General-Purpose Strategies
This page describes the general-purpose strategies that can be used with any Preset. For preset-specific strategies, see the documentation for each preset.
random
Samples parameters randomly.
Parameters are sampled according to their type:
| Parameter Type | Sampling Method |
|---|---|
IntParameter | Random selection based on step size when step is specified; uniform distribution over [low, high] otherwise |
FloatParameter | Uniform distribution in log space when log=True, linear space otherwise |
CategoricalParameter | Uniform random selection from choices |
BoolParameter | Uniform random selection from True/False |
Options:
| Parameter | Description | Default |
|---|---|---|
seed | Random seed for reproducibility | None |
The search continues until the trial budget (--n-trials) is exhausted.
grid
Exhaustively searches all parameter combinations.
Generates value lists for each parameter and evaluates all combinations via itertools.product.
Value list generation depends on the parameter type:
| Parameter Type | Value List Generation |
|---|---|
IntParameter | range(low, high+1, step) when step is specified; grid_points evenly spaced values otherwise |
FloatParameter | grid_points evenly spaced values in log space when log=True, linear space otherwise |
CategoricalParameter | All choices |
BoolParameter | [True, False] |
Options:
| Parameter | Description | Default |
|---|---|---|
grid_points | Number of grid points for parameters without an explicit step size | 5 |
The search automatically terminates when all combinations have been evaluated. Best suited for small search spaces.
optuna
Samples parameters using Optuna's Sampler. By default, uses TPE (Tree-structured Parzen Estimator), which prioritizes exploring promising parameter regions based on past trial results.
Options:
| Parameter | Description | Default |
|---|---|---|
sampler | Optuna sampler instance | TPESampler |
storage | Optuna storage URL (e.g., sqlite:///study.db) | None |
study_name | Optuna study name | None |
Specifying storage persists the search results, enabling interruption and resumption.