pdmlabs.optimization.hyperopt_adapter#
Hyperopt TPE optimizer adapter for PdMLabs.
All hyperopt imports are lazy so this module is importable even when hyperopt is not installed. Install with:
pip install pdmlabs[hyperopt]
The adapter uses hyperopt.fmin with tpe.suggest (Tree-structured
Parzen Estimator) as the single entry point. initial_random is
forwarded to TPE as n_startup_jobs via functools.partial, so the
first initial_random evaluations are pure random before the density
estimator kicks in. max_evals is always the hard cap on total
evaluations regardless of n_startup_jobs.
Space conversion rules (all preserve exact candidate sets via hp.choice):
list[int | float | bool | mixed]->hp.choice(name, values)list[str]->hp.choice(name, values)rv_frozen->hp.uniform(name, ppf(0.01), ppf(0.99))
Parallelism note#
TPE is a strictly sequential density-estimation algorithm. Each candidate
is proposed based on all previous observed results; there is no batch-
proposal step (unlike GPyOptβs local_penalization). hyperopt.fmin
does not support multi-process parallelism without external infrastructure
(Spark / MongoDB).
n_jobs is accepted for API consistency but ignored. A warning
is emitted when n_jobs > 1, directing users to optimizer='mango',
'gpyopt', or 'smac' for parallel HPO.
Classes
Adapter for Hyperopt TPE via |
- class pdmlabs.optimization.hyperopt_adapter.HyperoptAdapter#
Bases:
BaseOptimizerAdapterAdapter for Hyperopt TPE via
hyperopt.fmin.Requires
hyperopt >= 0.3.0(pip install pdmlabs[hyperopt]).Parallelism#
Hyperoptβs TPE is strictly sequential;
n_jobs > 1emits a warning and falls back to a single worker. Useoptimizer='mango','gpyopt', or'smac'for parallel HPO.- maximize(param_space: dict, objective_fn, n_iterations: int, n_jobs: int, initial_random: int, constraint_fn=None) dict#
Maximise objective_fn using Hyperopt TPE.
- minimize(param_space: dict, objective_fn, n_iterations: int, n_jobs: int, initial_random: int, constraint_fn=None) dict#
Minimise objective_fn using Hyperopt TPE.
- supports_categorical: bool = True#