GaussianProcessClassifier
Gaussian process classification (GPC) based on Laplace approximation.
The implementation is based on Algorithm 3.1, 3.2, and 5.1 from [RW2006].
Internally, the Laplace approximation is used for approximating the non-Gaussian posterior by a Gaussian.
Currently, the implementation is restricted to using the logistic link function. For multi-class classification, several binary one-versus rest classifiers are fitted. Note that this class thus does not implement a true multi-class Laplace approximation.
Read more in the User Guide.
Python Reference (opens in a new tab)
Constructors
constructor()
Signature
new GaussianProcessClassifier(opts?: object): GaussianProcessClassifier;
Parameters
Name | Type | Description |
---|---|---|
opts? | object | - |
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 “1.0 * RBF(1.0)” is used as default. Note that the kernel’s hyperparameters are optimized during fitting. Also kernel cannot be a CompoundKernel . |
opts.max_iter_predict? | number | The maximum number of iterations in Newton’s method for approximating the posterior during predict. Smaller values will reduce computation time at the cost of worse results. Default Value 100 |
opts.multi_class? | "one_vs_rest" | "one_vs_one" | Specifies how multi-class classification problems are handled. Supported are ‘one_vs_rest’ and ‘one_vs_one’. In ‘one_vs_rest’, one binary Gaussian process classifier is fitted for each class, which is trained to separate this class from the rest. In ‘one_vs_one’, one binary Gaussian process classifier is fitted for each pair of classes, which is trained to separate these two classes. The predictions of these binary predictors are combined into multi-class predictions. Note that ‘one_vs_one’ does not support predicting probability estimates. Default Value 'one_vs_rest' |
opts.n_jobs? | number | The number of jobs to use for the computation: the specified multiclass problems are computed in parallel. undefined means 1 unless in a joblib.parallel\_backend (opens in a new tab) context. \-1 means using all processors. See Glossary for more details. |
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.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. |
opts.warm_start? | boolean | If warm-starts are enabled, the solution of the last Newton iteration on the Laplace approximation of the posterior mode is used as initialization for the next call of _posterior_mode(). This can speed up convergence when _posterior_mode is called several times on similar problems as in hyperparameter optimization. See the Glossary. Default Value false |
Returns
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:29 (opens in a new tab)
Methods
dispose()
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Signature
dispose(): Promise<void>;
Returns
Promise
<void
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:160 (opens in a new tab)
fit()
Fit Gaussian process classification model.
Signature
fit(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Feature vectors or other representations of training data. |
opts.y? | ArrayLike | Target values, must be binary. |
Returns
Promise
<any
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:177 (opens in a new tab)
get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Signature
get_metadata_routing(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.routing? | any | A MetadataRequest encapsulating routing information. |
Returns
Promise
<any
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:221 (opens in a new tab)
init()
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Signature
init(py: PythonBridge): Promise<void>;
Parameters
Name | Type |
---|---|
py | PythonBridge |
Returns
Promise
<void
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:104 (opens in a new tab)
log_marginal_likelihood()
Return log-marginal likelihood of theta for training data.
In the case of multi-class classification, the mean log-marginal likelihood of the one-versus-rest classifiers are returned.
Signature
log_marginal_likelihood(opts: object): Promise<number>;
Parameters
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. Note that gradient computation is not supported for non-binary classification. If true , theta must not be undefined . Default Value false |
opts.theta? | ArrayLike | Kernel hyperparameters for which the log-marginal likelihood is evaluated. In the case of multi-class classification, theta may be the hyperparameters of the compound kernel or of an individual kernel. In the latter case, all individual kernel get assigned the same theta values. If undefined , the precomputed log_marginal_likelihood of self.kernel\_.theta is returned. |
Returns
Promise
<number
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:261 (opens in a new tab)
predict()
Perform classification on an array of test vectors X.
Signature
predict(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Query points where the GP is evaluated for classification. |
Returns
Promise
<ArrayLike
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:315 (opens in a new tab)
predict_proba()
Return probability estimates for the test vector X.
Signature
predict_proba(opts: object): Promise<ArrayLike[]>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Query points where the GP is evaluated for classification. |
Returns
Promise
<ArrayLike
[]>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:352 (opens in a new tab)
score()
Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
Signature
score(opts: object): Promise<number>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Test samples. |
opts.sample_weight? | ArrayLike | Sample weights. |
opts.y? | ArrayLike | True labels for X . |
Returns
Promise
<number
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:392 (opens in a new tab)
set_score_request()
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:
Signature
set_score_request(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight? | string | boolean | Metadata routing for sample\_weight parameter in score . |
Returns
Promise
<any
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:447 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:27 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:26 (opens in a new tab)
_py
PythonBridge
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:25 (opens in a new tab)
id
string
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:22 (opens in a new tab)
opts
any
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:23 (opens in a new tab)
Accessors
base_estimator_
The estimator instance that defines the likelihood function using the observed data.
Signature
base_estimator_(): Promise<any>;
Returns
Promise
<any
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:485 (opens in a new tab)
classes_
Unique class labels.
Signature
classes_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:539 (opens in a new tab)
feature_names_in_
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Signature
feature_names_in_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:620 (opens in a new tab)
log_marginal_likelihood_value_
The log-marginal-likelihood of self.kernel\_.theta
Signature
log_marginal_likelihood_value_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:512 (opens in a new tab)
n_classes_
The number of classes in the training data
Signature
n_classes_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:566 (opens in a new tab)
n_features_in_
Number of features seen during fit.
Signature
n_features_in_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:593 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:91 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/gaussian_process/GaussianProcessClassifier.ts:95 (opens in a new tab)