Prediction#
- class Prediction[source]#
What a fitted regressor expects at each row you asked about, in your original units.
By default it is for a new observation, so the spread includes measurement noise. Made with
predict(..., include_noise=False)it is for the underlying curve without the noise: the same mean, with a smaller spread.includes_noisesays which, and so does its printed form.The model’s expectation is one joint normal distribution over all rows:
mean(),std()andinterval()read its per-row values, andcovariance()gives how the rows move together.to_frame()puts the predictions next to your rows, and printing a prediction shows that table.Two predictions are equal only if they are the same object.
- covariance() ndarray[source]#
How the predictions for the rows move together: an n-by-n numpy array, for n rows.
Row
iand columnjhold the covariance between rowsiandj, in the target’s units squared, in the order of the rows passed topredict. Its diagonal isstd() ** 2. Likestd(), it includes measurement noise only whenincludes_noiseis True: the noise of each row is its own, so it adds to the diagonal only.This builds the whole matrix, so memory and time grow with the square of the number of rows (20,000 rows take about 3 GB).
mean(),std()andinterval()do not build it.
- interval(level: float = 0.95) Any[source]#
Lower and upper bounds that each row falls between with probability
level.Only the
loweranduppercolumns (with yoursuffix, if you gave one), one row per row passed topredict, in the dataframe type passed topredict. The bounds are for a new observation whenincludes_noiseis True, and for the underlying curve when it is False.
- mean() ndarray[source]#
The predicted mean of each row, in the target’s units, as a numpy array.
It is the same whether or not the prediction includes measurement noise.
- sample(n_samples: int = 1, random_state: int = 0) ndarray[source]#
Random samples of what the model expects, in the target’s units: a numpy array of n rows by
n_samplescolumns, for n rows, the shape scikit-learn’ssample_ygives (its numbers for the same seed differ, as its random number generator does).Each column is one sample: a value at every row, chosen at random from the joint normal distribution over all the rows (
mean()andcovariance()), so that the rows hang together as the model expects; nearby rows get similar values. A sample includes measurement noise whenincludes_noiseis True, so it is one possible set of new observations, and is one possible underlying curve when it is False. With heteroscedastic noise the noise at a row is not quite normal, so there the samples of new observations are a normal approximation with the right mean and covariance.n_samplesis a whole number above zero, 1 by default.random_stateis a whole number from 0 to 9,223,372,036,854,775,807, 0 by default, as in scikit-learn: the same prediction andrandom_stategive the same samples. It builds the covariance, so memory and time grow with the square of the number of rows.
- std() ndarray[source]#
The predicted standard deviation of each row, in the target’s units, as a numpy array.
It includes measurement noise when
includes_noiseis True, and is the spread of the underlying curve alone when it is False.
- to_frame(interval: float | None = None) Any[source]#
Your rows, every column you passed, followed by
meanandstdcolumns.It is the dataframe type passed to
predict, with the same rows in the same order. Giveintervala level between 0 and 1, such as 0.95, to also addloweranduppercolumns: the boundsinterval(level)gives.If you passed
suffixtopredict, it is added to the name of every column skgp adds (mean_predictedforsuffix="_predicted"). If one of your columns already has the name of a column skgp would add, this raisesValueErrornaming it; pass asuffixtopredictto avoid the clash.mean(),std(),interval()andcovariance()are not affected.