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_grid and multi-start (n_starts/start_points) follow the exact same standard as PatternSearchCV — see its docstring and PatternSearchCV_SPEC.md for the search-space and scatter-search conventions; they are not duplicated here. This estimator has zero additional dependencies beyond PatternSearchCV’s own (numpy, scipy, scikit-learn — the GP surrogate is sklearn.gaussian_process.GaussianProcessRegressor plus 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. Unlike PatternSearchCV, 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 >= 1 narrates every search decision as it happens (proposals, ring crossings, data climbs, final polish) and, at the end of fit, logs a full cross_validate pass on the winning parameters over the complete dataset with the user’s own cv splitter, exactly mirroring PatternSearchCV. This adds n_splits extra fits and is skipped entirely at verbose=0 (the default). verbose >= 2 additionally logs per-proposal debug detail.

property classes_#

Class labels.

Only available when refit=True and the estimator is a classifier.

decision_function(X)#

Call decision_function on the estimator with the best found parameters.

Only available if refit=True and the underlying estimator supports decision_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 X based 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_samples is the number of samples and n_features is 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 fit method of the estimator, the scorer, and the CV splitter.

If a fit parameter is an array-like whose length is equal to num_samples then it will be split by cross-validation along with X and y. For example, the sample_weight parameter is split because len(sample_weights) = len(X). However, this behavior does not apply to groups which is passed to the splitter configured via the cv parameter of the constructor. Thus, groups is 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 MetadataRouter encapsulating 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_transform and refit=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_transform function for X based on the estimator with the best found parameters.

property n_features_in_#

Number of features seen during fit.

Only available when refit=True.

predict(X)#

Call predict on the estimator with the best found parameters.

Only available if refit=True and the underlying estimator supports predict.

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 X based 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=True and the underlying estimator supports predict_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 X based 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=True and the underlying estimator supports predict_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 X based 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 scoring where provided, and the best_estimator_.score method otherwise.

Parameters:
Xarray-like of shape (n_samples, n_features)

Input data, where n_samples is the number of samples and n_features is 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 scoring if provided, and the best_estimator_.score method otherwise.

score_samples(X)#

Call score_samples on the estimator with the best found parameters.

Only available if refit=True and the underlying estimator supports score_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_samples method.

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 transform and refit=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)

X transformed in the new space based on the estimator with the best found parameters.