A distribution over functions
Most regression methods pick one function. A Gaussian process keeps all of them, weighted by how plausible they are: before any data it is a prior over functions, and each observation reweights it into a posterior. Every prediction then comes with an honest error bar, wide where there is no data and narrow where there is.
The page fits monthly averages of the Mauna Loa CO₂ record, the measurements started by Charles Keeling in 1958, as OpenML publishes them: the 72 months of 1995–2000 (in ppm, minus their mean) to learn from, and the 12 months of 2001 held out.
The kernel decides what functions look like
A Gaussian process is fixed by its mean (here zero) and its kernel , the covariance between the function's values at two times. The page's main kernel is the squared exponential, or RBF, plus noise:
is how far the function strays from its mean, the length scale how far apart two months can be and still move together, and the noise on each monthly average. The kernel chart draws the covariance against the gap between two months. Draw from the prior (points arrive, 0 points) and you get wiggly curves whose wiggles are about wide.
Conditioning on data
Given observations at times , the function's values at new times are again Gaussian, with
where is the kernel between observed times, between observed and new, between new ones. It is computed with one Cholesky factor of . In points arrive the months come in one at a time in a fixed random order. Near each seen month the band pinches to about the noise, between months farther apart than it opens again, and the average standard deviation over the six years falls from 3.43 ppm (the prior's ) to 0.169 ppm with all 72 months. The five samples are with the same random numbers in every frame, so a sample bends only because data arrived, and every sample passes near every seen month.
Choosing the kernel by marginal likelihood
The hyperparameters are chosen by maximizing the probability of the data with the function integrated out, the log marginal likelihood:
The first term rewards fitting the data; the second penalizes a kernel flexible enough to fit anything, an automatic Occam's razor. The Log marginal likelihood map shows it over and , with at its best for each cell, and the paths of twelve L-BFGS runs from random starts. They end in three different optima. A ( = 0.211 years, = 0.239 ppm, log marginal likelihood −85.4, 5 starts) follows the seasonal cycle. B ( = 2.63 years, = 2.16 ppm, −163.1, 3 starts) draws a smooth trend and calls the seasons noise. C ( at its lower bound, = 3.58 ppm, −194.2, 4 starts) calls everything noise. Each is a reasonable story, and which one an optimizer tells depends on where it started, so fitting a GP well usually means several restarts.
The length scale and noise buttons move one hyperparameter away from A with the others fixed: a short chases every month and opens up between them, a long one cuts through the seasons; little noise forces the mean through every point, a lot lets it pass them by.
Kernels that know about seasons
Kernels can be added and multiplied. Trend + seasonal is a long RBF for the trend plus an RBF times a periodic kernel for a cycle that may slowly change, plus noise, a simplified version of the kernel in scikit-learn's own Mauna Loa example. Fitted by the same marginal likelihood, it finds a period of 0.998 years by itself and a log marginal likelihood of −30.7, far above any RBF optimum. It also forecasts better: on the held-out months of 2001 its error is 1.24 ppm, against 4.95 ppm for optimum A, whose forecast falls back to the mean a few months past the data.
Gaussian processes go back to kriging in geostatistics; Williams and Rasmussen brought them into machine learning, and Rasmussen and Williams' book is the standard reference. Neal showed that a one-hidden-layer network with infinitely many random units is a Gaussian process, a link that μP in the Pretraining explainer builds on; an SVM uses the same kernels to draw one boundary instead of a distribution.
Papers
- Gaussian Processes for Machine Learning The standard reference: the posterior by Cholesky, the marginal likelihood and its gradient, and the Mauna Loa kernel.
- Gaussian Processes for Regression Gaussian process regression for machine learning, with hyperparameters fitted by marginal likelihood.
- Bayesian Learning for Neural Networks A network with one infinitely wide hidden layer of random weights is a Gaussian process.
- Structure Discovery in Nonparametric Regression through Compositional Kernel Search Sums and products of kernels as a language for structure, searched by marginal likelihood, with Mauna Loa CO₂ as an example.
- Deep Neural Networks as Gaussian Processes Neal's result extended to deep networks: infinitely wide layers give a Gaussian process with a computable kernel.