class sklearn.model_selection.RandomizedSearchCV(estimator, param_distributions, n_iter=10, scoring=None, fit_params=None, n_jobs=None, iid=’warn’, refit=True, cv=’warn’, verbose=0, pre_dispatch=‘2*n_jobs’, random_state=None, error_score=’raise-deprecating’, return_train_score=’warn’)
[source]
Randomized search on hyper parameters.
RandomizedSearchCV implements a “fit” and a “score” method. It also implements “predict”, “predict_proba”, “decision_function”, “transform” and “inverse_transform” if they are implemented in the estimator used.
The parameters of the estimator used to apply these methods are optimized by cross-validated search over parameter settings.
In contrast to GridSearchCV, not all parameter values are tried out, but rather a fixed number of parameter settings is sampled from the specified distributions. The number of parameter settings that are tried is given by n_iter.
If all parameters are presented as a list, sampling without replacement is performed. If at least one parameter is given as a distribution, sampling with replacement is used. It is highly recommended to use continuous distributions for continuous parameters.
Note that before SciPy 0.16, the scipy.stats.distributions
do not accept a custom RNG instance and always use the singleton RNG from numpy.random
. Hence setting random_state
will not guarantee a deterministic iteration whenever scipy.stats
distributions are used to define the parameter search space.
Read more in the User Guide.
Parameters: |
| ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Attributes: |
|
See also
GridSearchCV
ParameterSampler
The parameters selected are those that maximize the score of the held-out data, according to the scoring parameter.
If n_jobs
was set to a value higher than one, the data is copied for each parameter setting(and not n_jobs
times). This is done for efficiency reasons if individual jobs take very little time, but may raise errors if the dataset is large and not enough memory is available. A workaround in this case is to set pre_dispatch
. Then, the memory is copied only pre_dispatch
many times. A reasonable value for pre_dispatch
is 2 * n_jobs
.
decision_function (X) | Call decision_function on the estimator with the best found parameters. |
fit (X[, y, groups]) | Run fit with all sets of parameters. |
get_params ([deep]) | Get parameters for this estimator. |
inverse_transform (Xt) | Call inverse_transform on the estimator with the best found params. |
predict (X) | Call predict on the estimator with the best found parameters. |
predict_log_proba (X) | Call predict_log_proba on the estimator with the best found parameters. |
predict_proba (X) | Call predict_proba on the estimator with the best found parameters. |
score (X[, y]) | Returns the score on the given data, if the estimator has been refit. |
set_params (**params) | Set the parameters of this estimator. |
transform (X) | Call transform on the estimator with the best found parameters. |
__init__(estimator, param_distributions, n_iter=10, scoring=None, fit_params=None, n_jobs=None, iid=’warn’, refit=True, cv=’warn’, verbose=0, pre_dispatch=‘2*n_jobs’, random_state=None, error_score=’raise-deprecating’, return_train_score=’warn’)
[source]
decision_function(X)
[source]
Call decision_function on the estimator with the best found parameters.
Only available if refit=True
and the underlying estimator supports decision_function
.
Parameters: |
|
---|
fit(X, y=None, groups=None, **fit_params)
[source]
Run fit with all sets of parameters.
Parameters: |
|
---|
get_params(deep=True)
[source]
Get parameters for this estimator.
Parameters: |
|
---|---|
Returns: |
|
inverse_transform(Xt)
[source]
Call inverse_transform on the estimator with the best found params.
Only available if the underlying estimator implements inverse_transform
and refit=True
.
Parameters: |
|
---|
predict(X)
[source]
Call predict on the estimator with the best found parameters.
Only available if refit=True
and the underlying estimator supports predict
.
Parameters: |
|
---|
predict_log_proba(X)
[source]
Call predict_log_proba on the estimator with the best found parameters.
Only available if refit=True
and the underlying estimator supports predict_log_proba
.
Parameters: |
|
---|
predict_proba(X)
[source]
Call predict_proba on the estimator with the best found parameters.
Only available if refit=True
and the underlying estimator supports predict_proba
.
Parameters: |
|
---|
score(X, y=None)
[source]
Returns the score on the given data, if the estimator has been refit.
This uses the score defined by scoring
where provided, and the best_estimator_.score
method otherwise.
Parameters: |
|
---|---|
Returns: |
|
set_params(**params)
[source]
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
Returns: |
|
---|
transform(X)
[source]
Call transform on the estimator with the best found parameters.
Only available if the underlying estimator supports transform
and refit=True
.
Parameters: |
|
---|
sklearn.model_selection.RandomizedSearchCV
© 2007–2018 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.RandomizedSearchCV.html