GPy.kern.src.lfm package

This module adds functionality for Latent Force Models (LFM) to GPy. It is partially complete.

LFMs are a form of multiple output GP that make use of a kernel function inspired by a differential equation representing a phycial process (see M. Alvarez, D. Luengo and N. D. Lawrence, “Latent Force Models”, Proc. AISTATS 2009.).

LFMs combine kernels using convolution and will require functionality in GPy.kern.MultioutputKern to be combined into a useful model..

Multiple output GPs using co-regionalised regression are implemented elsewhere in GPy (GPy.models.GPCoregionalizedRegression).

cell(d0, d1)[source]

The purpose of this function is unknown.

lfmComputeH3(gamma1_p, gamma1_m, sigma2, X, X2, preFactor, mode=None, term=None)[source]

Helper function for computing part of the LFM kernel.

Computes a portion of the LFM kernel.

Parameters:
  • gamma1 – Gamma value for first system.
  • gamma2 – Gamma value for second system.
  • sigma2 – length scale of latent process.
  • X – first time input.
  • X2 – second time input.
  • mode – indicates in which way the vectors X and X2 must be transposed
  • term – the purpose of this parameter is unknown.
Return h:

result of this subcomponent of the kernel for the given values.

lfmComputeH4(gamma1_p, gamma1_m, sigma2, X, preFactor, preExp, mode=None, term=None)[source]

Helper function for computing part of the LFM kernel.

Computes a portion of the LFM kernel.

Parameters:
  • gamma1 – Gamma value for first system.
  • gamma2 – Gamma value for second system.
  • sigma2 – length scale of latent process.
  • X – first time input.
  • preFactor – precomputed constants.
  • preExp – precomputed exponentials.
  • mode – indicates in which way the vectors X and X2 must be transposed.
  • term – the purpose of this parameter is unknown.
Return h:

result of this subcomponent of the kernel for the given values.

lfmGradientH31(preFactor, preFactorGrad, gradThetaGamma, gradUpsilon1, gradUpsilon2, compUpsilon1, compUpsilon2, mode, term=None)[source]

Gradient of the function \(h_i(z)\) with respect to some of the hyperparameters of the kernel: \(m_k\), \(C_k\), \(D_k\), \(m_r\), \(C_r\) or \(D_r\).

Computes the gradient of the function \(h_i(z)\) with respect to some of the parameters of the system (mass, spring or damper).

Parameters:
  • gamma1 – Gamma value for first system.
  • gamma2 – Gamma value for second system.
  • sigma2 – length scale of latent process.
  • gradThetaGamma – Vector with the gradient of gamma1 and gamma2 with respect to the desired parameter.
  • X – first time input.
  • X2 – second time input.
  • mode – indicates in which way the vectors X and X2 must be transposed.
Return g:

Gradient of the function with respect to the desired parameter.

lfmGradientH32(preFactor, gradThetaGamma, compUpsilon1, compUpsilon2, mode, term=None)[source]

Gradient of the function \(h_i(z)\) with respect to some of the hyperparameters of the kernel: \(m_k\), \(C_k\), \(D_k\), \(m_r\), \(C_r\) or \(D_r\).

Computes the gradient of the function \(h_i(z)\) with respect to some of the parameters of the system (mass, spring or damper).

Parameters:
  • gamma1 – Gamma value for first system.
  • gamma2 – Gamma value for second system.
  • sigma2 – length scale of latent process.
  • gradThetaGamma – Vector with the gradient of gamma1 and gamma2 with respect to the desired parameter.
  • X – first time input.
  • X2 – second time input.
  • mode – indicates in which way the vectors X and X2 must be transposed
Return g:

Gradient of the function with respect to the desired parameter.

lfmGradientH41(preFactor, preFactorGrad, gradThetaGamma, preExp, gradUpsilon1, gradUpsilon2, compUpsilon1, compUpsilon2, mode, term=None)[source]

Gradient of the function \(h_i(z)\) with respect to some of the hyperparameters of the kernel: \(m_k\), \(C_k\), \(D_k\), \(m_r\), \(C_r\) or \(D_r\).

Computes the gradient of the function \(h_i(z)\) with respect to some of the parameters of the system (mass, spring or damper).

Parameters:
  • gamma1 – Gamma value for first system.
  • gamma2 – Gamma value for second system.
  • sigma2 – length scale of latent process.
  • gradThetaGamma – Vector with the gradient of gamma1 and gamma2 with respect to the desired parameter.
  • X – first time input.

:param X2 : second time input. :param mode: indicates in which way the vectors X and X2 must be transposed.

Return g:Gradient of the function with respect to the desired parameter.
lfmGradientH42(preFactor, preFactorGrad, gradThetaGamma, preExp, preExpt, compUpsilon1, compUpsilon2, mode, term=None)[source]

Gradient of the function \(h_i(z)\) with respect to some of the hyperparameters of the kernel: \(m_k\), \(C_k\), \(D_k\), \(m_r\), \(C_r\) or \(D_r\).

Computes the gradient of the function \(h_i(z)\) with respect to some of the parameters of the system (mass, spring or damper).

Parameters:
  • gamma1 – Gamma value for first system.
  • gamma2 – Gamma value for second system.
  • sigma2 – length scale of latent process.
  • gradThetaGamma – Vector with the gradient of gamma1 and gamma2 with respect to the desired parameter.
  • X – first time input.
  • X2 – second time input.
  • mode – indicates in which way the vectors X and X2 must be transposed
  • g – Gradient of the function with respect to the desired parameter.
lfmGradientSigmaH3(gamma1, gamma2, sigma2, X, X2, preFactor, mode, term=None)[source]

Gradient of the function \(h_i(z)\) with respect \(\sigma\).

Computes the gradient of the function \(h_i(z)\) with respect to the length-scale of the input “force”, \(\sigma\).

Parameters:
  • gamma1 – Gamma value for first system.
  • gamma2 – Gamma value for second system.
  • sigma2 – length scale of latent process.
  • X – first time input.
  • X2 – second time input.
  • mode – indicates in which way the vectors X and X2 must be transposed
Return g:

Gradient of the function with respect to \(\sigma\).

lfmGradientSigmaH4(gamma1, gamma2, sigma2, X, preFactor, preExp, mode, term)[source]

Gradient of the function \(h_i(z)\) with respect \(\sigma\).

Computes the gradient of the function \(h_i(z)\) with respect to the length-scale of the input “force”, \(\sigma\).

Parameters:
  • gamma1 – Gamma value for first system.
  • gamma2 – Gamma value for second system.
  • sigma2 – length scale of latent process.
  • X – first time input.
  • X2 – second time input.
  • mode – indicates in which way the vectors X and X2 must be transposed.
Return g:

Gradient of the function with respect to \(\sigma\).

lfmGradientSigmaUpsilonMatrix(gamma1_p, sigma2, X, X2)[source]

Computes the Upsilon’s Gradient wrt to Sigma.

Parameters:
  • gamma – gamma value system
  • sigma2 – squared lengthscale
  • X – first time input
  • X2 – second time input

:return gradient Matrix

lfmGradientSigmaUpsilonVector(gamma1_p, sigma2, X)[source]

Computes the Upsilon’s Gradient wrt to Sigma assuming that t2 is zero vector.

Parameters:
  • gamma – gamma value system
  • sigma2 – squared lengthscale
  • X – first time input

:return gradient vector (x 1)

lfmGradientUpsilonMatrix(gamma1_p, sigma2, X, X2)[source]

Computes the Upsilon’s Gradient wrt to gamma.

Parameters:
  • gamma – gamma value system
  • sigma2 – squared lengthscale
  • X – first time input
  • X2 – second time input
Returns:

gradient Matrix

lfmGradientUpsilonVector(gamma1_p, sigma2, X)[source]

Computes the Upsilon’s Gradient wrt to Sigma assuming that X2 is zero vector.

Parameters:
  • gamma – gamma value system
  • sigma2 – squared lengthscale
  • t1 – first time input
Returns:

gradient vector

lfmUpsilonMatrix(gamma1_p, sigma2, X, X2)[source]

Computes the Upsilon’s Gradient wrt to gamma.

Parameters:
  • gamma – gamma value system
  • sigma2 – squared lengthscale
  • X – first time input
  • X2 – second time input
Returns:

gradient Matrix

lfmUpsilonVector(gamma1_p, sigma2, X)[source]

Computes Upsilon given a input vector

Parameters:
  • gamma – gamma value system
  • sigma2 – squared lengthscale
  • X – first time input
Returns:

upsilon vector

Submodules

GPy.kern.src.lfm.lfmXlfm module

class LFMXLFM(input_dim, scale=None, mass=None, spring=None, damper=None, sensitivity=None, active_dims=None, isNormalised=None, name='lfmXlfm')[source]

Bases: GPy.kern.src.kern.Kern

LFM X LFM convolved kernel:

The latent force model (LFM) kernel is the result of a second order differential equation where there is assumed to be a force driving the system which is drawn from a Gaussian process with an RBF kernel, i.e. we have the following differential equation,

\[B + S f(x-\delta) = m \frac{d^2y(x)}{dx^2} + c \frac{dy(x)}{dx} + ky(x)\]

where m is a mass, c is a damping coefficient, k is a spring constant, S is a scalar sensitivity, B is the initial level and delta is a time delay.

If f(x) is assumed to come from a Gaussian process with an RBF covariance function y(t) is a Gaussian process with a covariance function provided by the single latent force model kernel. Further details about the structure of the kernel can be found in: M. Alvarez, D. Luengo and N. D. Lawrence, “Latent Force Models”, Proc. AISTATS 2009.

The kernel is designed to interoperate with the multiple output block kernel so that f(x) can be inferred given several different instantiations of y(x).

The parameters (m, c, delta and k) are constrained positive.

Inputs must be one dimensional i.e. time series.

Parameters:

  • scale (ToDo: Define)
  • mass (Mass)
  • spring (Spring constant)
  • damper (Damping coefficient)
  • sensitivity (Scalar sensitivity)
  • isNormalised (ToDo: Define)

Parameters are 1x2 numpy arrays with the first value assocated with the first part of the kernel and the second with the second. scale is the same for both parts of the kernel.

K(X, X2=None)[source]

Compute the kernel function.

\[K_{ij} = k(X_i, X_j)\]
Parameters:
  • X – the first set of inputs to the kernel
  • X2 – (optional) the second set of arguments to the kernel. If X2 is None, this is passed throgh to the ‘part’ object, which handLes this as X2 == X.
Kdiag(X)[source]

The diagonal of the kernel matrix K

\[Kdiag_{i} = k(X_i, X_i)\]
parameters_changed()[source]

This function overrides the same name function in the grandparent class “Parameterizable”, which is simply “pass” It describes the behaviours of the class when the “parameters” of a kernel are updated.

recalculate_intermediate_variables()[source]

Recalulate (effectively cached) intermediate variables derived from kernel object parameters.

reset_gradients()[source]
update_gradients_full(dL_dK, X, X2=None, meanVector=None)[source]

Given the derivative of the objective wrt the covariance matrix (dL_dK), compute the gradient wrt the parameters of this kernel, and store in the parameters object as e.g. self.variance.gradient

GPy.kern.src.lfm.lfmxrbf module

class LFMXRBF(input_dim, active_dims=None, scale=None, mass=None, spring=None, damper=None, sensitivity=None, isNormalised=None, name='lfmXrbf')[source]

Bases: GPy.kern.src.kern.Kern

LFM X RBF convolved kernel:

Inputs must be one dimensional i.e. time series.

Parameters:

  • scale (ToDo: Define)
  • mass (Mass)
  • spring (Spring constant)
  • damper (Damping coefficient)
  • sensitivity (Scalar sensitivity)
  • isNormalised (ToDo: Define)

Parameters are 1x2 numpy arrays with the first value assocated with the first part of the kernel and the second with the second. scale is the same for both parts of the kernel.

K(X1, X2=None)[source]

Compute the kernel function.

\[K_{ij} = k(X_i, X_j)\]
Parameters:
  • X – the first set of inputs to the kernel
  • X2 – (optional) the second set of arguments to the kernel. If X2 is None, this is passed throgh to the ‘part’ object, which handLes this as X2 == X.
Kdiag(X)[source]

The diagonal of the kernel matrix K

\[Kdiag_{i} = k(X_i, X_i)\]
parameters_changed()[source]

This function overrides the same name function in the grandparent class “Parameterizable”, which is simply “pass” It describes the behaviours of the class when the “parameters” of a kernel are updated.

recalculate_intermediate_variables()[source]
update_gradients_full(dL_dK, X1, X2=None, meanVector=None)[source]

Set the gradients of all parameters when doing full (N) inference.

GPy.kern.src.lfm.rbfxrbf module