The problem of machine learning (ML) is induction: We need to move from a finite training data
D
to a function
f
that makes predictions for all possible input values. A common method is to restrict the class of functions considered, for example only considering linear functions of the input. Another common method is to give a prior probability to all possible functions, where higher probabilities are given to functions that we consider to be more likely, for example because they are smoother than other functions. The Gaussian process (GP) belongs to the latter approach [1].
A Gaussian process is a generalization of the Gaussian probability distribution. Whereas a probability distribution describes random variables which are scalars or vectors, a stochastic process governs the properties of functions. A function can be loosely thought of as a very long vector, each entry in the vector specifying the function value
f(x)
at a particular input
x
. It turns out that if we only ask for the properties of the function at a finite number of points, then inference in the Gaussian process will give us the same answer as if we had considered all points [1].
Preliminaries
There are two equivalent ways to interpret Gaussian processes for models. One can think of a Gaussian process as defining a distribution over functions, and inference taking place in function space: the function space view. Alternatively, the weight space view considers distributions over the weights of models. Let us consider standard linear regression as an example [1].
Weight Space View
Say we have a training set
D
of
n
observations,
D={(xi,yi)∣i=1,…,n}
, where
x
denotes an input vector of dimension
D
and
y
denotes a scalar output or target. The column vector inputs for all
n
cases are aggregated in the
D×n
design matrix
X
, and the target are collected in the vector
y
, so we can write
D=(X,y)
. The standard linear regression model with Gaussian noise is written as follows where
x
is the input vector,
w
is a vector of weights (parameters) of the linear model,
f
is the function value, and
y
is the observed target value [1].
f(x)=x⊤w,y=f(x)+ϵ.
Often a bias weight or offset is included, but this can be implemented by augmenting the input vector
x
and weight vector
w
, and so is not explicitly included in this notation. We have assumed that the observed values
y
differ from the function values
f(x)
by additive noise, and further assumed that this noise follows and independent and identically distributed (IID) Gaussian distribution with zero mean and variance
σn2
[1].
ϵ∼N(0,σn2).
This gives rise to the likelihood, the probability density of the observations given the parameters, which is factored as follows by the independence assumption [1].
The normalizing constant known as the marginal likelihood or evidence is independent of the weights and given by the following [1].
p(y∣X)=∫p(y∣X,w)p(p)dw.
The posterior combines the likelihood and the prior capturing everything we know about the parameters, and writing only the terms from the likelihood and prior which depend on the weights we obtain the following where
wˉ=σn−2(σn−2XX⊤+Σp−1)−1Xy
[1].
The form of the posterior distribution is also Gaussian with mean
wˉ
and covariance matrix
A−1
where
A=σn−2XX⊤+Σp−1
[1].
p(w∣X,y)∼N(σn21A−1Xy,A−1).
To make predictions for a test case we average over all possible parameter values weighted by their posterior probability. This is in contrast to non-Bayesian schemes where a single parameter is typically chosen by some optimization criterion. Thus the predictive distribution for
f∗=f(x∗)
at
x∗
is given by averaging the output of all output linear models with respect to the Gaussian posterior. The predictive distribution is again Gaussian [1].
The Bayesian linear model suffers from limited expressiveness. A simple idea to overcome this problem is to first project the inputs into some high dimensional space using a set of basis functions and then apply the linear model in this space instead of directly on the inputs themselves. For example, a scalar input
x
could be projected into the space of powers of
x
:
ϕ(x)=(1,x,x2,x3,…)⊤
to implement polynomial regression. This idea is also used in classification where a dataset which is not linearly separable in the original data space may become linearly separable in a high dimensional feature space [1].
We assume a given basis function
ϕ(x)
which maps a
D
dimensional input vector
x
into an
N
dimensional feature space. Further let the matrix
Φ(X)
be the aggregation of columns
ϕ(x)
for all cases in the training set. Now the model is as follows where the vector of parameters now has length
N
[1].
f(x)=ϕ(x)⊤w.
The predictive distribution becomes the following with
Φ=Φ(X)
and
A=σn−2ΦΦ⊤+Σp−1
[1].
To make predictions using the equation we need to invert the
A
matrix of size
N×N
which may not be convenient if the dimension of the feature space
N
is large. In the equation we need to invert matrices of size
n×n
which is more convenient when
n<N
. The feature space in the equation only appears in the form of
Φ⊤ΣpΦ
,
ϕ∗⊤ΣpΦ
, or
ϕ∗⊤Σpϕ∗
. Thus the entries of these matrices are invariably of the form
ϕ(x)⊤Σpϕ(x′)
where
x
and
x′
are in either the training of the test sets [1].
Let us define
k(x,x′)=ϕ(x)⊤Σpϕ(x′)
. We call
k(x,x′)
a covariance function or kernel. Notice that
ϕ(x)⊤Σpϕ(x′)
is an inner product with respect to
Σp
. As
Σp
is positive definite we can define
Σp1/2
. Then defining
ψ(x)=Σp1/2ϕ(x)
we obtain a simple dot product representation
k(x,x′)=ψ(x)ψ(x′)
[1].
If an algorithm is defined solely in terms of inner products in input space then it can be lifted into feature space by replacing occurrences of those inner products by
k(x,x′)
. This is called the kernel trick. This technique is particularly valuable in situations where it is more convenient to compute the kernel than the feature vectors themselves. This often leads to considering the kernel as the object of primary interest, and its corresponding feature space as having secondary practical importance [1].
Function Space View
An alternative and equivalent way of reaching identical results to the weight space view is possible by considering inference directly in function space, and we can use a Gaussian process to describe a distribution over functions [1].
Definition. A Gaussian process is a collection of random variables, any finite number of which have a joint Gaussian distribution [1].
A Gaussian process is completely specified by its mean function and covariance function, which we define as
m(x)
and
k(x,x′)
respectively for a real process
f(x)
[1].
Thus
f(x)
and
f(x′)
are jointly Gaussian with zero mean and covariance given by
ϕ(x)⊤Σpϕ(x′)
. Our running example of a covariance function will be the squared exponential (SE) covariance function. For this particular covariance function, we see that the covariance is almost unity between variables whose corresponding inputs are close, and decreases as their distance in the input space increases [1].
The specification of the covariance function implies a distribution over functions. We can draw samples from the distribution of functions evaluated at any number of points. We choose a number of input points
X∗
and write the corresponding covariance matrix elementwise using the equation. Then we generate a random Gaussian vector with this covariance matrix and further can plot the generated values as a function of the inputs [1].
f∗∼N(0,K(X∗,X∗)).
Prediction with Noise Free Observations
We are not primarily interested in drawing random functions from the prior, but want to incorporate the knowledge that the training data provides about the function. Let us consider the simple special case where the observations are noise free. That is, we know
{(xi,fi)∣i=1,…,n}
. The joint distribution of the training outputs
f
and the test outputs
f∗
according to the prior are as follows [1].
If there are
n
training points and
n∗
test points then
K(X,X∗)
denotes the
n×n∗
matrix of covariances evaluated at all pairs of training and test points, and similarly for the other entries
K(X,X)
,
K(X∗,X∗)
, and
K(X∗,X)
. To get the posterior distribution over functions we need to restrict this joint prior distribution to contain only those functions which agree with the observed data points [1].
Graphically we may think of generating functions from the prior, and rejecting the ones that disagree with the observations, although this strategy is computationally inefficient. Though in probabilistic terms this operation is simple, corresponding to conditioning the joint Gaussian prior distribution on the observations. In the following, function values
f∗
corresponding to test inputs
X∗
can be sampled from the joint posterior distribution by evaluating the mean and covariance matrix [1].
Top comments (0)