GaussianProcessRegressor#
- class GaussianProcessRegressor(*, kernel: Literal['rbf', 'matern32', 'matern52'] | AbstractKernel = 'matern52', mean_function: Literal['zero', 'constant', 'linear'] | AbstractMeanFunction = 'constant', learned_noise: Literal['constant', 'heteroscedastic'] | None = 'constant', noise_column: str | None = None, iterations: int = 2000)[source]#
skgp’s
GPRegressoras a scikit-learn estimator: an exact Gaussian process regression model, with skgp’s settings.The inputs come from
Xand the target fromy, so there are nofeaturesortarget; and noschema, because aPipelinehas changed the data before it gets here. Every other setting is aGPRegressor’s, checked atfit:kernel:"matern52"(the default),"matern32","rbf"or a GPJax kernel. Its length scales are in the units of the columns ofX.mean_function: what the curve is far from the training data:"constant"(the default),"zero","linear"or a GPJax mean function.learned_noise:"constant"(the default),"heteroscedastic", orNone, which needs anoise_column.noise_column: the column ofXthat holds each row’s known noise, as a standard deviation in the target’s units, orNone(the default). It is not an input. For an array, name it as its column is named:"x3"for the fourth.iterations: the most iterations the fit may take, 2,000 by default.
After
fit:fitted_is the fitted skgp model (print(estimator.fitted_),estimator.fitted_.to_json()),n_features_in_is the number of columns ofX, andfeature_names_in_their names whenXnamed them.- fit(X: Any, y: Any) Self#
Fit to the inputs
Xand the targety, and return this estimator, fitted.Xis a Polars or pandas dataframe, whose columns keep their names, or a numeric array, whose columns are calledx0,x1, …;yholds one number per row. The skgp model checks the data and the settings, and raisesValueErrornaming what is wrong. The fitted skgp model isfitted_.
- 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; withreturn_std=Truealso the standard deviation of each row, and withreturn_cov=Truethe covariance between the rows instead, as scikit-learn’sGaussianProcessRegressor.predictgives 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.Xhas the columns it had atfit, as scikit-learn requires, so a model with known noise has itsnoise_columnthere 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’ssample_ygives (seeskgp.Prediction.sample). Each sample includes measurement noise unlessinclude_noise=False.random_stateis a whole number.
- score(X: Any, y: Any, sample_weight: None = None) float#
The mean CRPS of the predictions of
yat the rowsX, with its sign flipped, so that higher is better (seeneg_crps). It is whatcross_val_scoreandGridSearchCVuse when given noscoring, in place of the R² scikit-learn’s regressors give. Rows cannot be weighted.