A Gaussian process is defined by its mean and covariance functions
and
respectivily
![\begin{array}{c}
m(\mathbf{x}) = \mathbb{E} \left [ f(\mathbf{x}) \right ], \\
k(\mathbf{x},\mathbf{x}') = \mathbb{E} \left [
\left ( f(\mathbf{x})-m(\mathbf{x})\right )
\left ( f(\mathbf{x}')-m(\mathbf{x}')\right )
\right ]
\end{array}](_images/math/ee4c074dfbe9121f51938360f5d9813b189135cf.png)
and Gaussian Process (GP) can be written as

The free parameters in the covariance functions are called hyperparameters.
When doing regression we are interested in finding the model outputs for a given set of inputs, and the confidence of the predictions. We have training dataset
![\left [
\begin{array}{c}
\mathbf{f} \\ \mathbf{f_{*}}
\end{array}
\right ]
\sim
\mathcal{N}
\left (
0,
\left [
\begin{array}{cc}
K(X,X) & K(X,X_{*}) \\
K(X_{*},X) & K(X_{*},X_{*}) \\
\end{array}
\right ]
\right )
\sim
\mathcal{N}
\left (
0,
\left [
\begin{array}{cc}
K & K_{*}^T \\
K_{*} & K_{{*}{*}} \\
\end{array}
\right ]
\right )](_images/math/9b430c93eeed031d7bbbbcf8bdf99103132ba303.png)
For simplicity we have set
,
, and
.


Gaussian Process for regression.
Methods
| df | |
| f | |
| find_hyperparameters | |
| predict |
The partial derivatives of the function to minimize, which is the likihood in this case. This method is passed to the optimizer.
| Parameters : | params : 1D np array, optional
|
|---|---|
| Returns : | der : np array
|
The function to minimize, which is the likihood in this case. This method is passed to the optimizer.
| Parameters : | params : 1D np array, optional
|
|---|---|
| Returns : | nllikelihood : float
|
Find hyperparameters for the GP.
Predict the the output of the GPR for the inputs given in XX
| Parameters : | XX : NxD np array
|
|---|---|
| Returns : | res : np array
|
Gaussian Process class.
Methods
| find_likelihood_der | |
| fit_data | |
| generate | |
| regression |
Find the negative log likelihood and its partial derivatives.
Fit the hyper-parameters to the data.
X Input samples (2d array, samples row-wise) y Function output (1d array)
Generate samples from the GP.
| Parameters : | x : np array
rn : np array
|
|---|
Predict the y values for XX given the X, y, and the objects covariance function.
| Parameters : | X : MxD np array
y : 1-dimensional np array of length M
XX : NxD np array
max_samples : int, optional
|
|---|---|
| Returns : | ys : np array of length N
s2 : np array of length N
|