BO is a powerful method to find the optimum of a black box function that is expensive to evaluate. It is especially useful to optimize functions that are computationally expensive to evaluate (e.g hyperparameter tuning)
Components of BO
1. Objective function f(x)
This is the black box function that is to be maximized or minimized for the inputs .
2. Surrogate Model
This model approximates the value of to reduce the number of evaluations. It balances between exploration (focusing on new areas) and exploitation (finding new areas that provide better results)
Gaussian process
They provide a measure for uncertainty for predictions.
Why GPs?
GPs predict the mean (expected value) as well as the confidence interval (variance) around the prediction
Exploration involves focusing on stages with high uncertainty
Exploitation involves focusing on better expected values
Hence, they are commonly used as surrogate models
but w h y do they work?
1. What are Gaussian Processes?
A stochastic process is a collection of random variables that are indexed by some parameter, typically time or space. It is a way to describe phenomena that evolve over time or space in a way that includes randomness. (e.g a stock)
A stochastic process is Gaussian if every finite collection of random variables in the process follows a multivariate normal (Gaussian) distribution.
This means we can describe the process entirely using its mean and covariance functions.
These functions are βsmoothβ in a way determined by the covariance function , which encodes assumptions about how outputs and are related.
For example:
- If is large when and are close, will change smoothly between and .
- If is small, at and are weakly correlated.
2. What are Kernel functions?
A kernel function is a mathematical function that computes the βsimilarityβ or βcorrelationβ between two inputs and in the input space.
In GP, It defines how the outputs are related or correlated based on the inputs.
3. Prior and Posterior in GPs
Prior
In a gaussian process, the prior states that the function values follow a multivariate gaussian distribution. If two inputs are very similar, the kernel gives them a high covariance, meaning their outputs are likely to be similar too.
Posterior
Calculated when data is observed. It is the updated understanding of the function. For a new input we predict the most likely output (mean) and estimate how uncertain we are about that prediction (variance)
4. Gaussian Process Formula
The GP assumes a joint Gaussian distribution for the observed values and the unknown value :
Where:
- : Mean function (often ).
- : Covariance matrix for observed inputs, calculated using the kernel.
- : Covariance vector between observed inputs and .
- : Variance at .
- : Noise term for observed data (e.g., measurement noise).
This is derived from the rules of conditional distribution of multivariate gaussians
The conditioning rule, written out
For two variables, and , jointly distributed as:
Where:
- : Means of and .
- : Variances of and .
- : Correlation coefficient between and .
To generalize to higher dimensions, the covariance between the variables needs to be considered too
- : Means of and .
- : Variances of and .
- : Covariance between and .
Assumption
Note that GPs assume the function being modeled is smooth and continuous, which is encoded using a kernel function (e.g RBF)
RF / Bayesian NNs
Can be used for cases where GPs are not suitable (e.g very high dimensional spaces)
3. Acquisition function
Determines the next value to be evaluated based on the surrogate model
- Expected Improvement (EI) β this acquisition function picks points that maximise expected improvement over the current best value
- Probability of Improvement (PI) β Picks points with the probability of improving over the current best.
- How is it different from the above?
- Upper Confidence Bound (UCB) β Balances mean and uncertainty
Steps involved in BO
- Initialisation: Start with a small set of random input points to evaluate the objective function
- Build surrogate model: fit a probabilistic model to approximate
- Optimise the acquisition function: use the surrogate model to determine where to evaluate next by optimizing the acquisition function
- Evaluate the model: Compute the objective function
- Update the model: add a new evaluation to the dataset
- Iterate: Repeat steps 3 to 5 until convergence
Limitations
- Scalability: good (only) for low dimensional spaces
- Model assumptions: performance depends on the choice of surrogate model
- Computational overhead: training the surrogate model can become expensive for large datasets