BayesianOptimization
A Python implementation of global optimization with gaussian processes.
A Python library for finding the best input settings for a slow or expensive function without brute-force search. It uses Bayesian optimization with a Gaussian process model to intelligently decide where to test next, minimizing the number of runs needed.
This is a Python library for finding the best settings for a function when running that function is slow or expensive. The problem it solves is common in machine learning and scientific computing: you have a process that takes some input parameters and produces a score, but running it even once takes significant time or resources. You want to find the combination of inputs that produces the best score without having to try thousands of combinations at random.
The technique it uses is called Bayesian optimization. The basic idea is that after each test, the algorithm builds a statistical model of how the function behaves across the input space. That model, called a Gaussian process, gives the algorithm two things: an estimate of what the output will be at any untested point, and a measure of how uncertain that estimate is. The algorithm then uses this information to decide where to look next, balancing between exploring areas it knows little about and focusing on areas that look promising.
Using the library is straightforward. You define a Python function that takes named parameters and returns a number you want to maximize. You tell the optimizer the allowed range for each parameter. Then you call the maximize method and specify how many random starting points to try and how many Bayesian-guided steps to run afterward. After it finishes, you can read off the best parameter combination it found.
The library supports constrained optimization, meaning you can set hard limits on what parameter values are allowed. It also includes a feature called SequentialDomainReduction, which progressively narrows the search region as the optimizer gains confidence, helping it converge faster on problems where the optimum is in a small corner of the parameter space.
The library is installable via pip or Conda and is written in pure Python. It is actively developed and citable in academic work, with BibTeX citations provided for the core method and its extensions.
Where it fits
- Tune hyperparameters for a machine learning model, like learning rate and layer count, efficiently without trying every combination
- Find the optimal settings for a chemistry experiment or simulation where each run takes hours to complete
- Narrow down the best configuration for a slow API or data pipeline step without running a full grid search