Wednesday, October 14, 2026
HomeData ScienceGaussian Processes for Machine Learning – Regression, Uncertainty and Bayesian Optimisation

Gaussian Processes for Machine Learning – Regression, Uncertainty and Bayesian Optimisation

Table of Content

📋 KEY INSIGHTS

  • A Gaussian Process (GP) is a probability distribution over functions: rather than learning a single function mapping inputs to outputs, it maintains a distribution of plausible functions consistent with the observed data. This gives GP models a principled, calibrated measure of uncertainty at every prediction point — the further a query point is from observed data, the higher the GP uncertainty.
  • The kernel (covariance function) encodes all assumptions about the functions in a GP: smoothness, periodicity, stationarity, and scale. Choosing or designing the right kernel is the primary modelling decision in Gaussian process regression — it determines what kinds of functions the GP believes are plausible before seeing data.
  • Gaussian process regression is the Bayesian counterpart to kernel ridge regression: both use the kernel trick to fit non-parametric models, but GP regression additionally provides calibrated uncertainty estimates, while kernel ridge regression provides only point predictions. The connection to Bayesian inference makes GP predictions equivalent to exact Bayesian posterior inference under Gaussian assumptions.
  • Bayesian optimisation — using a GP as a surrogate model to efficiently optimise expensive black-box functions — is one of the most practically important applications of GPs. It is the principled method for hyperparameter optimisation of ML models, and it typically finds good hyperparameters with 10–50× fewer function evaluations than random search or grid search.
  • The computational bottleneck of Gaussian processes is the O(n³) cost of inverting the n×n kernel matrix. This limits standard GPs to datasets of ~10,000 observations. Sparse GP approximations (inducing points, variational inference) and GPU-based implementations (GPyTorch) extend GPs to larger datasets, but for very large datasets, GPs are generally replaced by neural network approaches.
  • GP models are most valuable in settings where calibrated uncertainty matters more than raw predictive accuracy and where the dataset is too small for deep learning: scientific experiments, pharmaceutical R&D, materials discovery, autonomous systems, and any setting involving safety-critical decisions under uncertainty.

Most machine learning models make a point prediction — a single number or class label — without any quantification of how confident the model is in that prediction. Gaussian processes take a fundamentally different approach: instead of learning a single function, they maintain a probability distribution over all functions consistent with the observed data, providing not just a prediction but a calibrated uncertainty estimate at every point. This ability to say “I predict Y = 3.2, and I am 95% confident the true value is between 2.1 and 4.3” — and to have those confidence bounds be correctly calibrated — makes Gaussian processes uniquely valuable in settings where knowing how much to trust a prediction matters: scientific modelling, drug discovery, robotics, and Bayesian optimisation for hyperparameter tuning. This guide covers the mathematical foundations of Gaussian process regression, kernel design, hyperparameter learning, Bayesian optimisation, and the computational scalability challenges that limit standard GPs to moderate-sized datasets.

What Is a Gaussian Process?

A Gaussian process is a collection of random variables, any finite number of which have a joint Gaussian distribution. Equivalently, a GP is a probability distribution over functions f: X → R such that, for any finite set of input points {x₁, …, xₙ}, the vector of function values [f(x₁), …, f(xₙ)] follows a multivariate Gaussian distribution. A GP is fully specified by two functions: the mean function m(x) = E[f(x)] (often set to zero) and the covariance function (kernel) k(x, x’) = Cov[f(x), f(x’)], which encodes how correlated the function values at two input points x and x’ are.

The kernel is the heart of GP modelling. The squared exponential (RBF) kernel k(x, x’) = σ² exp(−||x − x’||²/(2l²)) encodes the assumption that nearby inputs produce similar outputs, with smoothness controlled by the lengthscale l and output variance σ². The Matérn kernel family offers kernels with different degrees of smoothness (Matérn 1/2 is continuous but not differentiable; Matérn 5/2 is twice differentiable). Periodic kernels encode periodic structure. Linear kernels k(x, x’) = xᵀx’ reduce GP regression to Bayesian linear regression. Kernels can be combined — summed (k₁ + k₂) or multiplied (k₁ × k₂) — to encode complex composite structure: a trend plus periodic seasonality is naturally modelled by a linear kernel plus a periodic kernel. The connection to the kernel trick in SVMs and the mathematical framework of reproducing kernel Hilbert spaces is covered in our linear algebra guide. The distributional properties of Gaussian processes connect directly to the multivariate Gaussian distribution covered in our probability distributions guide.

KernelFormula (simplified)Function PropertiesBest For
Squared Exponential (RBF)exp(−r²/2l²)Infinitely smooth (C∞)Smooth physical processes, spatial data
Matérn 5/2(1+√5r/l+5r²/3l²)exp(−√5r/l)Twice differentiable (C²)General regression; less smooth than RBF
Matérn 3/2(1+√3r/l)exp(−√3r/l)Once differentiable (C¹)Rough physical processes
Exponentialexp(−r/l)Continuous, not differentiableOrnstein-Uhlenbeck processes
Rational Quadratic(1+r²/2αl²)^−αSmooth; multi-scaleData with multiple lengthscales
Periodicexp(−2sin²(πr/p)/l²)Periodic with period pSeasonal data, cyclic phenomena

GP Regression — Prediction and Uncertainty

A hand-drawn line graph on paper with a metal ruler and two pens
Photo by Isaac Smith on Unsplash

Given training data D = {(x₁, y₁), …, (xₙ, yₙ)} where yᵢ = f(xᵢ) + εᵢ and εᵢ ~ N(0, σ²_n) is observation noise, GP regression computes the posterior distribution over function values at any new test point x* using Bayes’ theorem. The posterior is also Gaussian: the posterior mean μ(x*) = k(x*, X)[K(X,X) + σ²_n I]⁻¹ y and posterior variance σ²(x*) = k(x*, x*) − k(x*, X)[K(X,X) + σ²_n I]⁻¹ k(X, x*). Here K(X,X) is the n×n kernel matrix of all pairwise kernel evaluations between training points.

The posterior mean is the GP prediction — a weighted combination of training outputs where the weights are determined by the kernel similarity between the test point and each training point. The posterior variance quantifies uncertainty: it is zero at observed training points (the model is certain of interpolated values), and increases as the test point moves further from any training point (the model becomes more uncertain in extrapolation). This automatic calibration of uncertainty — observations reduce uncertainty, absence of data increases it — is what distinguishes GP regression from all standard ML regression models. Our Bayesian statistics guide covers the prior-likelihood-posterior update that GP regression implements in the function space rather than the parameter space. The matrix inversion [K(X,X) + σ²_n I]⁻¹ and its connection to Cholesky decomposition for numerical stability is covered in our linear algebra guide.

Kernel hyperparameters (lengthscale l, output variance σ², noise variance σ²_n) are learned by maximising the marginal likelihood p(y|X, θ) = ∫ p(y|f, X) p(f|X, θ) df, which integrates out the function values. The marginal likelihood has a closed form for Gaussian likelihoods (the standard regression case) and balances model fit (likelihood of the data) against model complexity (a regularisation term that penalises kernels that are overly flexible). Maximising the log marginal likelihood with gradient descent — using automatic differentiation as implemented in GPyTorch — is the standard approach for kernel hyperparameter optimisation.

Bayesian Optimisation — The Killer Application of Gaussian Processes

Bayesian optimisation (BO) is the principled framework for optimising expensive, black-box, noisy functions with as few function evaluations as possible. The canonical application in data science is hyperparameter optimisation: finding the optimal learning rate, number of layers, dropout rate, and other hyperparameters of a neural network or gradient boosting model, where each function evaluation requires training a full model (expensive — minutes to hours). AutoML tools like Optuna (which implements TPE, a tree-structured variant of Bayesian optimisation), HyperOpt, and BoTorch all use BO-based methods as their core search algorithm.

Bayesian optimisation maintains a GP surrogate model over the objective function (e.g., validation accuracy as a function of hyperparameters). At each step, it selects the next hyperparameter configuration to evaluate by maximising an acquisition function that trades off exploration (querying uncertain regions) and exploitation (querying regions near known good configurations). The three standard acquisition functions are: Expected Improvement (EI) — the expected amount by which the next query will exceed the current best observation; Upper Confidence Bound (UCB) — the GP mean plus a multiple of the GP standard deviation (explicit exploration-exploitation trade-off parameter); and Probability of Improvement (PI) — the probability that the next query exceeds the current best. EI is the most commonly used and most theoretically well-studied. The exploration-exploitation trade-off here is mathematically identical to the multi-armed bandit problem covered in the experiment design guide.

In practice, BO finds hyperparameter configurations that rival manual expert tuning in 10–50 function evaluations, versus the hundreds typically required by grid or random search. For gradient boosting models, BO-based tuning typically improves validation AUC by 1–3 percentage points over the default hyperparameters, which can correspond to millions of dollars in business impact for high-stakes applications like credit scoring or fraud detection. The model evaluation guide covers the correct methodology for hyperparameter tuning with nested cross-validation to avoid optimistic bias in the performance estimate.

✦ SUMMARIZE THIS ARTICLE WITH AI

The Bayesian foundations of GP regression — prior, likelihood, and posterior — are in our Bayesian Statistics guide. The linear algebra of kernel matrix operations — Cholesky decomposition, matrix inversion, and eigendecomposition — is in our Linear Algebra guide. Bayesian optimisation for hyperparameter tuning is covered in our AutoML and Hyperparameter Optimisation guide. Gradient boosting hyperparameter optimisation — the most common BO application in industry — is in our Gradient Boosting guide. The probability distributions — multivariate Gaussian, Wishart — that GPs are built on are in our Probability Distributions guide.

Leave feedback about this

  • Rating

Durgesh Kekare
Durgesh Kekarehttps://www.dataexpertise.in
Durgesh Kekare is a data science educator and founder of DataExpertise.in. With expertise in Python, machine learning, and analytics, he helps 10,000+ learners break into data careers.

Latest Posts

List of Categories