Started with some Probability and Statistics; doing Gaussians now. This post is to go deep into Gaussian Processes.
Why do I write this?
I wanted to create an authoritative document I could refer to for later. Thought that I might as well make it public (build in public, serve society and that sort of stuff).
Why does this exist?
A parametric model, such as polynomial regression (), makes a strong, fixed assumption about the functional form of the relationship being modeled.
The learning process is confined to finding the optimal parameters within this pre-defined structure.
The fundamental question that motivates Gaussian Processes is – Can we perform inference about an unknown function without first committing to a rigid parametric form?
From Multivariate Gaussians to Gaussian Processes
A univariate Gaussian is a distribution over a scalar random variable.
A multivariate Gaussian is a distribution over a vector of random variables, . It is completely specified by a mean vector and a covariance matrix . The covariance matrix describes the relationships between all pairs of variables in the vector.
A Gaussian Process is the logical extension of this concept to an infinite-dimensional setting. It is a distribution over a function .
Defining a GP
A Gaussian Process is a collection of random variables, any finite number of which have a joint Gaussian distribution.
A GP defines a probability distribution over a function. For any finite set of input points , the corresponding vector of function values is a random vector that follows a multivariate Gaussian distribution.
A Gaussian Process is completely specified by two functions:
The Mean Function, : This function defines the expected value of the function at any input point .
It represents our prior belief about the average shape of the function. For notational simplicity, the mean function is often assumed to be the zero function, .
The Covariance Function (or Kernel), : This function defines the covariance between the function values at any two input points, and .
The kernel encodes our prior beliefs about the properties of the function, such as its smoothness, periodicity, or stationarity. The choice of kernel is the most critical modeling decision when using a GP. Why?A valid kernel function must ensure that the covariance matrix it generates for any set of points is always positive semi-definite.
We denote a Gaussian Process prior over a function as:
Huh?
You sample a function from a GP, duh.
Bayesian Inference with GPs
This is why I even started this. The primary use of Gaussian Processes is for Bayesian regression.
Gaussian Process Regression Model
The full generative model assumes that our observed targets are evaluations of the latent function corrupted by independent, identically distributed Gaussian noise:
Prior over the latent function:
Likelihood of observations:, where . This is equivalent to the likelihood .
Such cool notation, right?
Posterior Predictive Distribution
Let us consider a training dataset , where are the training inputs and are the noisy training targets.
As with any regression,
We want to predict the function value at a new test point .
Here’s how we do it –
The core of GP inference lies in the foundational definition: any finite collection of function values is jointly Gaussian.
Therefore, the training outputs and the test output are jointly Gaussian –
where:
is the vector of prior means at the training points.
is the covariance matrix where . The term is added to account for the independent observation noise.
is the vector of covariances between the training points and the test point.
is the prior variance at the test point.
Notice how we now have a joint Gaussian distribution of the form .
The goal is to find the posterior predictive distribution.
Here, I just state the analytical solution –
Interpretation:
The posterior mean is a linear combination of the observed training targets (adjusted by their prior means).
The posterior variance represents our uncertainty about the function value at the test point. It is the prior variance at that point, reduced by an amount that reflects the information gained from the training data. The variance is lowest near the training points and grows as we move away from them, correctly capturing that our uncertainty increases in regions where we have no data.
How tos
The Kernel Function and Model Properties
The choice of kernel is the primary mechanism for incorporating prior knowledge into the model. A widely used kernel is the Squared Exponential (or Radial Basis Function) kernel:
This kernel is governed by two hyperparameters:
Length-scale (): Controls how quickly the correlation between function values decays with distance. A small produces rapidly varying (“wiggly”) functions, while a large produces smooth functions.
Signal Variance (): Controls the overall vertical variation of the function from its mean.
Learning the Hyperparameters
The kernel parameters and the noise variance are typically not set by hand. They are learned from the data by maximizing the marginal log-likelihood:
where denotes the set of all hyperparameters. This objective function has a natural interpretation as an implementation of Occam’s razor.
The first term is a data-fit term, while the second term, , is a complexity penalty term that penalizes overly complex models.
Leave a comment