Gaussian process regression (GPR).
The implementation is based on Algorithm 2.1 of [RW2006].
In addition to standard scikit-learn estimator API, GaussianProcessRegressor
:
new GaussianProcessRegressor(opts?: object): GaussianProcessRegressor;
Name | Type | Description |
---|---|---|
opts? |
object |
- |
opts.alpha? |
number | ArrayLike |
Value added to the diagonal of the kernel matrix during fitting. This can prevent a potential numerical issue during fitting, by ensuring that the calculated values form a positive definite matrix. It can also be interpreted as the variance of additional Gaussian measurement noise on the training observations. Note that this is different from using a WhiteKernel . If an array is passed, it must have the same number of entries as the data used for fitting and is used as datapoint-dependent noise level. Allowing to specify the noise level directly as a parameter is mainly for convenience and for consistency with Ridge . Default Value 1e-10 |
opts.copy_X_train? |
boolean |
If true , a persistent copy of the training data is stored in the object. Otherwise, just a reference to the training data is stored, which might cause predictions to change if the data is modified externally. Default Value true |
opts.kernel? |
any |
The kernel specifying the covariance function of the GP. If undefined is passed, the kernel ConstantKernel(1.0, constant\_value\_bounds="fixed") \* RBF(1.0, length\_scale\_bounds="fixed") is used as default. Note that the kernel hyperparameters are optimized during fitting unless the bounds are marked as “fixed”. |
opts.n_restarts_optimizer? |
number |
The number of restarts of the optimizer for finding the kernel’s parameters which maximize the log-marginal likelihood. The first run of the optimizer is performed from the kernel’s initial parameters, the remaining ones (if any) from thetas sampled log-uniform randomly from the space of allowed theta-values. If greater than 0, all bounds must be finite. Note that n\_restarts\_optimizer \== 0 implies that one run is performed. Default Value 0 |
opts.n_targets? |
number |
The number of dimensions of the target values. Used to decide the number of outputs when sampling from the prior distributions (i.e. calling sample\_y before fit ). This parameter is ignored once fit has been called. |
opts.normalize_y? |
boolean |
Whether or not to normalize the target values y by removing the mean and scaling to unit-variance. This is recommended for cases where zero-mean, unit-variance priors are used. Note that, in this implementation, the normalisation is reversed before the GP predictions are reported. Default Value false |
opts.optimizer? |
"fmin_l_bfgs_b" |
Can either be one of the internally supported optimizers for optimizing the kernel’s parameters, specified by a string, or an externally defined optimizer passed as a callable. If a callable is passed, it must have the signature: Default Value 'fmin_l_bfgs_b' |
opts.random_state? |
number |
Determines random number generation used to initialize the centers. Pass an int for reproducible results across multiple function calls. See Glossary. |
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:25
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
dispose(): Promise<void>;
Promise
<void
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:149
Fit Gaussian process regression model.
fit(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
Feature vectors or other representations of training data. |
opts.y? |
ArrayLike |
Target values. |
Promise
<any
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:166
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
get_metadata_routing(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.routing? |
any |
A MetadataRequest encapsulating routing information. |
Promise
<any
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:210
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
init(py: PythonBridge): Promise<void>;
Name | Type |
---|---|
py |
PythonBridge |
Promise
<void
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:93
Return log-marginal likelihood of theta for training data.
log_marginal_likelihood(opts: object): Promise<number>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.clone_kernel? |
boolean |
If true , the kernel attribute is copied. If false , the kernel attribute is modified, but may result in a performance improvement. Default Value true |
opts.eval_gradient? |
boolean |
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 undefined . Default Value false |
opts.theta? |
any |
Kernel hyperparameters for which the log-marginal likelihood is evaluated. If undefined , the precomputed log_marginal_likelihood of self.kernel\_.theta is returned. |
Promise
<number
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:248
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.
predict(opts: object): Promise<ArrayLike>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
Query points where the GP is evaluated. |
opts.return_cov? |
boolean |
If true , the covariance of the joint predictive distribution at the query points is returned along with the mean. Default Value false |
opts.return_std? |
boolean |
If true , the standard-deviation of the predictive distribution at the query points is returned along with the mean. Default Value false |
Promise
<ArrayLike
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:304
Draw samples from Gaussian process and evaluate at X.
sample_y(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
Query points where the GP is evaluated. |
opts.n_samples? |
number |
Number of samples drawn from the Gaussian process per query point. Default Value 1 |
opts.random_state? |
number |
Determines random number generation to randomly draw samples. Pass an int for reproducible results across multiple function calls. See Glossary. Default Value 0 |
Promise
<any
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:357
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.
score(opts: object): Promise<number>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
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. |
opts.sample_weight? |
ArrayLike |
Sample weights. |
opts.y? |
ArrayLike |
True values for X . |
Promise
<number
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:412
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:
set_predict_request(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.return_cov? |
string | boolean |
Metadata routing for return\_cov parameter in predict . |
opts.return_std? |
string | boolean |
Metadata routing for return\_std parameter in predict . |
Promise
<any
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:467
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:
set_score_request(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.sample_weight? |
string | boolean |
Metadata routing for sample\_weight parameter in score . |
Promise
<any
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:514
boolean
=false
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:23
boolean
=false
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:22
PythonBridge
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:21
string
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:18
any
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:19
Lower-triangular Cholesky decomposition of the kernel in X\_train\_
.
L_(): Promise<ArrayLike[]>;
Promise
<ArrayLike
[]>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:633
Feature vectors or other representations of training data (also required for prediction).
X_train_(): Promise<ArrayLike[]>;
Promise
<ArrayLike
[]>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:552
Dual coefficients of training data points in kernel space.
alpha_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:660
Names of features seen during fit. Defined only when X
has feature names that are all strings.
feature_names_in_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:741
The kernel used for prediction. The structure of the kernel is the same as the one passed as parameter but with optimized hyperparameters.
kernel_(): Promise<any>;
Promise
<any
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:606
The log-marginal-likelihood of self.kernel\_.theta
.
log_marginal_likelihood_value_(): Promise<number>;
Promise
<number
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:687
Number of features seen during fit.
n_features_in_(): Promise<number>;
Promise
<number
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:714
py(): PythonBridge;
PythonBridge
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:80
py(pythonBridge: PythonBridge): void;
Name | Type |
---|---|
pythonBridge |
PythonBridge |
void
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:84
Target values in training data (also required for prediction).
y_train_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/gaussian_process/GaussianProcessRegressor.ts:579