Skip to content
AI.info

Classical machine learning

Kernel Ridge and Gaussian Process Regression

Compare kernel ridge and Gaussian process regression, including covariance design, posterior uncertainty, support, and scaling approximations.

By the end you can

Comparison

One estimator, two moments: the kernel ridge fit is the GP posterior mean

These are not two loosely similar methods. Under linked assumptions the curve is the same object twice. Kanagawa and colleagues state the identity outright in their 2018 review of how Gaussian processes and kernel methods connect: “It is widely known in machine learning that these two formalisms are closely related; for instance, the estimator of kernel ridge regression is identical to the posterior mean of Gaussian process regression.”

So the difference is not the fit. It is everything around the fit. scikit-learn's side-by-side example says what the probabilistic formulation adds: “However, the Gaussian process regressor also provide an uncertainty information that is not available with a kernel ridge.” Read the comparison below that way. Not two competing fits, but one fit plus a second moment, an explicit noise model, and hyperparameters that can be learned or selected.

FigureComparison · 3 columns

Kernel ridge regression

Fits a regularized least-squares function in a kernel space.

  • Deterministic point estimator
  • Uses a kernel matrix
  • Regularization controls function complexity
  • Usually involves all training examples

Gaussian process regression

Places a probability distribution over functions before observing data.

  • Posterior mean and variance
  • Kernel acts as a covariance function
  • Noise model affects uncertainty
  • Hyperparameters can be learned or selected

Shared limitation

Standard exact methods depend heavily on sample-pair computations.

  • Memory grows with the kernel matrix
  • Training can become expensive
  • Scaling and kernel choice remain critical
  • Approximations change the model

Kernel ridge solves a smooth global regression problem — and pays for it at serving time

Ridge regression penalizes coefficient magnitude in an explicit feature space. Kernel ridge does the same job through similarities to training examples, which buys nonlinear functions without ever constructing the features. Rasmussen and Williams gave the structural picture in 2006: “Another way to look at this equation is to see it as a linear combination of n kernel functions, each one centered on a training point”. Every training row keeps a seat at prediction time.

Unlike a sparse SVM solution, a standard kernel-ridge predictor commonly uses a contribution from every training row. That cost has a documented direction and a measured size. scikit-learn's user guide reports it in the comparison with support vector regression: “With regard to prediction time, SVR is faster than KernelRidge for all sizes of the training set because of the learned sparse solution.” In the library's own worked comparison, SVR keeps roughly a third of the 100 training points as support vectors. It predicts 100,000 targets more than three times faster. The dense solution is not a footnote about serving cost. It is a factor you can measure before you deploy.

Case

A ceiling written down in 2006, broken in 2019

The ten-thousand-point limit is not folklore. It was written down. Rasmussen and Williams open their 2006 chapter on approximation methods for large datasets by noting that GP prediction typically scales as O(n^3), then put the barrier in one sentence: “For large problems (e.g. n > 10, 000) both storing the Gram matrix and solving the associated linear systems are prohibitive on modern workstations”.

Thirteen years later the same barrier opens the abstract of a NeurIPS paper. Wang, Pleiss and colleagues write that “computational constraints with standard inference procedures have limited exact GPs to problems with fewer than about ten thousand training points”. Their fix left the model alone and changed the inference: “accessing the kernel matrix only through matrix multiplication”, then “partitioning and distributing kernel matrix multiplies” across multiple GPUs. The result was that “an exact GP can be trained on over a million points, a task previously thought to be impossible with current computing hardware, in less than 2 hours”. It also enabled “the first-ever comparison of exact GPs against scalable GP approximations on datasets with 10^4 - 10^6 data points”.

The prohibitive thing was never the model. It was the Gram matrix on a workstation, and hardware and linear algebra dissolved it.

Visual

A Gaussian process updates a prior over functions

The posterior conditions the prior on observed targets, through the kernel and the noise assumptions. The mean it returns is the kernel ridge estimate under the linked assumptions. The variance is the part only the probabilistic formulation supplies, and it is computed from the same chosen covariance and noise model.

FigureLayers · 5 layers
  1. 01

    Mean function

    The prior central tendency before observing data.

  2. 02

    Covariance kernel

    Specifies which input locations should have related function values.

  3. 03

    Observation noise

    Separates noisy measurements from latent function variation.

  4. 04

    Posterior mean

    The updated expected function after conditioning on data.

  5. 05

    Posterior variance

    Model-based uncertainty that grows or shrinks according to support and assumptions.

Posterior variance is conditional on the GP model being useful

A Gaussian process can express higher uncertainty away from observed inputs. That behaviour has been measured inside a national metrology institute's own instrument calibration. In 2022 Fowler and colleagues, at NIST, recast cryogenic microcalorimeter energy calibration as a GPR-justified approximating spline through x-ray lines of known energy. Across the 5.4-9 keV range populated by anchor points, the calibration uncertainty stays well below 0.5 eV. The shape of the uncertainty is exactly what the theory promises: “As expected, the uncertainty is smallest at the well-measured anchor points and grows with distance from the nearest one.”

The same paper shows what the variance is conditional on. Its Table 1 compares candidate calibration spaces. The median linear-interpolation error runs from 0.5 eV to 22.5 eV depending only on which space is assumed linear. That spread was produced by a modelling choice, not by the data. Variance is still computed under a chosen kernel, mean, noise model and fitted hyperparameters. Misspecification, unobserved regimes, selection bias and shift can each leave the reported interval confidently wrong.

Example

Where kernel regression earns its complexity

These methods are most attractive when data is moderate, smoothness structure is meaningful, and uncertainty or interpolation matters.

  • Materials science: kernel ridge with a Gaussian kernel, run on Coulomb-matrix representations of 7,165 small organic molecules from GDB-13, predicted DFT atomization energies to about 10 kcal/mol — “Cross-validation over more than seven thousand small organic molecules yields a mean absolute error of ~10 kcal/mol.” That was Rupp and colleagues, in 2012. Six years later the independent MoleculeNet benchmark still listed KRR on the Coulomb matrix at 10.22 MAE on the QM7 test subset — the best of the conventional, non-graph methods, beaten by the DTNN neural model at 8.75.
  • Environmental sensing: interpolate a smooth spatial process using a covariance structure that reflects location and measurement noise — and budget for the fact that the interval, not the point prediction, is where competing methods actually diverge.
  • Industrial calibration: learn a nonlinear correction curve from a manageable reference dataset, as in the NIST microcalorimeter work above, where the anchor points are x-ray lines of known energy and the uncertainty is reported alongside the curve.
  • Small clinical study: represent nonlinear biomarker response while reporting model-based uncertainty cautiously, remembering that the interval is a statement about the assumed covariance and noise, not about every source of ignorance.
  • Failure case: millions of rows make an exact kernel matrix impractical without approximation, distributed matrix multiplies, or data reduction — the n > 10,000 wall Rasmussen and Williams described in 2006 is where this begins to bite.

Steps

Use a kernel regressor with explicit assumptions

Kernel choice, noise and scaling are model design, not defaults. Two of the steps below have numbers attached to them from the evidence in this lesson. Inspecting support and residuals means measuring empirical coverage against the nominal 95% level — the axis on which the large-spatial-data competition separated methods that MAE and RMSE could not tell apart. Budgeting matrix cost means knowing where the wall is. Storage and linear solves for n > 10,000 were prohibitive on a 2006 workstation, and lifting that took accessing the kernel matrix only through matrix multiplication and distributing those multiplies across GPUs.

FigureProcess · 6 steps
  1. 1. Define smoothness expectations

    State whether nearby inputs should have related outputs and over what scale.

  2. 2. Scale and encode

    Fit transformations inside the training folds.

  3. 3. Compare simple kernels

    Start with linear and standard stationary choices before custom covariance.

  4. 4. Tune regularization or noise

    Use valid likelihood or held-out criteria without reusing the final test.

  5. 5. Inspect support and residuals

    Plot errors and uncertainty against distance, density, and slices.

  6. 6. Budget matrix cost

    Measure memory, factorization time, and prediction complexity.

Analogy

Stretching a flexible fabric across measured pegs

A flexible sheet is anchored at measured points. The kernel determines how a tug at one peg influences nearby locations. Regularization or noise controls how tightly the sheet must follow each measurement. The NIST calibration curve is this picture with the pegs made literal: the anchor points are x-ray lines of known energy, and the reported uncertainty is smallest at those lines and grows with distance from the nearest one.

High-dimensional inputs have no literal surface. And posterior uncertainty reflects the assumed covariance, not every possible source of ignorance.

The kernel defines how information travels from observed inputs to unobserved ones.

Key idea

Smooth interpolation can conceal a wrong kernel

A visually smooth posterior mean can look credible even when the kernel length scale connects cases that should not share information. A narrow interval can come from an overconfident noise model. So validate predictions and interval behavior on held-out regions that resemble the intended use. A blind competition has already shown what happens when nobody does.

Thirteen large-spatial-data methods were handed the same 105,569 training locations of MODIS daytime land-surface temperature from 4 August 2016 — 150,000 locations in total, 42,740 held out — and scored identically. Heaton and colleagues ran that comparison and published it in 2019. Point accuracy barely separated the entrants: MAE ran from 1.10 to 2.08, RMSE from 1.53 to 2.52.

The intervals were a different story. Empirical coverage of nominal 95% intervals ran from 0.36 (Gapfill) to 0.97 (SPDE) on the satellite data, and from 0.44 to 1.00 on the companion simulated dataset. The authors' own conclusion: “However, the methods differed in terms of their ability to accurately quantify the uncertainty associated with the predictions.” Two methods whose predictions you could not tell apart were offering intervals that meant entirely different things.

On the same 105,569 training locations, empirical coverage of nominal 95% intervals ran from 0.36 to 0.97 across methods of near-identical accuracy.

Scaling approximations change the evidence flow

Random Fourier features, Nyström methods, inducing points and local approximations all reduce cost the same way: they replace the full kernel calculation with a lower-rank or sparse structure. They trade exactness for speed. Both mean predictions and uncertainty can change, so audit the approximation error across dense, sparse and boundary regions.

The first of those substitutions was proposed at NIPS in 2007. Rahimi and Recht “propose to map the input data to a randomized low-dimensional feature space and then apply existing fast linear methods”, with the random features built “so that the inner products of the transformed data are approximately equal to those in the feature space of a user specified shift-invariant kernel”. scikit-learn ships it as RBFSampler, cites that paper, and states the trade-off in the open: “A higher n_components will result in a better approximation of the kernel”, and “For a given value of n_components RBFSampler is often less accurate as Nystroem”. The same page prices the alternative: “the computational complexity of the exact method is O(n_samples^3), the complexity of the approximation is O(n_components^2 · n_samples)”.

The approximation is a dial. The dial has a reading, and you can report it.

A scalable approximation is a new model whose failures must be measured.

Choose kernel methods for structure, not mystique

A linear, additive or tree model may perform comparably. It would then serve more cheaply and diagnose more clearly — and serving is not a rounding error here, since the dense kernel-ridge solution is slower to predict than a sparse one at every training-set size. Kernel regression earns its place when its similarity prior and uncertainty structure solve a measured problem.

The kernel ridge estimator is the GP posterior mean, so the real question is whether you need the second moment at all. If you do, the Heaton competition sets the standard to hold it to: report coverage, not just error. Model selection should compare the complete pipeline and the operational burden. That includes asking whether a modern alternative has since moved the number, as DTNN did on QM7 at 8.75 against kernel ridge's 10.22.

A covariance story is useful when the team can explain and test why observations should share information.

Key takeaways