conjugate_loocv#

gpjax.objectives.conjugate_loocv(model, data)[source]#

Evaluate the leave-one-out log predictive probability of the Gaussian process following section 5.4.2 of Rasmussen et al. 2006 - Gaussian Processes for Machine Learning. This metric calculates the average performance of all models that can be obtained by training on all but one data point, and then predicting the left out data point.

For multi-output likelihoods this performs leave-one-scalar-out on the flattened NP system (per-element predictive), the natural generalisation of the scalar R&W LOOCV to multiple outputs. Per-datapoint LOOCV has no closed form in the multi-output case.

The returned metric can then be used for gradient based optimisation of the model’s parameters or for model comparison. The implementation given here enables exact estimation of the Gaussian process’ latent function values.

For a given ConjugateModel, the following code snippet shows how the leave-one-out log predictive probability can be evaluated.

Example

>>> import gpjax as gpx
...
>>> xtrain = jnp.linspace(0, 1).reshape(-1, 1)
>>> ytrain = jnp.sin(xtrain)
>>> D = gpx.Dataset(X=xtrain, y=ytrain)
...
>>> meanf = gpx.mean_functions.Constant()
>>> kernel = gpx.kernels.RBF()
>>> likelihood = gpx.likelihoods.Gaussian()
>>> prior = gpx.gps.Prior(mean_function = meanf, kernel=kernel)
>>> model = prior * likelihood
...
>>> gpx.objectives.conjugate_loocv(model, D)

Our goal is to maximise the leave-one-out log predictive probability. Therefore, when optimising the model’s parameters with respect to the parameters, we use the negative leave-one-out log predictive probability. This can be realised through

>>> nloocv = lambda p, d: -gpx.objectives.conjugate_loocv(p, d)
Parameters:
  • model (ConjugateModel) – The joint model for which we want to compute the leave-one-out predictive probability.

  • data (Dataset) – The training dataset used to compute the leave-one-out predictive probability.

Returns:

The leave-one-out log predictive probability.

Return type:

ScalarFloat

Expand for references to gpjax.objectives.conjugate_loocv

conjugate_loocv