Bayesian Optimization — Sequential Model-Based Hyperparameter Tuning

Decision Sciences
Introduced by
Mockus (1975); popularised for ML by Snoek, Larochelle & Adams (2012)
Year
1975 (foundational); 2012 (ML standard)
Type
Sequential model-based black-box optimization

What does it do?

Bayesian Optimization is a sequential, model-based strategy for finding the optimum of expensive black-box functions with as few evaluations as possible.

Its foundations are usually traced to Mockus (1975), and it reached mainstream machine-learning practice through Snoek, Larochelle, and Adams (2012). It fits a probabilistic surrogate, typically a Gaussian Process, to past observations and uses an acquisition function to decide where to evaluate next, trading off exploration of uncertain regions against exploitation of promising ones.

The intuition behind the method

Imagine you have to find the best settings for a machine-learning model, but each trial takes hours to run. You cannot afford to test every combination. Bayesian Optimization acts like a careful scientist: it builds a running map of what has been tried and what results came back, uses that map to guess where the optimum probably lies, and then picks the next experiment that is most likely to improve the best result seen so far. As more experiments complete, the map grows more accurate and the choices smarter — all without ever needing to know the mathematical formula inside the black box.

History

Jonas Mockus and colleagues developed the theoretical basis in the 1970s, including expected improvement as a criterion for sequential experimental design. The approach remained largely academic until Snoek, Larochelle, and Adams (2012) applied Gaussian-Process-based Bayesian Optimization to tuning machine-learning algorithms, reporting comparisons with expert tuning and random search. Peter Frazier's 2018 tutorial (arXiv:1807.02811) later provided a unified introduction to the method for a wider audience.

When to use it

Choose Bayesian Optimization when each evaluation of the objective is expensive or slow, for example when training a large model, running a simulation, or performing a laboratory experiment, and when the budget allows only tens or low hundreds of evaluations. Every parameter needs explicit bounds, because the search and the surrogate operate within a defined region. Continuous and ordinal parameters are handled directly. Purely categorical spaces, or spaces with more than roughly 10–20 parameters, are poorer fits for a standard Gaussian Process surrogate; alternative surrogates such as random forests, or dimensionality reduction before optimisation, may be considered in that case. Do not choose it when evaluations are cheap and can be run in parallel, because random or grid search may then reach comparable results with much less implementation effort.

Limitations and considerations

  • Dimensionality: Gaussian Process fitting becomes computationally expensive, and surrogate accuracy declines as the number of parameters grows, with the loss becoming significant beyond roughly 10–20 dimensions.
  • Kernel and acquisition sensitivity: results depend on the kernel and acquisition choices, and poor defaults can slow convergence, especially on non-stationary or multi-modal objectives.
  • Sequential by default: each evaluation must finish before the next candidate is chosen, so parallel use requires batch or asynchronous extensions.
  • Bounded spaces only: parameters without explicit ranges cannot be handled directly.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Sample efficiency: because each new point is chosen using all earlier results, the method usually needs fewer evaluations than grid or random search to reach a good configuration, which matters when each evaluation is costly.
  • Explicit exploration–exploitation criterion: the acquisition function (EI, UCB, or PI) states the trade-off as a defined formula, so the choice of the next point can be inspected and justified.
  • Predictive uncertainty: the Gaussian Process returns a variance alongside its mean at every candidate, and the acquisition function uses it to favour poorly explored regions.
  • No gradients required: the objective is treated as a black box, so only input–output pairs are needed.

Applications

  • Tuning hyperparameters of machine-learning and deep-learning models where each training run is computationally expensive.
  • Neural Architecture Search (NAS): selecting architectural choices such as layer widths, activation functions, and skip connections.
  • Experimental design in engineering and natural sciences where each physical experiment is costly or time-consuming.
  • Automatic Machine Learning (AutoML) pipelines that select both algorithms and their hyperparameters jointly.
  • Drug discovery and materials science, where evaluating a candidate configuration requires laboratory work.

How it works

How it works

1

The practitioner defines the search space: every hyperparameter to be tuned is given a type (continuous, ordinal) and a range, with lower and upper bounds, within which the optimizer may search. A clear space definition is a prerequisite to everything else and keeps the surrogate from being asked to extrapolate beyond the region where it has data.

2

A small number of points in the search space are evaluated at random or via a space-filling design (e.g., Latin hypercube sampling). These initial observations (a common starting point is five to ten, more in higher-dimensional spaces) give the surrogate enough data to form a first, rough map of the objective landscape before the sequential loop begins.

3

All observations collected so far are used to fit a probabilistic surrogate model, most commonly a Gaussian Process. The GP returns a posterior mean mu(x) and a posterior standard deviation sigma(x) at every point in the space, capturing both what is known and how confident the model is. The surrogate is cheap to evaluate, so it can be queried thousands of times in place of the costly true objective.

Formula
f(x) \mid \mathcal{D} \sim \mathcal{N}\big(\mu(x), \sigma^2(x)\big)
4

An acquisition function, such as Expected Improvement (EI), Upper Confidence Bound (UCB) or Probability of Improvement (PI), is maximised over the surrogate to select the next candidate point. With f_best the best value observed so far (for maximisation) and f(x) distributed according to the GP posterior: EI(x) = E[max(f(x) - f_best, 0)]; UCB(x) = mu(x) + kappa * sigma(x), where kappa is a tunable confidence weight; PI(x) = P(f(x) > f_best). This step resolves the exploration-exploitation trade-off: regions with high predicted performance and regions with high uncertainty both attract attention.

Formula
\mathrm{EI}(x)=\mathbb{E}\big[\max(f(x)-f_{\text{best}},0)\big],\quad \mathrm{UCB}(x)=\mu(x)+\kappa\,\sigma(x),\quad \mathrm{PI}(x)=P\big(f(x)>f_{\text{best}}\big)
5

The candidate point selected by the acquisition function is passed to the true objective, for example by training and validating a neural network with those hyperparameters. This evaluation is the expensive step. Its result (the score) is recorded alongside the candidate's coordinates.

6

The new observation is added to the dataset, the surrogate is refitted, and the loop returns to the acquisition step. After the evaluation budget is exhausted, the configuration that produced the best observed score is returned as the recommendation. If evaluations are noisy, that score is optimistically biased, so the final candidates should be re-evaluated or confirmed on held-out data.

Common pitfalls

  • Too few initial probes: with only a handful of initial points the surrogate is poorly fitted; a common starting point is at least five, and more in higher-dimensional spaces.
  • Very short runs: with fewer than roughly ten total objective evaluations (including initial probes) the surrogate is unlikely to be reliable, and simple random search is preferable.
  • Unexamined acquisition choice: PI is the most exploitation-heavy option and can converge prematurely, while UCB's exploration is set by a tunable confidence weight. No single acquisition function suits every objective, so the default should be checked against the problem's behaviour.
  • Ignoring noise: ML training runs are usually stochastic, so the best observed score is biased upward and the reported best configuration may be partly luck. Re-evaluate the top candidates several times, consider a noise-aware surrogate, and confirm on held-out data.
  • Trusting the optimiser without checking: inspect the convergence trace (best-seen score against evaluation count) to detect stagnation early.
  • Using it where evaluations are cheap: when evaluations are inexpensive, random or grid search may reach comparable results with far less implementation overhead.

Frequently asked questions

How is Bayesian Optimization different from grid search or random search?

Grid search evaluates a fixed lattice of configurations and random search samples uniformly at random; both ignore the results of previous trials when choosing the next point. Bayesian Optimization uses all past observations to build a surrogate model and selects the next point most likely to improve over the current best, which usually makes it more sample-efficient when evaluations are expensive.

What acquisition function should I use?

Expected Improvement (EI) is a widely used default: it measures the expected gain over the current best and is a reasonable choice across many problem types. Upper Confidence Bound (UCB) adds a tunable exploration bonus and may suit cases where the landscape is poorly understood. Probability of Improvement (PI) is more exploitation-heavy and can converge prematurely. Starting with EI and trying UCB if the optimizer appears to stagnate is a reasonable heuristic.

How many evaluations are needed?

There is no universal rule. Fewer than about ten total objective evaluations (including initial probes) give the surrogate too little data to be reliable. A common starting point is five to ten initial points followed by a few tens of sequential steps, depending on dimensionality and evaluation cost. If the best-seen score stops improving for several consecutive evaluations, consider stopping, but do not apply this mechanically: stagnation may reflect a local optimum or a poor kernel or acquisition choice, so check the convergence trace and the remaining budget first.

Can Bayesian Optimization be parallelised?

Standard Bayesian Optimization is inherently sequential, because each new candidate depends on the surrogate fitted to all completed evaluations. Batch-mode variants propose several candidates at once, and asynchronous variants start a new candidate whenever a worker becomes free. Both reduce idle time but require a rule for handling candidates chosen before the outcomes of pending evaluations are known. Check which of these strategies a given optimisation library implements before relying on it.

Related methods

Sources

  1. Snoek, J., Larochelle, H., & Adams, R.P. (2012). Practical Bayesian Optimization of Machine Learning Algorithms. Advances in Neural Information Processing Systems (NeurIPS), 25.

    Open publication reference
  2. Frazier, P.I. (2018). A Tutorial on Bayesian Optimization. arXiv:1807.02811.

    Open publication reference