Gaussian Process

Machine Learning
Introduced by
Rasmussen, C. E. & Williams, C. K. I.
Year
2006 (book); roots in Kriging, 1951)
Type
Probabilistic non-parametric model
Family
Machine learning

What does it do?

A Gaussian Process (GP) is a non-parametric, fully probabilistic machine learning model that places a prior distribution directly over functions.

Rather than predicting a single value, it returns a predictive mean and an uncertainty estimate at every test point, making it especially valuable for regression on small to medium datasets and for Bayesian optimization tasks.

The intuition behind the method

Instead of fitting a fixed curve to your data, a Gaussian Process maintains a whole distribution over possible curves that are consistent with what you have observed. Before seeing data, it assumes functions should be smooth (as defined by a kernel). After seeing data, it narrows that distribution: nearby test points receive tight, confident predictions, while distant or data-sparse regions produce wide uncertainty bands. This built-in uncertainty quantification is what sets GPs apart from most other models.

History

Gaussian process methods trace their roots to Kriging, a geostatistical interpolation method associated with Danie Krige and formalised by Georges Matheron. In machine learning, Carl Rasmussen and Christopher Williams's 2006 MIT Press book Gaussian Processes for Machine Learning is the standard reference for Gaussian process regression.

When to use it

Choose a Gaussian Process when the dataset is small to moderate in size, when a predictive uncertainty estimate is needed alongside the point prediction, and when the input-output relationship can reasonably be assumed to be smooth. It is a common choice for Bayesian optimization and for surrogate models of expensive experiments or simulations, where each new observation is costly. Do not use exact GP inference when the number of observations is large, because its O(n^3) cost makes it impractical without sparse or approximate methods. Be cautious with high-dimensional inputs, discontinuous or strongly non-stationary responses, and predominantly categorical data, where standard kernels are less suitable.

Limitations and considerations

  • Exact inference costs O(n^3) time and O(n^2) memory in the number of training points, so exact GP becomes impractical as n grows; sparse or inducing-point approximations are needed for larger datasets.
  • Standard kernels rely on distances between inputs, and these distances become less informative in high-dimensional input spaces, which reduces predictive quality.
  • Predictive quality depends heavily on the kernel. A misspecified kernel can give intervals that are too narrow or too wide, and choosing the kernel structure requires domain knowledge.
  • GP classifiers have no closed-form posterior over class labels and depend on an approximation such as Laplace or expectation propagation, which adds a further layer of approximation. A GP classifier places a latent GP on the function and passes it through a non-Gaussian likelihood, such as probit or logistic, so the posterior is not Gaussian and the regression equations on this page do not apply directly to class labels. The mechanics on this page describe the regression case only.

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

Strengths

  • Each prediction comes with a posterior standard deviation that is smaller near training points and larger away from them, so the uncertainty output is part of the model rather than an add-on.
  • The kernel states the assumptions about smoothness and length scale explicitly, so they can be inspected, compared and changed.
  • Kernel hyperparameters are estimated by maximising the log marginal likelihood, which balances data fit against model complexity.
  • The posterior variance can guide where to measure next, for example through maximum-variance sampling in active learning. Bayesian optimization uses acquisition functions that combine the posterior mean and variance.

Applications

  • Regression on small to medium scientific and engineering datasets requiring calibrated confidence intervals.
  • Bayesian optimization of expensive black-box functions such as hyperparameter tuning or experimental design.
  • Surrogate modelling for costly computer simulations in aerospace, materials science, and climate modelling.
  • Spatio-temporal interpolation and geostatistical mapping (Kriging).
  • Active learning: using the posterior variance to select the most informative next measurement.
  • Time series modelling with periodic or composite kernels encoding seasonal structure.

How it works

How it works

1

A kernel function (commonly squared-exponential / RBF) encodes prior beliefs about function smoothness and length scale. It measures the similarity between any two input points: similar inputs should produce similar outputs. The choice of kernel shape strongly governs what kinds of functions the GP can represent.

Formula
k(\mathbf{x}, \mathbf{x}') = \sigma^2 \exp\!\left(-\frac{\|\mathbf{x}-\mathbf{x}'\|^2}{2l^2}\right)
2

Before any data are observed, the GP defines a prior distribution over functions: every finite collection of function values is jointly Gaussian with mean function m(x) and covariance given by the kernel. This prior is the starting belief about how the unknown function behaves.

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

Conditioning the prior on the observed training data yields the posterior distribution, which is also Gaussian. For training inputs X with observations y, noise variance sigma_n^2, training kernel matrix K, the vector k_* of kernel values between a new input x_* and the training inputs, and prior variance k(x_*, x_*) at x_*, the predictive mean is mu_* = k_*^T (K + sigma_n^2 I)^(-1) y and the predictive variance is sigma^2_* = k(x_*, x_*) - k_*^T (K + sigma_n^2 I)^(-1) k_*. The mean is the predictive function at x_*, and the variance measures uncertainty about the function at that input. The variance is small where training data are dense and larger where they are sparse.

Formula
f_* \mid \mathbf{X}, \mathbf{y}, \mathbf{x}_* \sim \mathcal{N}(\mu_*, \sigma^2_*)
4

Kernel hyperparameters (length scale, output variance, noise level) are estimated by maximising the log marginal likelihood of the training data. This objective rewards fit to the data and penalises unnecessary complexity, so regularisation comes from the likelihood itself rather than from a separate penalty term. The likelihood surface can have more than one local optimum, so the fitted values should be checked for plausibility.

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

At prediction time the posterior mean is returned as the point estimate and the posterior standard deviation as the uncertainty band. The band describes uncertainty about the underlying function. If observation noise is part of the quantity being predicted, the noise variance must be added before the interval is formed; otherwise the band will be too narrow to cover new noisy measurements.

Common pitfalls

  • Using the default RBF kernel without checking whether the function is stationary and smooth; periodic or discontinuous patterns require different kernels.
  • Forgetting to standardise continuous inputs and outputs before fitting. Because the covariance matrix depends on input scale, unscaled data can lead to ill-conditioned matrices and misleading length-scale estimates.
  • Treating the posterior mean alone as the deliverable and ignoring the uncertainty bands, which are a primary output of the model.
  • Applying exact GP to large datasets without switching to a sparse or inducing-point approximation, since the computational cost grows rapidly with the number of observations.
  • Reporting the posterior variance of the latent function as if it included measurement noise. Keep model uncertainty and observation noise distinct, and add the noise term when intervals must cover new noisy observations.
  • Accepting the first set of fitted hyperparameters without checking them, even though the marginal likelihood can have several local optima with different length scales.

Frequently asked questions

What kernel should I start with?

The squared-exponential (RBF) kernel is the default starting point because it produces infinitely differentiable, smooth functions and has interpretable length-scale and output-variance hyperparameters. Switch to a Matern kernel if you expect the function to be less smooth, or add a periodic component for seasonal data.

My dataset has 50,000 rows. Can I still use a GP?

Exact GP inference would be prohibitive at that scale. Consider sparse GP methods (e.g., inducing points / FITC) or stochastic variational GP, both of which bring training cost down to roughly O(nm^2) where m is the number of inducing points (m << n). Libraries such as GPyTorch implement these efficiently.

How is a GP different from Bayesian linear regression?

Bayesian linear regression places a prior over a fixed finite set of coefficients; the model's flexibility is therefore limited by the chosen basis functions. A GP places a prior directly over functions in an infinite-dimensional space, so its effective complexity adapts to the data without requiring you to pre-specify basis expansions.

Are the uncertainty estimates truly calibrated?

If the prior, kernel and noise model match the data-generating process, the posterior uncertainty is coherent with those assumptions. Real data rarely match them exactly: kernel misspecification or ignored noise structure can make intervals too narrow or too wide. Always check calibration on held-out data, for example with a posterior predictive check that plots observed against predicted values and compares the coverage of the credible intervals.

Can Gaussian Processes handle categorical or mixed-type inputs?

Standard GP kernels operate on continuous inputs. Categorical inputs require special kernels (e.g., Hamming distance kernel) or encoding. For predominantly categorical or very high-dimensional mixed data, tree-based models such as Random Forest or gradient boosting are usually a better starting point.

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. Gaussian process. Wikipedia.

    Open publication reference
  3. Mathematic for Machine Learning, p. 322

  4. SPC, p. 13