blackboxopt.gp module
Gaussian process module.
- class blackboxopt.gp.GaussianProcess(kernel=None, *, scaler=None, maxiterLBFGS: int = 15000, **kwargs) None
Bases:
GaussianProcessRegressor
Gaussian Process model.
This model uses default attributes and parameters from GaussianProcessRegressor with the following exceptions:
kernel
: Default is sklearn.gaussian_process.kernels.RBF().optimizer
: Default is_optimizer()
.normalize_y
: Default is True.n_restarts_optimizer
: Default is 10.
Check other attributes and parameters for GaussianProcessRegressor at https://scikit-learn.org/dev/modules/generated/sklearn.gaussian_process.GaussianProcessRegressor.html.
- Parameters:
scaler – Scaler for the input data. For details, see https://scikit-learn.org/stable/modules/preprocessing.html. (default:
None
)maxiterLBFGS (
int
) – Maximum number of iterations for the L-BFGS-B optimizer. Stored inmaxiterLBFGS
. (default:15000
)
- maxiterLBFGS
Maximum number of iterations for the L-BFGS-B optimizer. Used in the training of the gaussian process.
- scaler
Scaler used to preprocess input data.
- __call__(x: ndarray) tuple[ndarray, ndarray]
Evaluates the model at one or multiple points.
- Parameters:
x (
ndarray
) – m-by-d matrix with m point coordinates in a d-dimensional space.- Return type:
tuple
[ndarray
,ndarray
]- Returns:
Mean value predicted by the GP model on each of the input points.
Std value predicted by the GP model on each of the input points.
- check_initial_design(sample: ndarray) bool
Check if the sample is able to generate a valid surrogate.
- Parameters:
sample (
ndarray
) – m-by-d matrix with m training points in a d-dimensional space.- Return type:
bool
- eval_kernel(x, y=None)
Evaluate the kernel function at a pair (x,y).
The structure of the kernel is the same as the one passed as parameter but with optimized hyperparameters.
- Parameters:
x – First entry in the tuple (x,y).
y – Second entry in the tuple (x,y). If None, use x. (default:
None
)
- get_iindex() tuple[int, ...]
Return iindex, the sequence of integer variable indexes.
- Return type:
tuple
[int
,...
]
- min_design_space_size(dim: int) int
Return the minimum design space size for a given space dimension.
- Return type:
int
- ntrain() int
Get the number of sampled points.
- Return type:
int
- update(Xnew, ynew) None
Updates the model with new pairs of data (x,y).
When the default optimizer method,
_optimizer()
, is used asoptimizer
, this routine reports different warnings compared to sklearn.gaussian_process.GaussianProcessRegressor.fit(). The latter reports any convergence failure in L-BFGS-B. This implementation reports the last convergence failure in the multiple L-BFGS-B runs only if there all the runs end up failing. The number of optimization runs isn_restarts_optimizer
+ 1.- Parameters:
Xnew – m-by-d matrix with m point coordinates in a d-dimensional space.
ynew – Function values on the sampled points.
- Return type:
None
- xtrain() ndarray
Get the training data points.
- Return type:
ndarray
- Returns:
m-by-d matrix with m training points in a d-dimensional space.
- ytrain() ndarray
Get f(x) for the sampled points.
- Return type:
ndarray