GPR

Module wrapper exploiting GPy for Gaussian Process Regression

class GPR(kern=None, normalizer=True, optimization_restart=20)[source]

Bases: Approximation

Multidimensional regression using Gaussian process.

Variables:
  • X_sample (numpy.ndarray) – the array containing the input points, arranged by row.

  • Y_sample (numpy.ndarray) – the array containing the output values, arranged by row.

  • model (sklearn.gaussian_process.GaussianProcessRegressor) – the regression model.

  • kern (sklearn.gaussian_process.kernels.Kernel) – kernel object from sklearn.

  • normalizer (bool) – whether to normilize values or not. Defaults to True.

  • optimization_restart (int) – number of restarts for the optimization. Defaults to 20.

Example:
>>> import ezyrb
>>> import numpy as np
>>> x = np.random.uniform(-1, 1, size=(4, 2))
>>> y = (np.sin(x[:, 0]) + np.cos(x[:, 1]**3)).reshape(-1, 1)
>>> gpr = ezyrb.GPR()
>>> gpr.fit(x, y)
>>> y_pred = gpr.predict(x)
>>> print(np.allclose(y, y_pred))

Initialize a Gaussian Process Regressor.

Parameters:
  • kern – Kernel object from sklearn. Default is None.

  • normalizer (bool) – Whether to normalize values. Default is True.

  • optimization_restart (int) – Number of restarts for optimization. Default is 20.

_abc_impl = <_abc._abc_data object>
fit(points, values)[source]

Construct the regression given points and values.

Parameters:
  • points (array_like) – the coordinates of the points.

  • values (array_like) – the values in the points.

optimal_mu(bounds, optimization_restart=10)[source]

Proposes the next sampling point by looking at the point where the Gaussian covariance is maximized. A gradient method (with multi starting points) is adopted for the optimization.

Parameters:
  • bounds (numpy.ndarray) – the boundaries in the gradient optimization. The shape must be (input_dim, 2), where input_dim is the dimension of the input points.

  • optimization_restart (int) – the number of restart in the gradient optimization. Default is 10.

predict(new_points, return_variance=False)[source]

Predict the mean and the variance of Gaussian distribution at given new_points.

Parameters:
  • new_points (array_like) – the coordinates of the given points.

  • return_variance (bool) – flag to return also the variance. Default is False.

Returns:

the mean and the variance

Return type:

(numpy.ndarray, numpy.ndarray)