ML Systems Lab Open interactive version →
Advanced 65 min read GPgaussian processkernelBayesian optimisationinducing points

Gaussian Processes

Distribution over functions, kernel selection, GP regression, sparse GPs, Bayesian optimisation

You have 5 noisy measurements of a physical process at time points {1, 2, 5, 7, 10}. You want to predict the value at time 3. A standard regression model gives you a point prediction — but how confident should you be? The measurements are noisy, and time 3 sits between two observations. A model that says "value = 4.2" with no indication of uncertainty is only half useful.

A Gaussian Process solves this by treating the unknown function itself as a random variable. A GP defines a distribution over functions: any finite collection of points {f(x₁), ..., f(xₙ)} follows a jointly Gaussian distribution. The kernel function k(x, x') defines the covariance between any two points — points close in time covary strongly, points far apart covary weakly. You specify the prior over functions by choosing the kernel. The posterior at time 3 conditions the joint Gaussian on your 5 observations, yielding a Gaussian predictive distribution: a mean (best estimate) and a variance (uncertainty). Near the data, the variance collapses — the GP knows what it knows. Far from the data, the variance expands — the GP correctly reports ignorance.

The mechanism that produces this behavior is the posterior update: μ* = K(X*, X)[K(X, X) + σ²I]⁻¹ y, and Σ* = K(X*, X*) - K(X*, X)[K(X, X) + σ²I]⁻¹ K(X, X*). The variance term Σ* shrinks at observed points and expands away from them — this is what no other regression method gives you automatically. At time 20, far beyond your training data, the posterior variance will be large: the GP correctly says it doesn't know.

The cost of this principled uncertainty is computational: the matrix inversion [K(X, X) + σ²I]⁻¹ costs O(n³) and storing K costs O(n²). At n = 10,000, this hits a hard wall on standard hardware. Everything in the sparse GP literature exists to circumvent this wall.

NOT this. "GPs are too slow for real data." Exact GPs are O(n³) and impractical for n > 10,000. But inducing point approximations (sparse GPs) reduce this to O(nm²) where m << n. For hyperparameter tuning via Bayesian optimization — where n is the number of function evaluations, typically under 200 — exact GPs are standard, fast, and the default choice in tools like BoTorch. The O(n³) wall is real, but it is the wall for exact GPs at large n. Sparse GPs, SKI, and deep kernel learning each offer a different strategy for breaking through it.

Key points

Takeaway

The O(n³) wall is the central engineering fact about GPs, and SVGP with inducing points is the standard workaround — but the tradeoff is that the variational approximation underestimates predictive uncertainty between inducing points. Kernel choice encodes the prior over functions: RBF assumes infinite differentiability (wrong for most real processes), Matérn 5/2 assumes twice-differentiability (usually correct), and a periodic kernel is required for any recurring pattern — the GP is only as good as the prior you encode in its kernel.

Recap

Check your understanding

Q1. You have 50,000 training points and want to use a GP. Select the two valid approaches and what each trades away.

Q2. Your GP Bayesian optimisation run converges prematurely — the acquisition function keeps suggesting the same region. What went wrong and how do you fix it?

Q3. How does the GP marginal likelihood objective perform automatic model selection, and what is its failure mode?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →