Successive-halving search over an exhaustive parameter grid.
Classes
class evaluation.tuning.halving_grid_search.HalvingGridSearchCV(SuccessiveHalvingSearchCV)
Successive-halving search over every combination in a parameter grid.
Constructor
__init__( self, estimator, param_grid, factor: int = 3, resource: str = 'n_samples', min_resource = 'auto', max_resource = 'auto', aggressive_elimination: bool = False, scoring = 'accuracy', cv: int = 5, refit: bool = True, verbose: int = 0, n_jobs: int = 1, random_seed = None, progress_callback = None, )
Parameters
estimator
Algorithm
The model template to optimize.
param_grid
dict or list of dict
Parameter grid defining the combinations to evaluate.
factor
int
= 3
Reduction factor between successive rounds.
resource
str
= "n_samples"
Resource increased between successive rounds.
min_resource
int or str
= "auto"
Minimum resource used in the first round.
max_resource
int or str
= "auto"
Maximum resource used in the final round.
aggressive_elimination
bool
= False
Whether to use aggressive candidate elimination.
scoring
str or callable
= "accuracy"
Metric used to rank candidates.
cv
int
= 5
Number of cross-validation folds.
refit
bool
= True
Whether to refit the best estimator on the complete dataset.
verbose
int
= 0
Verbosity level.
n_jobs
int
= 1
Number of parallel jobs used during cross-validation.
random_seed
int
Seed used for reproducible candidate ordering and CV splits.
progress_callback
callable
Callback invoked after each evaluated parameter combination.
python
>>> from tuiml.evaluation.tuning import HalvingGridSearchCV
>>> from tuiml.algorithms.trees import RandomForestClassifier
>>> from tuiml.datasets import load_iris
>>> data = load_iris()
>>> search = HalvingGridSearchCV(
... RandomForestClassifier(),
... {"max_depth": [2, 4], "n_estimators": [5, 10]},
... factor=2,
... cv=3,
... random_seed=0,
... )
>>> _ = search.fit(data.X, data.y)
>>> type(search).__name__
'HalvingGridSearchCV'
>>> len(search.cv_results_["params"]) > 0
True