Bayesian Gaussian Process

Machine Learning
Introduced by
O'Hagan, A.; Neal, R. M.; Rasmussen, C. E. & Williams, C. K. I.
Year
1978–2006
Type
Probabilistic kernel model
Family
Machine learning

What does it do?

A Bayesian Gaussian Process (GP) places a probability distribution directly over functions, using a kernel to encode how similar outputs should be for similar inputs.

Conditioning on observed data with Bayes' rule yields a posterior whose mean gives point predictions and whose variance gives uncertainty at every new input. It is used when the uncertainty of a prediction matters as much as the prediction itself.

The intuition behind the method

Imagine drawing infinitely many plausible curves through your data, each consistent with what you know. A GP quantifies how likely each curve is before and after seeing observations. The kernel determines which curves look smooth or wiggly, near or far-reaching. Once data arrive, the GP narrows the family of plausible curves around the observations while keeping wider uncertainty where data are sparse. This gives both a prediction and a confidence band. The band reflects uncertainty under the assumed kernel and noise model, and it can be misleading if those assumptions are wrong.

History

Gaussian process methods have roots in spatial statistics, where Kriging in geostatistics is an early example of prediction with a covariance model. Neal's work linked neural networks with infinitely many hidden units to Gaussian processes. Rasmussen and Williams's 2006 book became a standard machine learning reference. GP methods now underpin Bayesian optimisation pipelines in hyperparameter tuning and experimental design.

When to use it

Choose a GP when the inputs are continuous or structured, the dataset is small to medium, the underlying function is plausibly smooth, and calibrated uncertainty is needed, for example in active learning, Bayesian optimisation, or scientific inference. Inputs that mix continuous and categorical variables need dedicated kernels or encodings. As rough rules of thumb, exact inference is practical up to a few thousand observations. The range between a few thousand and roughly 10,000 observations is a grey zone where exact inference becomes slow, and sparse approximations should be considered there. Beyond roughly 10,000 rows, use such approximations. Inputs above about 20 features need a strong prior structure to work well. These thresholds are not fixed limits: the practical boundary depends on hardware, kernel and noise level, and no cited source fixes these values. Avoid GPs when only a fast point predictor is needed and uncertainty will not be used.

Limitations and considerations

  • Exact inference has O(n^3) cost in the number of observations, so large datasets require sparse or inducing-point approximations.
  • Predictions and uncertainty bands depend on the kernel; a misspecified kernel can give misleading uncertainty as well as poor predictions.
  • With non-Gaussian likelihoods such as classification, the closed-form posterior is lost and approximation error is added.
  • Fixed-form kernels cover distances poorly in high-dimensional input spaces, so performance degrades without dimensionality reduction or structured kernels.
  • Hyperparameters estimated by marginal likelihood are point estimates; they do not carry the full uncertainty that a fully Bayesian treatment would include.

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

Strengths

  • The posterior gives a full predictive distribution at each input, and its variance is larger away from the training data.
  • For regression with a Gaussian likelihood, the posterior is available in closed form, so no sampling is needed for moderate dataset sizes.
  • The kernel encodes explicit assumptions about smoothness, periodicity, and trend, and kernels can be combined additively or multiplicatively.
  • The log marginal likelihood can be used both to fit hyperparameters and to compare candidate kernels.
  • The posterior variance shows where uncertainty is highest, which is the quantity used to choose informative points in active learning and Bayesian optimisation.

Applications

  • Bayesian optimisation for hyperparameter tuning, experimental design, and AutoML.
  • Surrogate modelling in engineering simulations and computer experiments.
  • Spatial interpolation and geostatistics (Kriging).
  • Time-series forecasting with explicit uncertainty quantification.
  • Active learning: selecting the next observation with the highest posterior variance.
  • Scientific inference where uncertainty must be propagated alongside the prediction.

How it works

How it works

1

A GP prior is defined by a mean function m(x), often set to zero, and a covariance (kernel) function k(x,x') that encodes how outputs at two inputs co-vary. Together they specify a distribution over all functions, from which the model samples candidate solutions before any data are seen.

Formula
f(\mathbf{x}) \sim \mathcal{GP}(m(\mathbf{x}),\, k(\mathbf{x},\mathbf{x}'))
2

The kernel is the central modelling choice. Common kernels include the squared-exponential (RBF), Matern, periodic, and linear kernels, each encoding different assumptions about smoothness, periodicity, or trend. Kernels can be added or multiplied to build composite structure, and the choice should reflect what is known about the target function.

3

For regression with a Gaussian likelihood, conditioning on training observations (X, y) gives a posterior GP in closed form. The posterior mean is the point prediction at a new input x*, and the posterior variance is the remaining uncertainty, which shrinks near observations and grows in regions without data.

Formula
p(f^* | \mathbf{X}, \mathbf{y}, \mathbf{x}^*) = \mathcal{N}(\mu^*, \sigma^{*2})
4

Kernel hyperparameters such as length-scales, output variance, and noise level are estimated by maximising the log marginal likelihood. This objective trades off data fit against model complexity, so it can guide hyperparameter choice without a separate validation split in many settings. The result is a point estimate of the hyperparameters, not an average over them.

Formula
\hat{\boldsymbol{\theta}} = \arg\max \log p(\mathbf{y}|\mathbf{X},\boldsymbol{\theta})
5

For regression, the predictive distribution at a new point is Gaussian, with the posterior mean and variance as its parameters. For classification, the Gaussian likelihood no longer applies, so an approximation (Laplace, expectation propagation, or variational inference) is needed to turn the latent GP into class probabilities.

Common pitfalls

  • Using a default RBF kernel without checking whether the data are actually smooth and stationary.
  • Reporting only the posterior mean and discarding the predictive variance, which is the main advantage of the model.
  • Applying exact GP inference to large datasets (n > 10,000) without sparse or inducing-point approximations, causing memory and speed failures.
  • Treating marginal-likelihood hyperparameter optimisation as full Bayesian inference over hyperparameters; the latter requires sampling methods such as MCMC and is rarely done in practice.
  • Reading classification GP outputs as if the latent posterior were exact, without accounting for the error introduced by the approximation.

Frequently asked questions

Is a Gaussian process inherently Bayesian?

Yes. A GP defines a prior over functions, and conditioning on data yields a posterior via Bayes' rule. The predictive distribution marginalises over all functions consistent with the data, weighted by their posterior probability, which is the defining property of Bayesian inference.

How do I choose the kernel?

Start by asking whether the function is expected to be smooth (RBF/squared-exponential) or periodic (periodic kernel). Matern kernels are often used when the function is expected to be rougher than the RBF assumes, since the smoothness parameter controls how many times the sample functions are differentiable. Kernels can be combined additively or multiplicatively to capture composite structure, and candidate choices can be compared using the log marginal likelihood.

Can I use a GP on thousands of data points?

Exact GP inference has O(n^3) cost, which is feasible up to a few thousand points on modern hardware. For larger datasets, use sparse GP approximations such as inducing-point methods (FITC or VFE) or stochastic variational GPs. The practical dataset size then depends on the approximation, the number of inducing points, and the available hardware.

What is the difference between GP regression and GP classification?

GP regression uses a Gaussian likelihood, so the posterior is also Gaussian and can be computed in closed form. GP classification uses a Bernoulli (or softmax) likelihood, which is non-Gaussian, so the posterior must be approximated, commonly with the Laplace approximation or expectation propagation.

How does a GP compare to a neural network?

GPs are better suited to small datasets, provide predictive uncertainty directly, and are interpretable through the kernel. Neural networks are generally preferred for large, high-dimensional data. Neal's result connects infinitely wide neural networks to Gaussian processes, as noted in the history section.

What assumptions does a GP regression model make?

The closed-form posterior assumes Gaussian observation noise. The kernel determines the assumed behaviour: many standard kernels, such as RBF and Matern, are stationary, meaning the covariance depends only on the distance between inputs. The mean function is often taken as zero or a constant. Inputs and outputs are usually standardised before fitting, so that length-scales and the noise level are interpretable and the optimiser behaves well.

How do I check a fitted GP?

Hold out data and check that the predictive intervals cover the observed values at roughly the nominal rate. Inspect standardised residuals for trends or heavy tails that suggest a misspecified kernel. When comparing kernels, use the log marginal likelihood, but remember that it is computed on the training data, so confirm the choice on held-out data. Check whether fitted length-scales sit at their bounds, which usually signals a poorly identified kernel.

Related methods

Sources

  1. Rasmussen, C. E., & Williams, C. K. I. (2006). Gaussian Processes for Machine Learning. MIT Press.

    ISBN: 978-0-262-18253-9
  2. Bishop, C. M. (2006). Pattern Recognition and Machine Learning (Ch. 6). Springer.

    ISBN: 978-0-387-31073-2