bayesvalidrox.surrogate_models.gaussian_process_sklearn.MySklGPE

class bayesvalidrox.surrogate_models.gaussian_process_sklearn.MySklGPE(max_iter=10000, gtol=1e-06, **kwargs)

Bases: GaussianProcessRegressor

GP ScikitLearn class, to change the default values for maximum iterations and optimization tolerance.

__init__(max_iter=10000, gtol=1e-06, **kwargs)

Methods

__init__([max_iter, gtol])

fit(X, y)

Fit Gaussian process regression model.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

log_marginal_likelihood([theta, ...])

Return log-marginal likelihood of theta for training data.

predict(X[, return_std, return_cov])

Predict using the Gaussian process regression model.

sample_y(X[, n_samples, random_state])

Draw samples from Gaussian process and evaluate at X.

score(X, y[, sample_weight])

Return the coefficient of determination of the prediction.

set_params(**params)

Set the parameters of this estimator.

set_predict_request(*[, return_cov, return_std])

Request metadata passed to the predict method.

set_score_request(*[, sample_weight])

Request metadata passed to the score method.

fit(X, y)

Fit Gaussian process regression model.

Parameters

Xarray-like of shape (n_samples, n_features) or list of object

Feature vectors or other representations of training data.

yarray-like of shape (n_samples,) or (n_samples, n_targets)

Target values.

Returns

selfobject

GaussianProcessRegressor class instance.

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns

routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)

Get parameters for this estimator.

Parameters

deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns

paramsdict

Parameter names mapped to their values.

log_marginal_likelihood(theta=None, eval_gradient=False, clone_kernel=True)

Return log-marginal likelihood of theta for training data.

Parameters

thetaarray-like of shape (n_kernel_params,) default=None

Kernel hyperparameters for which the log-marginal likelihood is evaluated. If None, the precomputed log_marginal_likelihood of self.kernel_.theta is returned.

eval_gradientbool, default=False

If True, the gradient of the log-marginal likelihood with respect to the kernel hyperparameters at position theta is returned additionally. If True, theta must not be None.

clone_kernelbool, default=True

If True, the kernel attribute is copied. If False, the kernel attribute is modified, but may result in a performance improvement.

Returns

log_likelihoodfloat

Log-marginal likelihood of theta for training data.

log_likelihood_gradientndarray of shape (n_kernel_params,), optional

Gradient of the log-marginal likelihood with respect to the kernel hyperparameters at position theta. Only returned when eval_gradient is True.

predict(X, return_std=False, return_cov=False)

Predict using the Gaussian process regression model.

We can also predict based on an unfitted model by using the GP prior. In addition to the mean of the predictive distribution, optionally also returns its standard deviation (return_std=True) or covariance (return_cov=True). Note that at most one of the two can be requested.

Parameters

Xarray-like of shape (n_samples, n_features) or list of object

Query points where the GP is evaluated.

return_stdbool, default=False

If True, the standard-deviation of the predictive distribution at the query points is returned along with the mean.

return_covbool, default=False

If True, the covariance of the joint predictive distribution at the query points is returned along with the mean.

Returns

y_meanndarray of shape (n_samples,) or (n_samples, n_targets)

Mean of predictive distribution a query points.

y_stdndarray of shape (n_samples,) or (n_samples, n_targets), optional

Standard deviation of predictive distribution at query points. Only returned when return_std is True.

y_covndarray of shape (n_samples, n_samples) or (n_samples, n_samples, n_targets), optional

Covariance of joint predictive distribution a query points. Only returned when return_cov is True.

sample_y(X, n_samples=1, random_state=0)

Draw samples from Gaussian process and evaluate at X.

Parameters

Xarray-like of shape (n_samples_X, n_features) or list of object

Query points where the GP is evaluated.

n_samplesint, default=1

Number of samples drawn from the Gaussian process per query point.

random_stateint, RandomState instance or None, default=0

Determines random number generation to randomly draw samples. Pass an int for reproducible results across multiple function calls. See Glossary.

Returns

y_samplesndarray of shape (n_samples_X, n_samples), or (n_samples_X, n_targets, n_samples)

Values of n_samples samples drawn from Gaussian process and evaluated at query points.

score(X, y, sample_weight=None)

Return the coefficient of determination of the prediction.

The coefficient of determination \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y_true - y_pred)** 2).sum() and \(v\) is the total sum of squares ((y_true - y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.

Parameters

Xarray-like of shape (n_samples, n_features)

Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.

yarray-like of shape (n_samples,) or (n_samples, n_outputs)

True values for X.

sample_weightarray-like of shape (n_samples,), default=None

Sample weights.

Returns

scorefloat

\(R^2\) of self.predict(X) w.r.t. y.

Notes

The \(R^2\) score used when calling score on a regressor uses multioutput='uniform_average' from version 0.23 to keep consistent with default value of r2_score(). This influences the score method of all the multioutput regressors (except for MultiOutputRegressor).

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters

**paramsdict

Estimator parameters.

Returns

selfestimator instance

Estimator instance.

set_predict_request(*, return_cov: bool | None | str = '$UNCHANGED$', return_std: bool | None | str = '$UNCHANGED$') MySklGPE

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

return_covstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for return_cov parameter in predict.

return_stdstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for return_std parameter in predict.

Returns

selfobject

The updated object.

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') MySklGPE

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

Returns

selfobject

The updated object.