Home

RandomizedSearchCV

RandomizedSearchCV is a hyperparameter optimization tool in scikit-learn that performs randomized search with cross-validation. It aims to identify a good combination of hyperparameters for an estimator by evaluating a fixed number of parameter settings sampled from specified distributions or sequences. The search uses cross-validated performance to assess each candidate configuration and selects the one that yields the best score according to the configured scoring metric. After fitting, the best_estimator_ can be refit on the full training data if requested.

Key features include the param_distributions argument, which describes the parameter space as distributions or lists of

Compared with GridSearchCV, RandomizedSearchCV does not exhaustively try all combinations but instead samples a fixed number

Typical outputs include best_params_, best_score_, and cv_results_. The estimator with the best settings can be retrieved

values;
n_iter,
which
controls
how
many
configurations
are
sampled;
and
standard
options
such
as
cv,
scoring,
refit,
random_state,
n_jobs,
and
verbose.
Parameter
distributions
may
use
distributions
from
scipy.stats
or
explicit
lists,
enabling
both
continuous
and
discrete
searches.
Random
state
ensures
reproducibility
of
the
sampling.
of
configurations.
This
makes
it
more
scalable
for
large
or
high-dimensional
hyperparameter
spaces
and
often
faster
while
still
delivering
strong
performance.
However,
there
is
a
risk
of
missing
the
optimal
configuration,
and
results
can
vary
between
runs
if
a
random
state
is
not
fixed.
via
best_estimator_,
and,
if
refit
is
enabled,
this
estimator
is
trained
on
the
entire
training
dataset.
This
approach
is
widely
used
when
the
hyperparameter
space
is
large
or
expensive
to
evaluate.