bayes_halving_search_cv.PatternSearchCV#

class bayes_halving_search_cv.PatternSearchCV(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, poll='auto', mesh_expansion=1.0, contraction='patient', data_zones=(0.005, 0.01, 0.1, 1.0), warmup=3, subsample='auto', subsample_columns=None, n_starts=1, start_points=None)#

Hooke-Jeeves pattern search over a discrete hyperparameter grid.

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.

poll{“auto”, “complete”, “opportunistic”}, default=”auto”

Exploratory sweep mode. “complete” evaluates all +/-delta probes around the fixed center in one parallel batch (MATLAB UseCompletePoll) plus the composite of improving dimensions; “opportunistic” is the classic 1961 sequential sweep with immediate acceptance. “auto” picks “complete” when n_jobs / n_splits >= 2, else “opportunistic” - on every machine this package has been benchmarked on so far (5-fold CV, <=8 cores) that resolves to “opportunistic”, so “complete” poll has not actually been measured, but “auto” keeps the adaptivity for users with many more cores than CV folds instead of hardcoding a choice that was never tested against.

mesh_expansionfloat, default=1.0

Step-size multiplier applied after a successful sweep. 1.0 (default) is classic Hooke-Jeeves (contraction only); 2.0 matches MATLAB GPS. Raise it on fine, continuous-like grids.

contraction{“patient”, “eager”}, default=”patient”

When the mesh contracts. “patient” (classic Hooke-Jeeves, default): only after a failed exploratory sweep. “eager” (prototype-faithful): a failed pattern move also contracts, spending step resolution faster. Across five controlled rounds on the retail benchmark (Experiments 7-11), “patient” and “eager” were tied on every cost metric that matters - identical evaluation counts, identical full-fit equivalents, identical best point and score in every round. Wall-clock bounced both directions within the machine’s noise floor with no consistent winner (patient faster in 3 of 5 rounds, eager in 2 of 5). There has never been a measured advantage to “eager” in this project, so “patient” is the default: it also avoids “eager“‘s untested-on-rugged-landscapes premature-convergence risk at zero measured cost. If you use “eager” anyway, pair it with n_starts > 1 to hedge that risk.

data_zonesint or sequence of float, default=(0.005, 0.01, 0.1, 1.0)

The data ladder. An int n gives n evenly divided levels (4 -> [0.25, 0.5, 0.75, 1.0]); a sequence gives explicit ascending fractions ending at 1.0; 1 disables multi-fidelity. This aggressive 0.5%-start ladder was set as the default after five successive halvings of the starting zone (10% -> 5% -> 2.5% -> 1% -> 0.5%) each matched or beat the one before it on the retail benchmark, with 0.5% giving 5.09 full-fit equivalents at the same optimum (805.038) that every less-aggressive ladder also found. Evidence is from one dataset/grid (523K rows, a 3-parameter ExtraTrees search). The resource floor (min_rows = max(2*(n_splits+1), 8)) protects small datasets from an unreasonably tiny first rung regardless.

warmupint, default=3

Number of positions (starting point included) before the bullseye rings self-calibrate. The patience dial: higher = data is added closer to the optimum. Minimum 3 (two displacement readings).

subsample{“auto”, “expanding”, “stratified”, “random”}, default=”auto”

How the data-zone priority ordering is built. “auto” picks “stratified” for time-ordered splitters (TimeSeriesSplit), else “random”. “stratified” (the transition sampler) measurably beat “expanding” on the retail benchmark’s aggressive 5% starting zone (lower MAE, less compute, faster wall-clock) and is fail-soft by design (degrades to systematic sampling in the worst case), which is why it is now the time-series default instead of “expanding”. “expanding” remains available explicitly. “random” on temporal data leaks future rows - see docs.

subsample_columnssequence of int, optional

Column subset watched by the “stratified” transition sampler.

n_startsint, default=1

Independent climbers. Starts are chosen by scatter search (QMC pool + greedy maximin); every climber runs to completion (no elimination) and the best full-data optimum wins.

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 (moves, contractions, ring crossings, data climbs, merges) 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 - mirroring a typical post-search sanity check. This adds n_splits extra fits and is skipped entirely at verbose=0 (the default), so it never costs anything unless requested. verbose >= 2 additionally logs per-probe 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.