pdmlabs.optimization.gpyopt_adapter#
GPyOpt Bayesian Optimization adapter for PdMLabs.
All GPyOpt imports are lazy (inside method bodies) so this module is
importable even when gpyopt is not installed.
Install GPyOpt support with:
pip install pdmlabs[gpyopt]
The adapter uses GPyOpt.methods.BayesianOptimization as the single
entry point. Hyperparameter space conversion rules:
listwith string values β'categorical'domain (GPyOpt uses integer indices internally; cast back via original list)listwith numeric values β'discrete'domain (preserves the exact candidate set defined by the user)scipy.statsfrozen dist β'continuous'domain (bounds derived fromppf(0.01)/ppf(0.99))
Parallelism works as follows:
batch_size=n_jobstells the acquisition function to proposen_jobscandidates per BO iteration ('local_penalization'evaluator whenn_jobs > 1,'sequential'otherwise).Inside
gpyopt_target,joblib.Parallel(n_jobs=n_jobs)evaluates thosen_jobscandidates concurrently β mirroring how Mangoβs@scheduler.parallel(n_jobs)evaluates a batch of configs in parallel.num_coresis always set to1to prevent GPyOpt from spawning an additional layer of subprocesses on top ofjoblib.The number of BO iterations is set so that total function evaluations (
initial_random + n_iterations Γ n_jobs) stay within theMAX_RUNSbudget β seecalculate_optimizer_budgetinutils.py.
Classes
Adapter for |
- class pdmlabs.optimization.gpyopt_adapter.GPyOptAdapter#
Bases:
BaseOptimizerAdapterAdapter for
GPyOpt.methods.BayesianOptimization.Requires
gpyoptandGPy >= 1.0.8(pip install pdmlabs[gpyopt]).Parallelism model#
batch_size=n_jobscandidates are proposed per BO iteration by the'local_penalization'acquisition evaluator (or'sequential'whenn_jobs == 1). Thegpyopt_targetwrapper evaluates those candidates in parallel viajoblib.Parallel(n_jobs=n_jobs), matching Mangoβs@scheduler.parallelapproach.num_coresis always1so GPyOpt does not add a second layer of subprocesses.- maximize(param_space: dict, objective_fn, n_iterations: int, n_jobs: int, initial_random: int, constraint_fn=None) dict#
Maximise objective_fn using GPyOpt Bayesian optimisation.
- minimize(param_space: dict, objective_fn, n_iterations: int, n_jobs: int, initial_random: int, constraint_fn=None) dict#
Minimise objective_fn using GPyOpt Bayesian optimisation.
- supports_categorical: bool = True#