Mean functions#

gpyreg.mean_functions#

Each mean function is implemented as its own class. An instance of one of these classes is passed to gpyreg.GP at initialization and defines the type of mean function for that Gaussian process.

ConstantMean#

class gpyreg.mean_functions.ConstantMean[source]#

Constant mean function.

compute(hyp: ndarray, X: ndarray, compute_grad: bool = False)[source]#

Compute the mean function at given test points.

Parameters:
hypndarray, shape (mean_N,)

A 1D array of hyperparameters, where mean_N is the number returned by the function hyperparameter_count.

Xndarray, shape (N, D)

A 2D array where each row is a test point.

compute_gradbool, defaults to False

Whether to compute the gradient with respect to hyperparameters.

Returns:
mndarray, shape (N,)

The mean values.

dmndarray, shape (N, mean_N), optional

The gradient with respect to hyperparameters.

Raises:
ValueError

Raised when hyp has not the expected number of hyperparameters.

ValueError

Raised when hyp is not an 1D array but of higher dimension.

get_bounds_info(X: ndarray, y: ndarray)[source]#

Return information on the lower, upper, plausible lower and plausible upper bounds of the hyperparameters of this mean function.

Parameters:
Xndarray, shape (N, D)

A 2D array where each row is a test point.

yndarray, shape (N, 1)

A 2D array where each row is a test target.

Returns:
mean_bound_info: dict

A dictionary containing the bound info with the following elements:

LBnp.ndarray, shape (mean_N, 1)

The lower bounds of the hyperparameters.

UBnp.ndarray, shape (mean_N, 1)

The upper bounds of the hyperparameters.

PLBnp.ndarray, shape (mean_N, 1)

The plausible lower bounds of the hyperparameters.

PUBnp.ndarray, shape (mean_N, 1)

The plausible upper bounds of the hyperparameters.

x0np.ndarray, shape (mean_N, 1)

The plausible starting point.

where mean_N is the number of hyperparameters.

static hyperparameter_count(_)[source]#

Return the number of hyperparameters of this mean function.

Parameters:
Dint

The dimensionality of the mean function (unused).

Returns:
countint

The number of hyperparameters.

static hyperparameter_info(_)[source]#

Return information on the names of hyperparameters for setting them in other parts of the program.

Parameters:
Dint

The dimensionality of the mean function (unused).

Returns:
hyper_infoarray_like

A list of tuples of hyperparameter names and their number, in the order they are in the hyperparameter array.

NegativeQuadratic#

class gpyreg.mean_functions.NegativeQuadratic[source]#

Centered negative quadratic mean functions.

compute(hyp: ndarray, X: ndarray, compute_grad: bool = False)[source]#

Compute the mean function at given test points.

Parameters:
hypndarray, shape (mean_N,)

A 1D array of hyperparameters, where mean_N is the number returned by the function hyperparameter_count.

Xndarray, shape (N, D)

A 2D array where each row is a test point.

compute_gradbool, defaults to False

Whether to compute the gradient with respect to hyperparameters.

Returns:
mndarray, shape (N,)

The mean values.

dmndarray, shape (N, mean_N), optional

The gradient with respect to hyperparameters.

Raises:
ValueError

Raised when hyp has not the expected number of hyperparameters.

ValueError

Raised when hyp is not an 1D array but of higher dimension.

get_bounds_info(X: ndarray, y: ndarray)[source]#

Return information on the lower, upper, plausible lower and plausible upper bounds of the hyperparameters of this mean function.

Parameters:
Xndarray, shape (N, D)

A 2D array where each row is a test point.

yndarray, shape (N, 1)

A 2D array where each row is a test target.

Returns:
mean_bound_info: dict

A dictionary containing the bound info with the following elements:

LBnp.ndarray, shape (mean_N, 1)

The lower bounds of the hyperparameters.

UBnp.ndarray, shape (mean_N, 1)

The upper bounds of the hyperparameters.

PLBnp.ndarray, shape (mean_N, 1)

The plausible lower bounds of the hyperparameters.

PUBnp.ndarray, shape (mean_N, 1)

The plausible upper bounds of the hyperparameters.

x0np.ndarray, shape (mean_N, 1)

The plausible starting point.

where mean_N is the number of hyperparameters.

static hyperparameter_count(D: int)[source]#

Return the number of hyperparameters this mean function has.

Parameters:
Dint

The dimensionality of the mean function.

Returns:
countint

The number of hyperparameters.

static hyperparameter_info(D: int)[source]#

Return information on the names of hyperparameters for setting them in other parts of the program.

Parameters:
Dint

The dimensionality of the mean function.

Returns:
hyper_infoarray_like

A list of tuples of hyperparameter names and their number, in the order they are in the hyperparameter array.

ZeroMean#

class gpyreg.mean_functions.ZeroMean[source]#

Zero mean function.

compute(hyp: ndarray, X: ndarray, compute_grad: bool = False)[source]#

Compute the mean function at given test points.

Parameters:
hypndarray, shape (mean_N,)

A 1D array of hyperparameters, where mean_N is the number returned by the function hyperparameter_count.

Xndarray, shape (N, D)

A 2D array where each row is a test point.

compute_gradbool, defaults to False

Whether to compute the gradient with respect to hyperparameters.

Returns:
mndarray, shape (N,)

The mean values.

dmndarray, shape (N, mean_N), optional

The gradient with respect to hyperparameters.

Raises:
ValueError

Raised when hyp has not the expected number of hyperparameters.

ValueError

Raised when hyp is not an 1D array but of higher dimension.

get_bounds_info(X: ndarray, y: ndarray)[source]#

Return information on the lower, upper, plausible lower and plausible upper bounds of the hyperparameters of this mean function.

Parameters:
Xndarray, shape (N, D)

A 2D array where each row is a test point.

yndarray, shape (N, 1)

A 2D array where each row is a test target.

Returns:
mean_bound_info: dict

A dictionary containing the bound info with the following elements:

LBnp.ndarray, shape (mean_N, 1)

The lower bounds of the hyperparameters.

UBnp.ndarray, shape (mean_N, 1)

The upper bounds of the hyperparameters.

PLBnp.ndarray, shape (mean_N, 1)

The plausible lower bounds of the hyperparameters.

PUBnp.ndarray, shape (mean_N, 1)

The plausible upper bounds of the hyperparameters.

x0np.ndarray, shape (mean_N, 1)

The plausible starting point.

where mean_N is the number of hyperparameters.

static hyperparameter_count(_)[source]#

Return the number of hyperparameters of this mean function.

Parameters:
Dint

The dimensionality of the mean function (unused).

Returns:
countint

The number of hyperparameters.

static hyperparameter_info(_)[source]#

Return information on the names of hyperparameters for setting them in other parts of the program.

Parameters:
Dint

The dimensionality of the mean function (unused).

Returns:
hyper_infoarray_like

A list of tuples of hyperparameter names and their number, in the order they are in the hyperparameter array.