bayes_halving_search_cv.BayesHalvingSearchCV#
- class bayes_halving_search_cv.BayesHalvingSearchCV(estimator, param_grid, *, scoring=None, n_jobs=None, refit=True, cv=None, verbose=0, random_state=None, pre_dispatch='2*n_jobs', error_score=nan, return_train_score=False, n_iter=25, promote_k=3, data_zones=(0.005, 0.01, 0.1, 1.0), warmup=3, subsample='auto', subsample_columns=None, n_starts=1, start_points=None)#
Gaussian-Process Bayesian search over a discrete hyperparameter grid, with bullseye multi-fidelity data growth and scatter-search multi-start.
Despite the name, the fidelity mechanism is this package’s self-calibrating bullseye-ring data growth (see
PatternSearchCV), not classic successive halving; the name was chosen by the project’s author and kept as-is.param_gridand multi-start (n_starts/start_points) follow the exact same standard asPatternSearchCV— see its docstring andPatternSearchCV_SPEC.mdfor the search-space and scatter-search conventions; they are not duplicated here. This estimator has zero additional dependencies beyondPatternSearchCV’s own (numpy,scipy,scikit-learn— the GP surrogate issklearn.gaussian_process.GaussianProcessRegressorplus a hand-rolled Expected Improvement acquisition; no Optuna, no torch).- Parameters:
- estimatorestimator object
The estimator to tune.
- param_griddict
Maps parameter names to either an explicit list of values or a
(low, high, num)tuple expanded to a linspace grid.- n_iterint, default=25
Budget of genuine (non-cache-served) model evaluations per start, across all data zones combined, excluding the bounded final-polish re-scores (at most
promote_k+ 1 extra evaluations per start).- promote_kint, default=3
Number of top-scored configurations re-scored (and used to seed a fresh Gaussian Process) whenever the bullseye rings climb to a new data zone, and again for the mandatory final polish at full data.
- data_zonesint or sequence of float, default=(0.005, 0.01, 0.1, 1.0)
The data ladder. Identical semantics to
PatternSearchCV.data_zones.- warmupint, default=3
Positions (starting point included) before the bullseye rings self-calibrate. Identical semantics to
PatternSearchCV.warmup.- subsample{“auto”, “expanding”, “stratified”, “random”}, default=”auto”
Identical semantics to
PatternSearchCV.subsample.- subsample_columnssequence of int, optional
Column subset watched by the “stratified” transition sampler.
- n_startsint, default=1
Independent Bayesian searches. Starts are chosen by the same scatter-search mechanism as
PatternSearchCV(QMC pool + greedy maximin); every start runs to completion (no elimination between starts) and the best full-data optimum wins. UnlikePatternSearchCV, there is no state-match merging between starts (no clean analog for a stochastic search) — the shared dedup cache is the cost-saving mechanism instead.- start_pointslist of dict, optional
Explicit start points (parameter dicts); they take seats before scatter-search generation fills the rest.
Notes
verbose >= 1narrates every search decision as it happens (proposals, ring crossings, data climbs, final polish) and, at the end offit, logs a fullcross_validatepass on the winning parameters over the complete dataset with the user’s owncvsplitter, exactly mirroringPatternSearchCV. This addsn_splitsextra fits and is skipped entirely atverbose=0(the default).verbose >= 2additionally logs per-proposal debug detail.- property classes_#
Class labels.
Only available when
refit=Trueand the estimator is a classifier.
- decision_function(X)#
Call decision_function on the estimator with the best found parameters.
Only available if
refit=Trueand the underlying estimator supportsdecision_function.- Parameters:
- Xindexable, length n_samples
Must fulfill the input assumptions of the underlying estimator.
- Returns:
- y_scorendarray of shape (n_samples,) or (n_samples, n_classes) or (n_samples, n_classes * (n_classes-1) / 2)
Result of the decision function for
Xbased on the estimator with the best found parameters.
- fit(X, y=None, **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.
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Added in version 1.4.
- Returns:
- routingMetadataRouter
A
MetadataRouterencapsulating routing information.
- get_params(deep=True)#
Get parameters for this estimator.
- Parameters:
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns:
- paramsdict
Parameter names mapped to their values.
- inverse_transform(X)#
Call inverse_transform on the estimator with the best found params.
Only available if the underlying estimator implements
inverse_transformandrefit=True.- Parameters:
- Xindexable, length n_samples
Must fulfill the input assumptions of the underlying estimator.
- Returns:
- X_original{ndarray, sparse matrix} of shape (n_samples, n_features)
Result of the
inverse_transformfunction forXbased on the estimator with the best found parameters.
- predict(X)#
Call predict on the estimator with the best found parameters.
Only available if
refit=Trueand the underlying estimator supportspredict.- Parameters:
- Xindexable, length n_samples
Must fulfill the input assumptions of the underlying estimator.
- Returns:
- y_predndarray of shape (n_samples,)
The predicted labels or values for
Xbased on the estimator with the best found parameters.
- predict_log_proba(X)#
Call predict_log_proba on the estimator with the best found parameters.
Only available if
refit=Trueand the underlying estimator supportspredict_log_proba.- Parameters:
- Xindexable, length n_samples
Must fulfill the input assumptions of the underlying estimator.
- Returns:
- y_predndarray of shape (n_samples,) or (n_samples, n_classes)
Predicted class log-probabilities for
Xbased on the estimator with the best found parameters. The order of the classes corresponds to that in the fitted attribute classes_.
- predict_proba(X)#
Call predict_proba on the estimator with the best found parameters.
Only available if
refit=Trueand the underlying estimator supportspredict_proba.- Parameters:
- Xindexable, length n_samples
Must fulfill the input assumptions of the underlying estimator.
- Returns:
- y_predndarray of shape (n_samples,) or (n_samples, n_classes)
Predicted class probabilities for
Xbased on the estimator with the best found parameters. The order of the classes corresponds to that in the fitted attribute classes_.
- score(X, y=None, **params)#
Return the score on the given data, if the estimator has been refit.
This uses the score defined by
scoringwhere provided, and thebest_estimator_.scoremethod otherwise.- Parameters:
- Xarray-like of shape (n_samples, n_features)
Input data, where
n_samplesis the number of samples andn_featuresis the number of features.- 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
Parameters to be passed to the underlying scorer(s).
Added in version 1.4: Only available if
enable_metadata_routing=True. See Metadata Routing User Guide for more details.
- Returns:
- scorefloat
The score defined by
scoringif provided, and thebest_estimator_.scoremethod otherwise.
- score_samples(X)#
Call score_samples on the estimator with the best found parameters.
Only available if
refit=Trueand the underlying estimator supportsscore_samples.Added in version 0.24.
- Parameters:
- Xiterable
Data to predict on. Must fulfill input requirements of the underlying estimator.
- Returns:
- y_scorendarray of shape (n_samples,)
The
best_estimator_.score_samplesmethod.
- set_callbacks(*callbacks)#
Set callbacks for the estimator.
- Parameters:
- *callbackscallback instances
The callbacks to set.
- Returns:
- selfestimator instance
The estimator instance itself.
- set_params(**params)#
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
- **paramsdict
Estimator parameters.
- Returns:
- selfestimator instance
Estimator instance.
- transform(X)#
Call transform on the estimator with the best found parameters.
Only available if the underlying estimator supports
transformandrefit=True.- Parameters:
- Xindexable, length n_samples
Must fulfill the input assumptions of the underlying estimator.
- Returns:
- Xt{ndarray, sparse matrix} of shape (n_samples, n_features)
Xtransformed in the new space based on the estimator with the best found parameters.