ertk.sklearn.utils.GridSearchVal
- class ertk.sklearn.utils.GridSearchVal(estimator, param_grid, *, scoring=None, n_jobs=None, refit=False, cv=None, verbose=0, pre_dispatch='2*n_jobs', error_score=nan, return_train_score=False)
Bases:
GridSearchCVGrid-search but using a single validation set. Simple hack of GridSearchCV to avoid retraining on train + val data.
- __init__(estimator, param_grid, *, scoring=None, n_jobs=None, refit=False, cv=None, verbose=0, pre_dispatch='2*n_jobs', error_score=nan, return_train_score=False)
Methods
__init__(estimator, param_grid, *[, ...])fit(X[, y, groups])Run fit with all sets of parameters.
set_fit_request(*[, groups])Configure whether metadata should be requested to be passed to the
fitmethod.Inherited Methods
decision_function(X)Call decision_function on the estimator with the best found parameters.
get_metadata_routing()Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
inverse_transform(X)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])Return the score on the given data, if the estimator has been refit.
score_samples(X)Call score_samples on the estimator with the best found parameters.
set_params(**params)Set the parameters of this estimator.
transform(X)Call transform on the estimator with the best found parameters.
Attributes
classes_Class labels.
n_features_in_Number of features seen during fit.
- fit(X, y=None, *, groups=None, **fit_params)
Run fit with all sets of parameters.
- Parameters:
- Xarray-like of shape (n_samples, n_features) or (n_samples, n_samples)
Training vectors, where
n_samplesis the number of samples andn_featuresis the number of features. For precomputed kernel or distance matrix, the expected shape of X is (n_samples, n_samples).- yarray-like of shape (n_samples, n_output) or (n_samples,), default=None
Target relative to X for classification or regression; None for unsupervised learning.
- **paramsdict of str -> object
Parameters passed to the
fitmethod of the estimator, the scorer, and the CV splitter.If a fit parameter is an array-like whose length is equal to
num_samplesthen it will be split by cross-validation along withXandy. For example, the sample_weight parameter is split becauselen(sample_weights) = len(X). However, this behavior does not apply togroupswhich is passed to the splitter configured via thecvparameter of the constructor. Thus,groupsis used to perform the split and determines which samples are assigned to the each side of the a split.
- Returns:
- selfobject
Instance of fitted estimator.
- set_fit_request(*, groups: bool | None | str = '$UNCHANGED$') GridSearchVal
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
- Parameters:
- groupsstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
groupsparameter infit.
- Returns:
- selfobject
The updated object.