#import necessary modules, set up the plotting
import numpy as np
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
import matplotlib;matplotlib.rcParams['figure.figsize'] = (8,6)
from matplotlib import pyplot as plt
import GPy
The GPy model class has a set of features which are designed to make it simple to explore the parameter space of the model. By default, the scipy optimisers are used to fit GPy models (via model.optimize()), for which we provide mechanisms for ‘free’ optimisation: GPy can ensure that naturally positive parameters (such as variances) remain positive. But these mechanisms are much more powerful than simple reparameterisation, as we shall see.
Along this tutorial we’ll use a sparse GP regression model as example. This example can be in GPy.examples.regression. All of the examples included in GPy return an instance of a model class, and therefore they can be called in the following way:
m = GPy.examples.regression.sparse_GP_regression_1D(plot=False, optimize=False)
To see the current state of the model parameters, and the model’s (marginal) likelihood just print the model
print m
The first thing displayed on the screen is the log-likelihood value of the model with its current parameters. Below the log-likelihood, a table with all the model’s parameters is shown. For each parameter, the table contains the name of the parameter, the current value, and in case there are defined: constraints, ties and prior distrbutions associated.
m
Model: sparse gp
Objective: 422.820894957
Number of Parameters: 8
Number of Optimization Parameters: 8
Updates: True
sparse_gp. | value | constraints | priors |
---|---|---|---|
inducing inputs | (5, 1) | ||
rbf.variance | 1.0 | +ve | |
rbf.lengthscale | 1.0 | +ve | |
Gaussian_noise.variance | 1.0 | +ve |
In this case the kernel parameters (bf.variance
, bf.lengthscale
) as well as the likelihood noise parameter (Gaussian_noise.variance
), are constrained to be positive, while the inducing inputs have no constraints associated. Also there are no ties or prior defined.
You can also print all subparts of the model, by printing the subcomponents individually; this will print the details of this particular parameter handle:
m.rbf
rbf. | value | constraints | priors |
---|---|---|---|
variance | 1.0 | +ve | |
lengthscale | 1.0 | +ve |
When you want to get a closer look into multivalue parameters, print them directly:
m.inducing_inputs
index | sparse_gp.inducing_inputs | constraints | priors |
---|---|---|---|
[0 0] | 0.17450990 | ||
[1 0] | 2.19478599 | ||
[2 0] | 1.09452540 | ||
[3 0] | -0.42446266 | ||
[4 0] | 0.45784368 |