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:

  • list with string values β†’ 'categorical' domain (GPyOpt uses integer indices internally; cast back via original list)

  • list with numeric values β†’ 'discrete' domain (preserves the exact candidate set defined by the user)

  • scipy.stats frozen dist β†’ 'continuous' domain (bounds derived from ppf(0.01) / ppf(0.99))

Parallelism works as follows:

  • batch_size=n_jobs tells the acquisition function to propose n_jobs candidates per BO iteration ('local_penalization' evaluator when n_jobs > 1, 'sequential' otherwise).

  • Inside gpyopt_target, joblib.Parallel(n_jobs=n_jobs) evaluates those n_jobs candidates concurrently β€” mirroring how Mango’s @scheduler.parallel(n_jobs) evaluates a batch of configs in parallel.

  • num_cores is always set to 1 to prevent GPyOpt from spawning an additional layer of subprocesses on top of joblib.

  • The number of BO iterations is set so that total function evaluations (initial_random + n_iterations Γ— n_jobs) stay within the MAX_RUNS budget β€” see calculate_optimizer_budget in utils.py.

Classes

GPyOptAdapter()

Adapter for GPyOpt.methods.BayesianOptimization.

class pdmlabs.optimization.gpyopt_adapter.GPyOptAdapter#

Bases: BaseOptimizerAdapter

Adapter for GPyOpt.methods.BayesianOptimization.

Requires gpyopt and GPy >= 1.0.8 (pip install pdmlabs[gpyopt]).

Parallelism model#

batch_size=n_jobs candidates are proposed per BO iteration by the 'local_penalization' acquisition evaluator (or 'sequential' when n_jobs == 1). The gpyopt_target wrapper evaluates those candidates in parallel via joblib.Parallel(n_jobs=n_jobs), matching Mango’s @scheduler.parallel approach. num_cores is always 1 so 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#