Optimizer Workflows
Use this sub-skill when a user wants to run the core bayes_opt.BayesianOptimization
lifecycle for a black-box objective or a small machine-learning hyperparameter
optimization job. This route is self-contained: future agents should not need to
open the original repository docs, notebooks, tests, or examples.
Load This When
- The user has a Python function or external evaluation service and wants to
optimize scalar parameters with Bayesian optimization.
- The task mentions
BayesianOptimization,pbounds,maximize,max,res,
probe, register, suggest, random_sample, set_bounds,
set_gp_params, save_state, load_state, or predict.
- The user asks how to turn a loss into an optimization target, persist an
optimizer, resume a run, validate results, or handle duplicate/noisy
observations.
- The user wants a tiny scikit-learn HPO pattern using
bayesian-optimization.
Core Rules To Apply First
- The package maximizes target values. Convert losses to scores, commonly by
returning -loss or using a scikit-learn scorer whose larger value is better.
pboundskeys must match the objective function keyword arguments exactly.
Dict inputs are safest. Array/list inputs use the pbounds insertion order.
- Keep objective functions deterministic enough for the GP when possible. For
noisy objectives, set allow_duplicate_points=True only when repeated
evaluations at the same coordinates are intentional.
- Use
f=Noneonly for manual ask-tell loops: callsuggest(), evaluate
outside the optimizer, then register(params, target). Do not call eager
probe(..., lazy=False) or maximize() with f=None.
- After
maximize(), callpredict(..., fit_gp=True)before relying on GP
predictions; the final registered point may not be included in the fitted GP
until prediction refits it.
- Save/load state as JSON with a newly constructed compatible optimizer: same
objective-compatible kwargs, pbounds, acquisition strategy, constraints,
duplicate policy, and any bounds transformer.
Bundled References
- API reference: constructor and method
signatures, lifecycle semantics, TargetSpace result behavior, predict
return shapes, and state persistence details.
- Workflow recipes: basic optimization, manual
ask-tell evaluations, tiny HPO patterns, loss sign handling, persistence,
duplicate/noisy recipes, bounds updates, and result validation.
- Troubleshooting: symptoms, causes, and fixes
for key mismatches, duplicate points, unfitted GP errors, stale state loads,
target-sign mistakes, bounds/type changes, slow objectives, and f=None
misuse.