Kernels

gpax.kernels.RBFKernel(X, Z, params, noise=0, jitter=1e-06, **kwargs)[source]

Radial basis function kernel

Parameters:
  • X (Array) – 2D vector with (number of points, number of features) dimension

  • Z (Array) – 2D vector with (number of points, number of features) dimension

  • params (Dict[str, Array]) – Dictionary with kernel hyperparameters ‘k_length’ and ‘k_scale’

  • noise (int) – optional noise vector with dimension (n,)

Return type:

Array

Returns:

Computed kernel matrix betwenen X and Z

gpax.kernels.MaternKernel(X, Z, params, noise=0, jitter=1e-06, **kwargs)[source]

Matern52 kernel

Parameters:
  • X (Array) – 2D vector with (number of points, number of features) dimension

  • Z (Array) – 2D vector with (number of points, number of features) dimension

  • params (Dict[str, Array]) – Dictionary with kernel hyperparameters ‘k_length’ and ‘k_scale’

  • noise (int) – optional noise vector with dimension (n,)

Return type:

Array

Returns:

Computed kernel matrix between X and Z

gpax.kernels.PeriodicKernel(X, Z, params, noise=0, jitter=1e-06, **kwargs)[source]

Periodic kernel

Parameters:
  • X (Array) – 2D vector with (number of points, number of features) dimension

  • Z (Array) – 2D vector with (number of points, number of features) dimension

  • params (Dict[str, Array]) – Dictionary with kernel hyperparameters ‘k_length’, ‘k_scale’, and ‘period’

  • noise (int) – optional noise vector with dimension (n,)

Return type:

Array

Returns:

Computed kernel matrix between X and Z

gpax.kernels.NNGPKernel(activation='erf', depth=3)[source]

Neural Network Gaussian Process (NNGP) kernel function

Parameters:
  • activation (str) – activation function (‘erf’ or ‘relu’)

  • depth (int) – The number of layers in the corresponding infinite-width neural network. Controls the level of recursion in the computation.

Return type:

Callable[[Array, Array, Dict[str, Array]], Array]

Returns:

Function for computing kernel matrix between X and Z.

gpax.kernels.MultitaskKernel(base_kernel, **kwargs1)[source]

Constructs a multi-task kernel given a base data kernel. The multi-task kernel is defined as

\[K(x_i, y_j) = k_{data}(x, y) * k_{task}(i, j)\]

where x and y are data points and i and j are the tasks associated with these points. The task indices are passed as the last column in the input data vectors.

Parameters:
  • base_kernel – The name of the base data kernel or a function that computes the base data kernel. This kernel is used to compute the similarities in the input space. The built-in kernels are ‘RBF’, ‘Matern’, ‘Periodic’, and ‘NNGP’.

  • **kwargs1 – Additional keyword arguments to pass to the get_kernel function when constructing the base data kernel.

Returns:

The constructed multi-task kernel function.

gpax.kernels.MultivariateKernel(base_kernel, num_tasks, **kwargs1)[source]

Construct a multivariate kernel given a base data kernel asssuming that all tasks share the same input space. For situations where not all tasks share the same input parameters, see MultitaskKernel. The multivariate kernel is defined as a Kronecker product between data and task kernels

\[K(x_i, y_j) = k_{data}(x, y) \otimes k_{task}(i, j)\]

where x and y are data points and i and j are the tasks associated with these points.

Parameters:
  • base_kernel – The name of the base data kernel or a function that computes the base data kernel. This kernel is used to compute the similarities in the input space. THe built-in kernels are ‘RBF’, ‘Matern’, ‘Periodic’, and ‘NNGP’.

  • num_tasks – number of tasks

  • **kwargs1 – dict Additional keyword arguments to pass to the get_kernel function when constructing the base data kernel.

Returns:

The constructed multi-task kernel function.

gpax.kernels.LCMKernel(base_kernel, shared_input_space=True, num_tasks=None, **kwargs1)[source]

Construct kernel for a Linear Model of Coregionalization (LMC)

Parameters:
  • base_kernel – The name of the data kernel or a function that computes the data kernel. This kernel is used to compute the similarities in the input space. The built-in kernels are ‘RBF’, ‘Matern’, ‘Periodic’, and ‘NNGP’.

  • shared_input_space – If True (default), assumes that all tasks share the same input space and uses a multivariate kernel (Kronecker product). If False, assumes that different tasks have different number of observations and uses a multitask kernel (elementwise multiplication). In that case, the task indices must be appended as the last column of the input vector.

  • num_tasks – int, optional Number of tasks. This is only used if shared_input_space is True.

  • **kwargs1 – Additional keyword arguments to pass to the get_kernel function when constructing the base data kernel.

Returns:

The constructed LMC kernel function.