8.6 Gaussian process regression with PyMC
The gray line in Figure 8.4 is a sin function. We are going to assume we don’t know this function and instead, all we have is a set of data points (dots). Then we use a Gaussian process to approximate the function that generated those data points.
Figure 8.4: Synthetic data (dots) generated from a known function (line)
GPs are implemented in PyMC as a series of Python classes that deviate a little bit from what we have seen in previous models; nevertheless, the code is still very PyMConic. I have added a few comments in the following code to guide you through the key steps of defining a GP with PyMC.
Code 8.3
# A one-dimensional column vector of inputs.
X = x[:, None]
with pm.Model() as model_reg:
# hyperprior for lengthscale kernel parameter
ℓ = pm.InverseGamma("ℓ", 7, 17)
# instanciate...