SparseGaussianProcessRegressor#

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

skgp’s SparseGPRegressor as a scikit-learn estimator: a sparse Gaussian process regression model, for data with too many rows for an exact one, with skgp’s settings.

There are no features, target or schema (see GaussianProcessRegressor), and no noise_column, which a SparseGPRegressor does not take. The settings, checked at fit, are a SparseGPRegressor’s:

  • kernel and mean_function: as for GaussianProcessRegressor.

  • learned_noise: "constant" (the default) or "heteroscedastic".

  • num_inducing: how many inducing points summarise the data, or None (the default) to let skgp choose.

  • minibatch_size: the rows each iteration looks at, or None (the default) for all.

  • random_state: the seed of everything random in the fit, 0 by default.

  • iterations: 2,000 by default: the most iterations a fit on all rows may take, and exactly the number a fit on minibatches runs.

After fit, fitted_, n_features_in_ and feature_names_in_ are as for GaussianProcessRegressor.

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

Fit to the inputs X and the target 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 number per row. The skgp model checks the data and the settings, and raises ValueError naming what is wrong. The fitted skgp model is fitted_.

predict(X: Any, return_std: bool = False, return_cov: bool = False, include_noise: bool = True) → Any#

The predicted mean of each row of X, in the target’s units, as a numpy array; with return_std=True also the standard deviation of each row, and with return_cov=True the covariance between the rows instead, as scikit-learn’s GaussianProcessRegressor.predict gives them.

Unlike scikit-learn’s, the spread is of a new observation, measurement noise included, unless include_noise=False, which gives the spread of the underlying curve. X has the columns it had at fit, as scikit-learn requires, so a model with known noise has its noise_column there even for the curve alone, whose prediction does not use it.

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

Random samples of the prediction at the rows of X: a numpy array of a row for each row and a column for each sample, as scikit-learn’s sample_y gives (see skgp.Prediction.sample). Each sample includes measurement noise unless include_noise=False. random_state is a whole number.

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

The mean CRPS of the predictions of y at the rows X, with its sign flipped, so that higher is better (see neg_crps). It is what cross_val_score and GridSearchCV use when given no scoring, in place of the R² scikit-learn’s regressors give. Rows cannot be weighted.