Noise functions#

gpyreg.noise_functions#

Each noise function (so far, only GaussianNoise) 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 noise function for that Gaussian process.

GaussianNoise#

class gpyreg.noise_functions.GaussianNoise(constant_add: bool = False, user_provided_add: bool = False, scale_user_provided: bool = False, rectified_linear_output_dependent_add: bool = False)[source]#

Gaussian noise function.

Total noise variance is is obtained by summing the independent contribution of each noise feature.

Parameters:
constant_addbool, defaults to False

Whether to add constant noise.

user_provided_addbool, defaults to False

Whether to add user provided (input) noise.

scale_user_providedbool, defaults to False

Whether to scale uncertainty in provided noise. If user_provided_add = False then this does nothing.

rectified_linear_output_dependent_addbool, defaults to False

Whether to add rectified linear output-dependent noise.

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

Compute the noise function at test points, that is the variance of observation noise evaluated at the test points.

Parameters:
hypndarray, shape (noise_N,)

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

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.

s2ndarray, shape (N, 1), optional

A 2D array of estimated noise variance associated with each test point. Only required if user_provided_add = True.

compute_gradbool, defaults to False

Whether to compute the gradient with respect to the hyperparameters.

Returns:
sn2ndarray

The variance of observation noise evaluated at test points. If there is no input or output dependent noise, sn2 is a scalar since it does not change, while otherwise it is of the same shape as s2.

dsn2ndarray, optional

The gradient with respect to hyperparameters. If there is no input or output dependent noise, dsn2 is of shape (1, noise_N) while otherwise it is of shape (N, noise_N).

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]#

Returns information on the lower, upper, plausible lower and plausible upper bounds of the hyperparameters of this noise 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:
noise_bound_info: dict

A dictionary containing the bound info with the following elements:

LBnp.ndarray, shape (noise_N, 1)

The lower bounds of the hyperparameters.

UBnp.ndarray, shape (noise_N, 1)

The upper bounds of the hyperparameters.

PLBnp.ndarray, shape (noise_N, 1)

The plausible lower bounds of the hyperparameters.

PUBnp.ndarray, shape (noise_N, 1)

The plausible upper bounds of the hyperparameters.

x0np.ndarray, shape (noise_N, 1)

The plausible starting point.

where noise_N is the number of hyperparameters.

hyperparameter_count()[source]#

Returns the number of hyperparameters this noise function has.

Returns:
countint

The number of hyperparameters.

hyperparameter_info()[source]#

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

Returns:
hyper_infoarray_like

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