![]() |
Class KerasRegressor
Implementation of the scikit-learn regressor API for Keras.
Aliases:
- Class
tf.compat.v1.keras.wrappers.scikit_learn.KerasRegressor
- Class
tf.compat.v2.keras.wrappers.scikit_learn.KerasRegressor
__init__
__init__(
build_fn=None,
**sk_params
)
Initialize self. See help(type(self)) for accurate signature.
Methods
tf.keras.wrappers.scikit_learn.KerasRegressor.check_params
check_params(params)
Checks for user typos in params
.
Arguments:
params
: dictionary; the parameters to be checked
Raises:
ValueError
: if any member ofparams
is not a valid argument.
tf.keras.wrappers.scikit_learn.KerasRegressor.filter_sk_params
filter_sk_params(
fn,
override=None
)
Filters sk_params
and returns those in fn
's arguments.
Arguments:
fn
: arbitrary functionoverride
: dictionary, values to overridesk_params
Returns:
res
: dictionary containing variables in bothsk_params
andfn
's arguments.
tf.keras.wrappers.scikit_learn.KerasRegressor.fit
fit(
x,
y,
**kwargs
)
Constructs a new model with build_fn
& fit the model to (x, y)
.
Arguments:
x
: array-like, shape(n_samples, n_features)
Training samples wheren_samples
is the number of samples andn_features
is the number of features.y
: array-like, shape(n_samples,)
or(n_samples, n_outputs)
True labels forx
.**kwargs
: dictionary arguments Legal arguments are the arguments ofSequential.fit
Returns:
history
: object details about the training history at each epoch.
tf.keras.wrappers.scikit_learn.KerasRegressor.get_params
get_params(**params)
Gets parameters for this estimator.
Arguments:
**params
: ignored (exists for API compatibility).
Returns:
Dictionary of parameter names mapped to their values.
tf.keras.wrappers.scikit_learn.KerasRegressor.predict
predict(
x,
**kwargs
)
Returns predictions for the given test data.
Arguments:
x
: array-like, shape(n_samples, n_features)
Test samples wheren_samples
is the number of samples andn_features
is the number of features.**kwargs
: dictionary arguments Legal arguments are the arguments ofSequential.predict
.
Returns:
preds
: array-like, shape(n_samples,)
Predictions.
tf.keras.wrappers.scikit_learn.KerasRegressor.score
score(
x,
y,
**kwargs
)
Returns the mean loss on the given test data and labels.
Arguments:
x
: array-like, shape(n_samples, n_features)
Test samples wheren_samples
is the number of samples andn_features
is the number of features.y
: array-like, shape(n_samples,)
True labels forx
.**kwargs
: dictionary arguments Legal arguments are the arguments ofSequential.evaluate
.
Returns:
score
: float Mean accuracy of predictions onx
wrt.y
.
tf.keras.wrappers.scikit_learn.KerasRegressor.set_params
set_params(**params)
Sets the parameters of this estimator.
Arguments:
**params
: Dictionary of parameter names mapped to their values.
Returns:
self