A distribution over functions defined by a mean and covariance kernel. Predicts a mean and kernel-conditional uncertainty. Beautiful theory, brutal scaling.
ConceptCore MLFoundations
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
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?
Sources and provenance
Full explanation 14 min read
Summary
A Gaussian process (GP) places a prior over functions f:X→R such that any finite collection of values {f(x1),…,f(xn)} is jointly Gaussian. The GP is fully specified by a mean function m(x) (usually 0) and a covariance kernel k(x,x′).
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: O(n3) 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 X, training targets y, test point x∗, prior covariance kernel k, and noise variance σ2:
The joint distribution is
[yf(x∗)]∼N(0,[K+σ2Ik∗⊤k∗k∗∗]),
where Kij=k(xi,xj), k∗ is the vector of k(x∗,xi), and k∗∗=k(x∗,x∗).
Conditioning on training data gives the Gaussian posterior:
Separate three-observation example: conditioning remains kernel-dependent
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
Derivation
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 (K+σ2I)−1 give you both the predictive mean and the predictive variance at any test point. The hard part is (K+σ2I)−1, which costs O(n3) to compute and O(n2) to store.
Choosing the kernel
The kernel encodes prior beliefs about the function:
Deep kernels. Replace k(x,x′) with k(ϕ(x),ϕ(x′)) 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 σ2. Without it, K 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.