Skip to content
mlmentorship

Gaussian processes

A distribution over functions defined by a mean and covariance kernel. Predicts a mean and kernel-conditional uncertainty. Beautiful theory, brutal scaling.

Published · 14 min read ·Role-specific ·Intermediate

Visual quick review

Explain how kernel similarity to observed inputs simultaneously shapes a Gaussian process posterior mean and reduces posterior function uncertainty at a query location.

Learning objective

Kernel covariance controls the mean response and uncertainty reduction; observation noise prevents an exact pin

Kernel covariance controls the mean response and uncertainty reduction; observation noise prevents an exact pinA GP conditions a joint Gaussian using its kernel and observation noise. This unit-RBF example bends the mean toward one observation and reduces latent uncertainty where kernel similarity is high. Noiseless evidence pins that input; noisy evidence leaves uncertainty. Future observations also add their own noise. Changing the observed value changes the mean, not fixed-kernel covariance. These bands are model-conditional, not automatic calibration. Kernel choice and exact-inference scaling matter.Condition the mean andlatent-function uncertainty togetherToy: zero prior mean, unit RBFkernel, lengthscale one. Observevalue one at input zero.Prior: flat mean, unit latentstandard deviation-303Shared scales. Blue mean; one latentstandard deviation band.Noiseless observation: mean reachesone; band pinches shut-303Shared scales. Blue mean; one latentstandard deviation band.Noise variance one: partial meanresponse; band stays open-303Shared scales. Blue mean; one latentstandard deviation band.At observed input: noisy mean 0.5,latent variance 0.5.Future-observation variance addsnoise and becomes 1.5.Change observed value from one to twowith the same kernel and noise: meandoubles; covariance is unchanged.Similarity, not distance alone,controls information transfer.Another kernel can connect distantinputs.General exact inference solves thenoisy covariance system; do not forman explicit inverse. Dense traininghas cubic time and quadratic storage.A misspecified kernel can givemisleading bands. These areconditional model uncertainties, notautomatic empirical calibration.
Read it this way: A GP conditions a joint Gaussian using its kernel and observation noise. This unit-RBF example bends the mean toward one observation and reduces latent uncertainty where kernel similarity is high. Noiseless evidence pins that input; noisy evidence leaves uncertainty. Future observations also add their own noise. Changing the observed value changes the mean, not fixed-kernel covariance. These bands are model-conditional, not automatic calibration. Kernel choice and exact-inference scaling matter. Does a noisy observation pin latent uncertainty to zero?
Full explanation 14 min read

Summary

A Gaussian process (GP) places a prior over functions such that any finite collection of values is jointly Gaussian. The GP is fully specified by a mean function (usually 0) and a covariance kernel .

GPs are the canonical Bayesian regression model. They give a closed-form posterior over functions, with a predictive mean and a predictive variance per query point. Under a suitable, well-specified kernel, that variance can be calibrated and returns toward the prior variance as kernel similarity to the observations falls. This makes GPs a standard tool for Bayesian optimization, active learning, and settings where uncertainty quantification matters as much as the prediction.

The cost is brutal scaling: exact inference. GPs are practical up to a few thousand training points without approximation; modern variants (sparse, structured kernel, deep kernel) push that to millions.

The mechanism

For training inputs , training targets , test point , prior covariance kernel , and noise variance :

The joint distribution is

where , is the vector of , and .

Conditioning on training data gives the Gaussian posterior:

Learning objective

Separate three-observation example: conditioning remains kernel-dependent

Gaussian process posterior mean and uncertainty around three observations A horizontal input axis contains three observed points. A solid posterior mean bends through their neighborhood. A shaded uncertainty band is narrow near each observation and broad at the left and right edges, where there is little kernel similarity to the training inputs. Labels connect the narrow regions to a large covariance correction subtracted from prior variance and the broad regions to a near-zero correction. OUTPUT f(x) INPUT x posterior mean μ(x) posterior uncertainty OBSERVED INPUTS near X large k* → large subtraction → narrow far from X k* ≈ 0 → prior width remains
start at a query location and ask how similar it is to the observed inputs. Nearby, the covariance vector k* is large: observations pull the mean and the subtracted correction in Σ(x*) removes much of the prior uncertainty. Far away, k* approaches zero, so the mean relaxes toward the prior and the uncertainty band widens toward the prior variance. This behavior is conditional on the chosen kernel; it is not a universal guarantee of calibration. Original schematic checked against Rasmussen and Williams (2006).
Check: Which covariance term makes the posterior band narrower at the marked query? What uncertainty does that band represent?
Reference drawing

Learning objective

Kernel covariance controls the mean response and uncertainty reduction; observation noise prevents an exact pin

Kernel covariance controls the mean response and uncertainty reduction; observation noise prevents an exact pinA GP conditions a joint Gaussian using its kernel and observation noise. This unit-RBF example bends the mean toward one observation and reduces latent uncertainty where kernel similarity is high. Noiseless evidence pins that input; noisy evidence leaves uncertainty. Future observations also add their own noise. Changing the observed value changes the mean, not fixed-kernel covariance. These bands are model-conditional, not automatic calibration. Kernel choice and exact-inference scaling matter.Condition the mean andlatent-function uncertainty togetherToy: zero prior mean, unit RBFkernel, lengthscale one. Observevalue one at input zero.Prior: flat mean, unit latentstandard deviation-303Shared scales. Blue mean; one latentstandard deviation band.Noiseless observation: mean reachesone; band pinches shut-303Shared scales. Blue mean; one latentstandard deviation band.Noise variance one: partial meanresponse; band stays open-303Shared scales. Blue mean; one latentstandard deviation band.At observed input: noisy mean 0.5,latent variance 0.5.Future-observation variance addsnoise and becomes 1.5.Change observed value from one to twowith the same kernel and noise: meandoubles; covariance is unchanged.Similarity, not distance alone,controls information transfer.Another kernel can connect distantinputs.General exact inference solves thenoisy covariance system; do not forman explicit inverse. Dense traininghas cubic time and quadratic storage.A misspecified kernel can givemisleading bands. These areconditional model uncertainties, notautomatic empirical calibration.
Derivation
Gaussian process posterior mean and uncertainty around three observations A horizontal input axis contains three observed points. A solid posterior mean bends through their neighborhood. A shaded uncertainty band is narrow near each observation and broad at the left and right edges, where there is little kernel similarity to the training inputs. Labels connect the narrow regions to a large covariance correction subtracted from prior variance and the broad regions to a near-zero correction. OUTPUT f(x) INPUT x posterior mean μ(x) posterior uncertainty OBSERVED INPUTS near X large k* → large subtraction → narrow far from X k* ≈ 0 → prior width remains
start at a query location and ask how similar it is to the observed inputs. Nearby, the covariance vector k* is large: observations pull the mean and the subtracted correction in Σ(x*) removes much of the prior uncertainty. Far away, k* approaches zero, so the mean relaxes toward the prior and the uncertainty band widens toward the prior variance. This behavior is conditional on the chosen kernel; it is not a universal guarantee of calibration. Original schematic checked against Rasmussen and Williams (2006).
Check: Which covariance term makes the posterior band narrower at the marked query? What uncertainty does that band represent?
Read it this way: A GP conditions a joint Gaussian using its kernel and observation noise. This unit-RBF example bends the mean toward one observation and reduces latent uncertainty where kernel similarity is high. Noiseless evidence pins that input; noisy evidence leaves uncertainty. Future observations also add their own noise. Changing the observed value changes the mean, not fixed-kernel covariance. These bands are model-conditional, not automatic calibration. Kernel choice and exact-inference scaling matter. Does a noisy observation pin latent uncertainty to zero?

Two matrix-vector products against give you both the predictive mean and the predictive variance at any test point. The hard part is , which costs to compute and to store.

Choosing the kernel

The kernel encodes prior beliefs about the function:

  • RBF / squared exponential: . Smooth functions, infinite differentiability. Default.
  • Matern: lets you tune smoothness via a half-integer parameter . is a common modern default; smoother than , less restrictive than RBF.
  • Periodic: . For periodic data.
  • Linear: . Recovers Bayesian linear regression.
  • Sums and products of valid kernels are valid kernels. Add a periodic and an RBF for “trend plus seasonality.”

Hyperparameters (lengthscale , variance , noise ) are typically learned by maximizing the marginal likelihood:

Scaling: sparse and approximate variants

  • Inducing points (Snelson & Ghahramani, 2005). Pick inducing inputs, approximate via a low-rank decomposition. training, prediction.
  • SVGP (Hensman et al., 2013). Variational inference over inducing point values. Stochastic mini-batch training. The standard for large-data GPs.
  • KISS-GP / structured kernels (Wilson & Nickisch, 2015). Exploit grid structure for inference.
  • Deep kernels. Replace with where is a neural network. Combines deep features with kernel-conditional uncertainty.

Where GPs are still the right tool

  • Bayesian optimization of expensive functions (hyperparameter search, materials discovery, drug design). The acquisition function uses the posterior variance to balance exploration and exploitation.
  • Geospatial / time-series modeling with structured covariance (kriging is just a GP).
  • Small-data regression where calibrated uncertainty matters more than predictive accuracy.
  • Probabilistic numerics (treat numerical algorithms as Bayesian inference).

For most large-scale supervised learning, deep nets with bootstrapping or deep ensembles deliver competitive uncertainty estimates at much better scaling.

Common pitfalls

  • Using RBF without setting the lengthscale. Default lengthscale produces nearly-flat predictions or wildly oscillating ones. Always optimize.
  • Ignoring the noise term . Without it, is often singular and inversion fails. Add a small jitter even for noiseless data.
  • Reading posterior variance as “model uncertainty.” GP variance is uncertainty in the function value given the kernel and the prior. Misspecified kernels give miscalibrated variance.
  • Treating GPs as automatic. Kernel choice is a strong prior. The model can fail silently if the kernel does not match the data structure.