emukit.quadrature.kernels package¶
Module contents¶
Kernel embeddings for Bayesian quadrature.
- class emukit.quadrature.kernels.QuadratureKernel(kern, measure, variable_names)¶
Bases:
object
Abstract class for a kernel augmented with integrability.
Note
Each specific implementation of this class must go with a specific standard kernel as input which inherits from
IStandardKernel
. This is because we both want theQuadratureKernel
to be backend agnostic but at the same timeQuadratureKernel
needs access to specifics of the standard kernel. For example a specific pair ofQuadratureKernel
andIStandardKernel
isQuadratureRBF
andIRBF
. The kernel embeddings are implemented w.r.t. a specific integration measure, for example theLebesgueMeasure
.- Parameters
kern (
IStandardKernel
) – Standard EmuKit kernel.measure (
IntegrationMeasure
) – The integration measure.variable_names (
str
) – The (variable) name(s) of the integral.
- K(x1, x2)¶
The kernel k(x1, x2) evaluated at x1 and x2.
- Parameters
x1 (
ndarray
) – First argument of the kernel.x2 (
ndarray
) – Second argument of the kernel.
- Return type
ndarray
- Returns
The kernel at x1, x2.
- qK(x2)¶
The kernel with the first argument integrated out (kernel mean) evaluated at x2.
- Parameters
x2 (
ndarray
) – The locations where the kernel mean is evaluated, shape (n_points, input_dim).- Return type
ndarray
- Returns
The kernel mean at x2, shape (1, n_points).
- Kq(x1)¶
The kernel with the second argument integrated out (kernel mean) evaluated at x1.
- Parameters
x1 (
ndarray
) – The locations where the kernel mean is evaluated, shape (n_points, input_dim).- Return type
ndarray
- Returns
The kernel mean at x1, shape (n_points, 1).
- qKq()¶
The kernel integrated over both arguments x1 and x2.
- Return type
- Returns
Double integrated kernel.
- dK_dx1(x1, x2)¶
The gradient of the kernel wrt x1 evaluated at pair x1, x2.
- Parameters
x1 (
ndarray
) – First argument of the kernel, shape (n_points N, input_dim).x2 (
ndarray
) – Second argument of the kernel, shape (n_points M, input_dim).
- Return type
ndarray
- Returns
The gradient at (x1, x2), shape (input_dim, N, M).
- dK_dx2(x1, x2)¶
The gradient of the kernel wrt x2 evaluated at pair x1, x2.
Note that this is equal to the transposed gradient of the kernel wrt x1 evaluated at x2 and x1 (swapped arguments).
- Parameters
x1 (
ndarray
) – First argument of the kernel, shape (n_points N, N, input_dim).x2 (
ndarray
) – Second argument of the kernel, shape (n_points N, M, input_dim).
- Return type
ndarray
- Returns
The gradient at (x1, x2), shape (input_dim, N, M).
- dKdiag_dx(x)¶
The gradient of the diagonal of the kernel \(v(x):=k(x, x)\) evaluated at x.
- Parameters
x (
ndarray
) – The locations where the gradient is evaluated, shape = (n_points M, input_dim).- Return type
ndarray
- Returns
The gradient at x, shape (input_dim, M).
- dqK_dx(x2)¶
The gradient of the kernel mean (integrated in first argument) evaluated at x2.
- Parameters
x2 (
ndarray
) – The locations where the gradient is evaluated, shape (n_points N, N, input_dim).- Return type
ndarray
- Returns
The gradient at x2, shape (input_dim, N).
- dKq_dx(x1)¶
The gradient of the kernel mean (integrated in second argument) evaluated at x1.
- Parameters
x1 (
ndarray
) – The locations where the gradient is evaluated, shape (n_points N, N, input_dim).- Return type
ndarray
- Returns
The gradient with shape (N, input_dim).
- class emukit.quadrature.kernels.QuadratureProductKernel(kern, measure, variable_names)¶
Bases:
QuadratureKernel
Abstract class for a product kernel augmented with integrability.
The product kernel is of the form \(k(x, x') = \sigma^2 \prod_{i=1}^d k_i(x, x')\) where \(k_i(x, x')\) is a univariate kernel acting on dimension \(i\).
- Parameters
kern (
IStandardKernel
) – Standard EmuKit kernel (must be a product kernel).measure (
IntegrationMeasure
) – The integration measure.variable_names (
str
) – The (variable) name(s) of the integral.
- qK(x2, skip=None)¶
The kernel with the first argument integrated out (kernel mean) evaluated at x2.
- Parameters
x2 (
ndarray
) – The locations where the kernel mean is evaluated, shape (n_points, input_dim).- Return type
ndarray
- Returns
The kernel mean at x2, shape (1, n_points).
- qKq()¶
The kernel integrated over both arguments x1 and x2.
- Return type
- Returns
Double integrated kernel.
- dqK_dx(x2)¶
The gradient of the kernel mean (integrated in first argument) evaluated at x2.
- Parameters
x2 (
ndarray
) – The locations where the gradient is evaluated, shape (n_points N, N, input_dim).- Return type
ndarray
- Returns
The gradient at x2, shape (input_dim, N).
- class emukit.quadrature.kernels.LebesgueEmbedding¶
Bases:
object
Mixin for quadrature kernel w.r.t. Lebesgue measure.
- classmethod from_integral_bounds(kern, integral_bounds, normalized=False, variable_names='')¶
Create the quadrature kernel w.r.t. a Lebesgue measure from the integral bounds.
- Parameters
kern (
IStandardKernel
) – Standard EmuKit kernel.integral_bounds (
List
[Tuple
[float
,float
]]) – The integral bounds. List of \(d\) tuples \([(a_1, b_1), (a_2, b_2), \dots, (a_d, b_d)]\), where \(d\) is the dimensionality of the integral and the tuple \((a_i, b_i)\) contains the lower and upper integration bound of dimension \(i\).normalized (
bool
) – Weather the Lebesgue measure is normalized.variable_names (
str
) – The (variable) name(s) of the integral
- Returns
An instance of a quadrature kernel w.r.t. Lebesgue measure.
- class emukit.quadrature.kernels.GaussianEmbedding¶
Bases:
object
Mixin for quadrature kernel w.r.t. Gaussian measure.
- classmethod from_measure_params(kern, mean, variance, variable_names='')¶
Create the quadrature kernel w.r.t. a Gaussian measure from the measure parameters.
- Parameters
kern (
IStandardKernel
) – Standard EmuKit kernel.mean (
ndarray
) – The mean of the Gaussian measure, shape (input_dim, ).variance (
Union
[float
,ndarray
]) – The variances of the Gaussian measure, shape (input_dim, ). If a scalar value is given, all dimensions will have same variance.variable_names (
str
) – The (variable) name(s) of the integral
- Returns
An instance of a quadrature kernel w.r.t. Gaussian measure.
- class emukit.quadrature.kernels.QuadratureBrownian(brownian_kernel, measure, variable_names)¶
Bases:
QuadratureKernel
Base class for a Brownian motion kernel augmented with integrability.
\[k(x, x') = \sigma^2 \operatorname{min}(x, x')\quad\text{with}\quad x, x' \geq 0,\]where \(\sigma^2\) is the
variance
property.Note
This class is compatible with the standard kernel
IBrownian
. Each child of this class implements an embedding w.r.t. a specific integration measure.- Parameters
brownian_kernel (
IBrownian
) – The standard EmuKit Brownian motion kernel.measure (
IntegrationMeasure
) – The integration measure.variable_names (
str
) – The (variable) name(s) of the integral.
- Raises
ValueError – If
measure
has wrong dimensionality.ValueError – If the reasonable box of the measure allows for negative values.
- class emukit.quadrature.kernels.QuadratureBrownianLebesgueMeasure(brownian_kernel, measure, variable_names='')¶
Bases:
QuadratureBrownian
,LebesgueEmbedding
A Brownian motion kernel augmented with integrability w.r.t. the standard Lebesgue measure.
See also
- Parameters
brownian_kernel (
IBrownian
) – The standard EmuKit Brownian motion kernel.measure (
LebesgueMeasure
) – The Lebesgue measure.variable_names (
str
) – The (variable) name(s) of the integral.
- qK(x2)¶
The kernel with the first argument integrated out (kernel mean) evaluated at x2.
- Parameters
x2 (
ndarray
) – The locations where the kernel mean is evaluated, shape (n_points, input_dim).- Return type
ndarray
- Returns
The kernel mean at x2, shape (1, n_points).
- qKq()¶
The kernel integrated over both arguments x1 and x2.
- Return type
- Returns
Double integrated kernel.
- dqK_dx(x2)¶
The gradient of the kernel mean (integrated in first argument) evaluated at x2.
- Parameters
x2 (
ndarray
) – The locations where the gradient is evaluated, shape (n_points N, N, input_dim).- Return type
ndarray
- Returns
The gradient at x2, shape (input_dim, N).
- class emukit.quadrature.kernels.QuadratureRBF(rbf_kernel, measure, variable_names)¶
Bases:
QuadratureKernel
Base class for an RBF kernel augmented with integrability.
\[k(x, x') = \sigma^2 e^{-\frac{1}{2}\sum_{i=1}^{d}r_i^2},\]where \(d\) is the input dimensionality, \(r_i = \frac{x_i-x_i'}{\lambda_i}\) is the scaled vector difference of dimension \(i\), \(\lambda_i\) is the \(i\) th element of the
lengthscales
property and \(\sigma^2\) is thevariance
property.Note
This class is compatible with the standard kernel
IRBF
. Each child of this class implements an embedding w.r.t. a specific integration measure.- Parameters
rbf_kernel (
IRBF
) – The standard EmuKit rbf-kernel.measure (
IntegrationMeasure
) – The integration measure.None
implies the standard Lebesgue measure.variable_names (
str
) – The (variable) name(s) of the integral.
- property lengthscales: ndarray¶
The lengthscales \(\lambda\) of the kernel.
- Return type
ndarray
- class emukit.quadrature.kernels.QuadratureRBFLebesgueMeasure(rbf_kernel, measure, variable_names='')¶
Bases:
QuadratureRBF
,LebesgueEmbedding
An RBF kernel augmented with integrability w.r.t. the standard Lebesgue measure.
See also
- Parameters
rbf_kernel (
IRBF
) – The standard EmuKit rbf-kernel.measure (
LebesgueMeasure
) – The Lebesgue measure.variable_names (
str
) – The (variable) name(s) of the integral.
- qK(x2)¶
The kernel with the first argument integrated out (kernel mean) evaluated at x2.
- Parameters
x2 (
ndarray
) – The locations where the kernel mean is evaluated, shape (n_points, input_dim).- Return type
ndarray
- Returns
The kernel mean at x2, shape (1, n_points).
- qKq()¶
The kernel integrated over both arguments x1 and x2.
- Return type
- Returns
Double integrated kernel.
- dqK_dx(x2)¶
The gradient of the kernel mean (integrated in first argument) evaluated at x2.
- Parameters
x2 (
ndarray
) – The locations where the gradient is evaluated, shape (n_points N, N, input_dim).- Return type
ndarray
- Returns
The gradient at x2, shape (input_dim, N).
- class emukit.quadrature.kernels.QuadratureRBFGaussianMeasure(rbf_kernel, measure, variable_names='')¶
Bases:
QuadratureRBF
,GaussianEmbedding
An RBF kernel augmented with integrability w.r.t. a Gaussian measure.
See also
- Parameters
rbf_kernel (
IRBF
) – The standard EmuKit rbf-kernel.measure (
GaussianMeasure
) – A Gaussian measure.variable_names (
str
) – The (variable) name(s) of the integral.
- qK(x2, scale_factor=1.0)¶
The kernel with the first argument integrated out (kernel mean) evaluated at x2.
- Parameters
x2 (
ndarray
) – The locations where the kernel mean is evaluated, shape (n_points, input_dim).- Return type
ndarray
- Returns
The kernel mean at x2, shape (1, n_points).
- qKq()¶
The kernel integrated over both arguments x1 and x2.
- Return type
- Returns
Double integrated kernel.
- dqK_dx(x2)¶
The gradient of the kernel mean (integrated in first argument) evaluated at x2.
- Parameters
x2 (
ndarray
) – The locations where the gradient is evaluated, shape (n_points N, N, input_dim).- Return type
ndarray
- Returns
The gradient at x2, shape (input_dim, N).
- class emukit.quadrature.kernels.QuadratureProductMatern52(matern_kernel, measure, variable_names)¶
Bases:
QuadratureProductKernel
Base class for a product Matern52 kernel augmented with integrability.
The kernel is of the form \(k(x, x') = \sigma^2 \prod_{i=1}^d k_i(x, x')\) where
\[k_i(x, x') = (1 + \sqrt{5} r_i + \frac{5}{3} r_i^2) \exp(- \sqrt{5} r_i).\]Above, \(d\) is the input dimensionality, \(r_i =\frac{|x_i - x'_i|}{\lambda_i}\), is the scaled distance, \(\sigma^2\) is the
variance
property and \(\lambda_i\) is the \(i\) th element of thelengthscales
property.Note
This class is compatible with the standard kernel
IProductMatern52
. Each subclass of this class implements an embedding w.r.t. a specific integration measure.See also
- Parameters
matern_kernel (
IProductMatern52
) – The standard EmuKit product Matern52 kernel.measure (
IntegrationMeasure
) – The integration measure.variable_names (
str
) – The (variable) name(s) of the integral.
- property lengthscales: ndarray¶
The lengthscales \(\lambda\) of the kernel.
- Return type
ndarray
- class emukit.quadrature.kernels.QuadratureProductMatern52LebesgueMeasure(matern_kernel, measure, variable_names='')¶
Bases:
QuadratureProductMatern52
,LebesgueEmbedding
A product Matern52 kernel augmented with integrability w.r.t. the standard Lebesgue measure.
See also
- Parameters
matern_kernel (
IProductMatern52
) – The standard EmuKit product Matern52 kernel.measure (
LebesgueMeasure
) – The Lebesgue measure.variable_names (
str
) – The (variable) name(s) of the integral.
- class emukit.quadrature.kernels.QuadratureProductMatern32(matern_kernel, measure, variable_names)¶
Bases:
QuadratureProductKernel
Base class for a product Matern32 kernel augmented with integrability.
The kernel is of the form \(k(x, x') = \sigma^2 \prod_{i=1}^d k_i(x, x')\) where
\[k_i(x, x') = (1 + \sqrt{3}r_i ) e^{-\sqrt{3} r_i}.\]Above, \(d\) is the input dimensionality, \(r_i =\frac{|x_i - x'_i|}{\lambda_i}\), is the scaled distance, \(\sigma^2\) is the
variance
property and \(\lambda_i\) is the \(i\) th element of thelengthscales
property.Note
This class is compatible with the standard kernel
IProductMatern32
. Each subclass of this class implements an embedding w.r.t. a specific integration measure.See also
- Parameters
matern_kernel (
IProductMatern32
) – The standard EmuKit product Matern32 kernel.measure (
IntegrationMeasure
) – The integration measure.variable_names (
str
) – The (variable) name(s) of the integral.
- property lengthscales: ndarray¶
The lengthscales \(\lambda\) of the kernel.
- Return type
ndarray
- class emukit.quadrature.kernels.QuadratureProductMatern32LebesgueMeasure(matern_kernel, measure, variable_names='')¶
Bases:
QuadratureProductMatern32
,LebesgueEmbedding
A product Matern32 kernel augmented with integrability w.r.t. the standard Lebesgue measure.
See also
- Parameters
matern_kernel (
IProductMatern32
) – The standard EmuKit product Matern32 kernel.measure (
LebesgueMeasure
) – The Lebesgue measure.variable_names (
str
) – The (variable) name(s) of the integral.
- class emukit.quadrature.kernels.QuadratureProductMatern12(matern_kernel, measure, variable_names)¶
Bases:
QuadratureProductKernel
Base class for a product Matern12 (a.k.a. Exponential) kernel augmented with integrability.
The kernel is of the form \(k(x, x') = \sigma^2 \prod_{i=1}^d k_i(x, x')\) where
\[k_i(x, x') = e^{-r_i}.\]Above, \(d\) is the input dimensionality, \(r_i =\frac{|x_i - x'_i|}{\lambda_i}\), is the scaled distance, \(\sigma^2\) is the
variance
property and \(\lambda_i\) is the \(i\) th element of thelengthscales
property.Note
This class is compatible with the standard kernel
IProductMatern12
. Each subclass of this class implements an embedding w.r.t. a specific integration measure.See also
- Parameters
matern_kernel (
IProductMatern12
) – The standard EmuKit product Matern12 kernel.measure (
IntegrationMeasure
) – The integration measure.variable_names (
str
) – The (variable) name(s) of the integral.
- property lengthscales: ndarray¶
The lengthscales \(\lambda\) of the kernel.
- Return type
ndarray
- class emukit.quadrature.kernels.QuadratureProductMatern12LebesgueMeasure(matern_kernel, measure, variable_names='')¶
Bases:
QuadratureProductMatern12
,LebesgueEmbedding
A product Matern12 kernel augmented with integrability w.r.t. the standard Lebesgue measure.
See also
- Parameters
matern_kernel (
IProductMatern12
) – The standard EmuKit product Matern12 kernel.measure (
LebesgueMeasure
) – The Lebesgue measure.variable_names (
str
) – The (variable) name(s) of the integral.
- class emukit.quadrature.kernels.QuadratureProductBrownian(brownian_kernel, measure, variable_names)¶
Bases:
QuadratureProductKernel
Base class for a product Brownian kernel augmented with integrability.
The kernel is of the form \(k(x, x') = \sigma^2 \prod_{i=1}^d k_i(x, x')\) where
\[k_i(x, x') = \operatorname{min}(x_i-c, x_i'-c)\quad\text{with}\quad x_i, x_i' \geq c,\]\(d\) is the input dimensionality, \(\sigma^2\) is the
variance
property and \(c\) is theoffset
property.Note
This class is compatible with the standard kernel
IProductBrownian
. Each subclass of this class implements an embedding w.r.t. a specific integration measure.See also
- Parameters
brownian_kernel (
IProductBrownian
) – The standard EmuKit product Brownian kernel.measure (
IntegrationMeasure
) – The integration measure.variable_names (
str
) – The (variable) name(s) of the integral.
- Raises
ValueError – If the reasonable box of the measure allows for values smaller than the offset \(c\).
- class emukit.quadrature.kernels.QuadratureProductBrownianLebesgueMeasure(brownian_kernel, measure, variable_names='')¶
Bases:
QuadratureProductBrownian
,LebesgueEmbedding
A product Brownian kernel augmented with integrability w.r.t. the standard Lebesgue measure.
See also
- Parameters
brownian_kernel (
IProductBrownian
) – The standard EmuKit product Brownian kernel.measure (
LebesgueMeasure
) – The Lebesgue measure.variable_names (
str
) – The (variable) name(s) of the integral.