SparseGaussianProcessClassifier#

class SparseGaussianProcessClassifier(*, kernel: Literal['rbf', 'matern32', 'matern52'] | AbstractKernel = 'matern52', mean_function: Literal['zero', 'constant', 'linear'] | AbstractMeanFunction = 'constant', num_inducing: int | None = None, minibatch_size: int | None = None, random_state: int = 0, iterations: int = 2000)[source]#

skgp’s SparseGPClassifier as a scikit-learn estimator: Gaussian process classification of two classes for data with too many rows for a GaussianProcessClassifier, with skgp’s settings.

There are no features, target or schema (see GaussianProcessRegressor). The settings, checked at fit, are a SparseGPClassifier’s: kernel, mean_function, num_inducing, minibatch_size, random_state and iterations, as for SparseGaussianProcessRegressor.

After fit, classes_, fitted_, n_features_in_ and feature_names_in_ are as for GaussianProcessClassifier.

fit(X: Any, y: Any) → Self#

Fit to the inputs X and the classes y, and return this estimator, fitted.

X is a Polars or pandas dataframe, whose columns keep their names, or a numeric array, whose columns are called x0, x1, …; y holds one of two classes per row, of any type. The two classes, in sorted order, are classes_. The fitted skgp model is fitted_.

predict(X: Any) → ndarray#

The more likely class at each row of X, as a numpy array of the classes.

predict_proba(X: Any) → ndarray#

The probability of each class at each row of X: a numpy array with a row for each row and a column for each class, in the order of classes_.

sample_y(X: Any, n_samples: int = 1, random_state: int = 0) → ndarray#

Random samples of the class at each row of X: a numpy array of a row for each row and a column for each sample, holding the classes (see skgp.ClassPrediction.sample). scikit-learn’s classifiers have no sample_y; skgp’s have one so that every estimator samples the same way. random_state is a whole number.

score(X: Any, y: Any, sample_weight: None = None) → float#

The Brier loss of the predicted probabilities of y at the rows X, with its sign flipped, so that higher is better, as scikit-learn’s neg_brier_score scorer gives it: the mean, over the rows, of the squared difference between the probability of classes_[1] and 1 where it is the class, 0 where it is not. It is what cross_val_score and GridSearchCV use when given no scoring, in place of the accuracy scikit-learn’s classifiers give. Rows cannot be weighted.