Application Programming Interface

class mlkernels.Kernel[source]

Bases: algebra.function.Function

Kernel function.

Kernels can be added and multiplied.

__call__(*args, **kw_args)[source]

Construct the kernel matrix between all x and y.

Parameters
  • x (input) – First argument.

  • y (input, optional) – Second argument. Defaults to first argument.

Returns

Kernel matrix.

Return type

matrix

mlkernels.pairwise()[source]

Construct the kernel matrix between all x and y.

Parameters
  • k (Kernel) – Kernel.

  • x (input) – First argument.

  • y (input, optional) – Second argument. Defaults to first argument.

Returns

Kernel matrix.

Return type

matrix or matrix.AbstractMatrix

mlkernels.elwise()[source]

Construct the kernel vector x and y element-wise.

Parameters
  • kernel (Kernel) – Kernel.

  • x (input) – First argument.

  • y (input, optional) – Second argument. Defaults to first argument.

Returns

Kernel vector as a rank-2 column vector.

Return type

matrix or matrix.AbstractMatrix

Kernels

class mlkernels.EQ[source]

Bases: mlkernels.kernel.Kernel

Exponentiated quadratic kernel.

class mlkernels.RQ(alpha)[source]

Bases: mlkernels.kernel.Kernel

Rational quadratic kernel.

Parameters

alpha (scalar) – Shape of the prior over length scales. Determines the weight of the tails of the kernel. Must be positive.

class mlkernels.Matern12[source]

Bases: mlkernels.kernel.Kernel

Matern–1/2 kernel.

mlkernels.Exp

Alias for the Matern–1/2 kernel.

alias of mlkernels.kernels.matern12.Matern12

class mlkernels.Matern32[source]

Bases: mlkernels.kernel.Kernel

Matern–3/2 kernel.

class mlkernels.Matern52[source]

Bases: mlkernels.kernel.Kernel

Matern–5/2 kernel.

class mlkernels.Linear[source]

Bases: mlkernels.kernel.Kernel

Linear kernel.

class mlkernels.Delta(epsilon=1e-06)[source]

Bases: mlkernels.kernel.Kernel

Kronecker delta kernel.

Parameters

epsilon (float, optional) – Tolerance for equality in distance. Defaults to 1e-6.

class mlkernels.DecayingKernel(alpha, beta)[source]

Bases: mlkernels.kernel.Kernel

Decaying kernel.

Parameters
  • alpha (tensor) – Shape of the gamma distribution governing the distribution of decaying exponentials.

  • beta (tensor) – Rate of the gamma distribution governing the distribution of decaying exponentials.

class mlkernels.LogKernel[source]

Bases: mlkernels.kernel.Kernel

Logarithm kernel.

class mlkernels.PosteriorKernel(k_ij, k_zi, k_zj, z, K_z)[source]

Bases: mlkernels.kernel.Kernel

Posterior kernel.

Parameters
  • k_ij (kernel.Kernel) – Kernel between processes corresponding to the left input and the right input respectively.

  • k_zi (kernel.Kernel) – Kernel between processes corresponding to the data and the left input respectively.

  • k_zj (kernel.Kernel) – Kernel between processes corresponding to the data and the right input respectively.

  • z (input) – Locations of data.

  • K_z (matrix) – Kernel matrix of data.

class mlkernels.SubspaceKernel(k_zi, k_zj, z, A)[source]

Bases: mlkernels.kernel.Kernel

Kernel for a subspace of the RKHS.

Parameters
  • k_zi (kernel.Kernel) – Kernel between the processes corresponding to the left input and the inducing points respectively.

  • k_zj (kernel.Kernel) – Kernel between the processes corresponding to the right input and the inducing points respectively.

  • z (input) – Locations of the inducing points.

  • A (matrix) – Generalised inducing point kernel matrix.

class mlkernels.TensorProductKernel(*fs)[source]

Bases: mlkernels.kernel.Kernel, algebra.ops.tensor.TensorProductFunction

Tensor product kernel.