Skip to main content

RandomizedSearchCV

Cross-validated search over random samples from parameter distributions — a budgeted alternative to exhaustive grid search.

Algorithm

Draws n_iter parameter combinations from the supplied distributions and evaluates each by K-fold cross-validation, refitting the best on the full data.

Constructor

Skigen::RandomizedSearchCV<Estimator> model(Estimator est, ParameterGrid distributions, int n_iter = 10, int cv = 5, bool refit = true, uint64_t random_state = nullopt);

Parameters

ParameterDefaultDescription
estimatorEstimator to tune.
param_distributionsDistributions to sample.
n_iter10Number of sampled configurations.
cv5Cross-validation folds.
random_statenulloptSeed for sampling.

Methods

MethodDescription
fit(X, y)Sample, search, and refit the best.
predict(X)Predict with the best estimator.
best_params()Best sampled parameters.
best_score()Best mean CV score.

Fitted Attributes

AccessorDescription
best_score()Best mean cross-validation score.
cv_results_params()Sampled parameter sets.

Example

Skigen::RandomizedSearchCV<Skigen::Ridge<double>> rs(Skigen::Ridge<double>(), dist, 10, 5);
rs.fit(X, y);
Verified against scikit-learn

This estimator is checked by the parity suite. See the generator tests/parity/generate_model_selection_reference.py and the reference fixtures in tests/parity/data/randomized_search_cv/, exercised by tests/parity/parity_model_selection.cpp.

API Reference

For full signatures see the RandomizedSearchCV API Reference.