runlmc.models.multigp module

This module houses the base model that the package centers around: runlmc.model.MultiGP, the parent class for all multi-output GP models in this package.

class runlmc.models.multigp.MultiGP(Xs, Ys, normalize=True, name='multigp')[source]

Bases: runlmc.parameterization.model.Model

The generic GP model for multi-output regression. This handles common functionality between all models regarding input validation and high level parameter optimization routines.

This model assumes Gaussian noise.

This class shouldn’t be instantiated directly.

Upon construction, this class assumes ownership of its parameters and does not account for changes in their values.

Parameters:
  • Xs – input observations, should be a list of numpy arrays, where each numpy array is a design matrix for the inputs to output \(i\). If the \(i\)-th input has \(n_i\) data points, then this matrix can be \(n_i\) or \(n_i\times P\) shape for input dimension \(P\), with the former re-interpreted as \(P=1\).
  • Ys – output observations, this must be a list of one-dimensional numpy arrays, matching up with the number of rows in Xs.
  • normalize – optional normalization for outputs Ys. Prediction will be un-normalized.
  • name (str) –
Raises:

ValueError if Xs and Ys lengths do not match.

Raises:

ValueError if normalization if any Ys have no variance or values in Xs have multiple identical values.

log_likelihood()[source]

The log marginal likelihood of the model, \(p(\mathbf{y})\), this is the objective function of the model being optimised

optimize(**kwargs)[source]

Optimize the model using log_likelihood() with a gradient descent method that involves the priors.

kwargs are passed to the optimizer. See parameters for handled keywords.

Parameters:optimizer – A paramz.optimization.Optimizer. Pre-built ones available in runlmc.models.optimization.
parameters_changed()[source]

This method is called automatically when linked parameters change, which the may during the optimization process.

Classes should update their posterior information, log likelihood, and gradients when this happens, such that _raw_predict(), log_likelihood(), and gradient() are consistent with the new parameters.

predict(Xs)[source]

Predict the functions at the new points Xs.

Parameters:Xs – The points at which to make a prediction for each output. Should be empty if no output desired for a certain index. This is a list of numpy.ndarray for each output d, one-dimensional of size n_d each. Length of Xs should be equal to the number of outputs output_dim.
Returns:(mean, var):
mean: posterior mean, a list of length output_dim with
one-dimensional numpy arrays of length n_d at index d.

var: posterior variance, corresponding to each mean entry.

predict_quantiles(Xs, quantiles=(2.5, 97.5))[source]

Identical to predict, but returns quantiles instead of mean and variance according to the Gaussian likelihood.

Parameters:quantiles (tuple of doubles) – tuple of quantiles, default is (2.5, 97.5), which is the 95% interval; shouldn’t be 0 or 100
Returns:list of quantiles for each output’s input, as a numpy array, 2-D, the first axis corresponding to the input index and the second to the quantile index.