## Module contents¶

The general class for Bayesian quadrature (BQ) with a warped Gaussian process model.

The model is of the form $$f = w(g(x))$$ where $$g\sim\mathcal{GP}$$ is a Gaussian process and $$w:\mathbb{R}\rightarrow\mathbb{R}$$ is a deterministic warping function.

Inherit from this class to create new warped Bayesian quadrature models.

property X: ndarray

The data nodes.

Return type

ndarray

property Y: ndarray

The data evaluations at the nodes.

Return type

ndarray

property integral_bounds: Union[None, BoxDomain]

The integration bounds. None if integration domain is not bounded.

Return type
property reasonable_box_bounds: BoxDomain

Reasonable box bounds.

This box is used by the acquisition optimizer even when integral_bounds is None. By default it is set to get_box() of the integration measure used, or, if not available, to the integral_bounds.

emukit.quadrature.measures.IntegrationMeasure.get_box

Return type

BoxDomain

property measure: Union[None, IntegrationMeasure]

The measure used for integration. None for standard Lebesgue measure.

Return type
transform(Y)

The transform from base-GP to integrand implicitly defined by the warping used.

Return type

ndarray

inverse_transform(Y)

The transform from integrand to base-GP implicitly defined by the warping used.

Return type

ndarray

predict_base(X_pred)

Compute predictive means and variances of the warped GP as well as the base GP.

Parameters

X_pred (ndarray) – Locations at which to predict, shape (n_points, input_dim).

Return type

Tuple[ndarray, ndarray, ndarray, ndarray]

Returns

Predictive mean and variances of warped GP, and predictive mean and variances of base-GP in that order all shapes (n_points, 1).

predict_base_with_full_covariance(X_pred)

Compute predictive means and covariance of the warped GP as well as the base GP.

Parameters

X_pred (ndarray) – Locations at which to predict, shape (n_points, input_dim)

Return type

Tuple[ndarray, ndarray, ndarray, ndarray]

Returns

Predictive mean and covariance of warped GP, predictive mean and covariance of base-GP in that order. mean shapes both (n_points, 1) and covariance shapes both (n_points, n_points)

predict_with_full_covariance(X_pred)

Compute predictive means and covariance of warped GP.

Parameters

X_pred (ndarray) – Locations at which to predict, shape (n_points, input_dim)

Return type

Tuple[ndarray, ndarray]

Returns

predictive mean, predictive full covariance of warped-GP, shapes (n_points, 1) and (n_points, n_points)

predict(X_pred)

Compute predictive means and variances of warped-GP.

Parameters

X_pred (ndarray) – Locations at which to predict, shape (n_points, input_dim)

Return type

Tuple[ndarray, ndarray]

Returns

predictive mean, predictive variances of warped-GP, both shapes (n_points, 1)

set_data(X, Y)

Set the new data in the model.

First, potential warping parameters that are not being optimized but do depend on the data in an analytic way are updated. This is done via the method compute_warping_params(). Then, the new data is automatically transformed and set in the model.

Parameters
• X (ndarray) – Observation locations, shape (n_points, input_dim).

• Y (ndarray) – Integrand observations at X, shape (n_points, 1).

Return type

None

compute_warping_params(X, Y)

Compute new parameters of the warping that are dependent on data, and that are not being optimized.

This method is called by default when new data is being set in set_data(). By default, this method returns an empty dict (no warping params need to be updated). Override this method in case warping parameters are data dependent.

Parameters
• X (ndarray) – Observation locations, shape (n_points, input_dim).

• Y (ndarray) – Integrand observations at X, shape (n_points, 1).

Return type

dict

Returns

Dictionary containing new warping parameters. Names of parameters are the keys.

optimize()

Optimizes the hyperparameters of the base GP.

Return type

None

integrate()

Compute an estimator of the integral as well as its variance.

Return type
Returns

Estimator of integral and its variance.

static symmetrize_matrix(A)

Symmetrize a matrix.

The symmetrized matrix is computed as $$A_{sym} = \frac{1}{2} (A + A^{\intercal})$$.

Parameters

A (ndarray) – The square matrix $$A$$, shape (N, N)

Return type

ndarray

Returns

The symmetrized matrix $$A_{sym}$$, shape (N, N).

The warping for vanilla Bayesian quadrature is the identity transform $$w(y) = y$$. Hence, the model for the integrand $$f$$ is a standard Gaussian process as.

Parameters
• base_gp (IBaseGaussianProcess) – The underlying Gaussian process model.

• X (ndarray) – The initial locations of integrand evaluations, shape (n_points, input_dim).

• Y (ndarray) – The values of the integrand at X, shape (n_points, 1).

predict_base(X_pred)

Compute predictive means and variances of the warped GP as well as the base GP.

Parameters

X_pred (ndarray) – Locations at which to predict, shape (n_points, input_dim).

Return type

Tuple[ndarray, ndarray, ndarray, ndarray]

Returns

Predictive mean and variances of warped GP, and predictive mean and variances of base-GP in that order all shapes (n_points, 1).

predict_base_with_full_covariance(X_pred)

Compute predictive means and covariance of the warped GP as well as the base GP.

Parameters

X_pred (ndarray) – Locations at which to predict, shape (n_points, input_dim)

Return type

Tuple[ndarray, ndarray, ndarray, ndarray]

Returns

Predictive mean and covariance of warped GP, predictive mean and covariance of base-GP in that order. mean shapes both (n_points, 1) and covariance shapes both (n_points, n_points)

integrate()

Compute an estimator of the integral as well as its variance.

Return type
Returns

Estimator of integral and its variance.

Computes and returns model gradients of mean and variance at given points

Parameters

X (ndarray) – points to compute gradients at

Return type

Tuple

Returns

Tuple of gradients of mean and variance.

A warped Bayesian quadrature model that is upper bounded OR lower bounded by a constant.

The integrand $$f(x)$$ is modeled as $$f(x) = f_* + \frac{1}{2} g(x)^2$$ for lower bounded functions, or as $$f(x) = f^* - \frac{1}{2}g(x)^2$$ for upper bounded functions. The constants $$f_*$$ and $$f^*$$ are the lower and upper bound respectively, and $$g$$ is a Gaussian process (GP).

The process $$f$$ induced by the Gaussian process $$g$$ is non-Gaussian and not easy to integrate. In order to obtain an analytic estimator for the integral value, this class approximates the process $$f$$ by another Gaussian process $$\hat{f}$$ which is found by linearizing $$f$$ around the mean of $$g$$. It is then possible to integrate $$\hat{f}$$ analytically. The approximate GP $$\hat{f}$$ is implemented in the predict methods in this class, and it is also used by integrate().

Parameters
Raises
• ValueError – If neither lower_bound nor upper_bound is given.

• ValueError – If both lower_bound and upper_bound are given.

• ValueError – If the quadrature kernel of base_gp is not of type QuadratureRBFGaussianMeasure.

property bound

The bound $$f^*$$ or $$f_*$$ as defined in the model.

property is_lower_bounded

True if the model is lower bounded, False if it is upper bounded.

predict_base(X_pred)

Compute predictive means and variances of the warped GP as well as the base GP.

Parameters

X_pred (ndarray) – Locations at which to predict, shape (n_points, input_dim).

Return type

Tuple[ndarray, ndarray, ndarray, ndarray]

Returns

Predictive mean and variances of warped GP, and predictive mean and variances of base-GP in that order all shapes (n_points, 1).

predict_base_with_full_covariance(X_pred)

Compute predictive means and covariance of the warped GP as well as the base GP.

Parameters

X_pred (ndarray) – Locations at which to predict, shape (n_points, input_dim)

Return type

Tuple[ndarray, ndarray, ndarray, ndarray]

Returns

Predictive mean and covariance of warped GP, predictive mean and covariance of base-GP in that order. mean shapes both (n_points, 1) and covariance shapes both (n_points, n_points)

integrate()

Compute an estimator of the integral as well as its variance.

Return type
Returns

Estimator of integral and its variance.

Computes and returns model gradients of mean and variance at given points

Parameters

X (ndarray) – points to compute gradients at

Return type

Tuple[ndarray, ndarray]

Returns

Tuple of gradients of mean and variance.

Warped Sequential Active Bayesian Integration with linear approximation (WSABI-L).

The linear approximation is described in [1] in section 3.1, Eq (9) and (10).

The offset $$\alpha$$ (notation from paper) will either be set to a small value if adapt_alpha is False. Else it will be adapted according to $$0.8 \operatorname{min}(Y)$$ as in Gunter et al. 2014, page 3, footnote, where $$Y$$ are the collected integrand evaluations so far.

References

[1] Gunter et al. 2014 Sampling for Inference in Probabilistic Models with Fast Bayesian Quadrature, Advances in Neural Information Processing Systems (NeurIPS), 27, pp. 2789–2797.

Note

WSABI-L must be used with the RBF kernel and the Gaussian integration measure (See description of base_gp parameter). The loop must use the uncertainty sampling acquisition strategy.

Parameters
compute_warping_params(X, Y)

Computes the new $$\alpha$$ parameter from data.

Parameters
• X (ndarray) – Observation locations, shape (n_points, input_dim).

• Y (ndarray) – Integrand observations at X, shape (n_points, 1).

Return type

dict

Returns

Dictionary containing new value of $$\alpha$$.

## Submodules¶

Warpings as used by warped Bayesian quadrature models.

Bases: ABC

Base class for a warping as used by a warped Bayesian quadrature model.

abstract transform(Y)

Transform from base-GP to integrand.

Parameters

Y (ndarray) – Function values of latent function, shape (n_points, 1).

Return type

ndarray

Returns

Transformed values, shape (n_points, 1).

abstract inverse_transform(Y)

Transform from integrand to base-GP.

Parameters

Y (ndarray) – Function values of integrand, shape (n_points, 1).

Return type

ndarray

Returns

Transformed values, shape (n_points, 1).

update_parameters(**new_parameters)

Update the warping parameters.

Parameters

new_parameters – Contains the parameter names as keys with the new values. An empty dictionary will do nothing.

Return type

None

Bases: Warping

The identity warping

$w(y) = y.$
transform(Y)

Transform from base-GP to integrand.

Parameters

Y (ndarray) – Function values of latent function, shape (n_points, 1).

Return type

ndarray

Returns

Transformed values, shape (n_points, 1).

inverse_transform(Y)

Transform from integrand to base-GP.

Parameters

Y (ndarray) – Function values of integrand, shape (n_points, 1).

Return type

ndarray

Returns

Transformed values, shape (n_points, 1).

Bases: Warping

The square root warping.

$\begin{split}w(y)=\begin{cases} c + \frac{1}{2}y^2 & \text{is_inverted is False (default)}\\ c - \frac{1}{2}y^2 &\text{otherwise} \end{cases},\end{split}$

where $$c$$ is a constant.

Parameters
transform(Y)

Transform from base-GP to integrand.

Parameters

Y (ndarray) – Function values of latent function, shape (n_points, 1).

Return type

ndarray

Returns

Transformed values, shape (n_points, 1).

inverse_transform(Y)

Transform from integrand to base-GP.

Parameters

Y (ndarray) – Function values of integrand, shape (n_points, 1).

Return type

ndarray

Returns

Transformed values, shape (n_points, 1).