ClassPrediction#

class ClassPrediction[source]#

What a fitted classifier expects at each row you asked about: the probability of each of its two classes, and the more likely one.

classes are the two values of your target column, in the order the model coded them. probabilities() and most_likely() give the results as numpy arrays, and to_frame() puts them next to your rows; printing a prediction shows that table.

Two predictions are equal only if they are the same object.

most_likely() → ndarray[source]#

The more likely class at each row, as a numpy array of your target’s values. A row whose two probabilities are exactly equal gets classes[0].

probabilities() → ndarray[source]#

The probability of each class at each row: a numpy array of n rows by 2 columns, for n rows. Column 0 is for classes[0] and column 1 for classes[1], so each row sums to 1.

sample(n_samples: int = 1, random_state: int = 0) → ndarray[source]#

Random samples of the class at each row: a numpy array of n rows by n_samples columns, for n rows, holding the values of your target column.

Each column is one sample, chosen at random jointly over all the rows: first one possible underlying curve, the one the model turns into probabilities, from its joint normal distribution at every row, so that nearby rows hang together; then at each row classes[1] with the probability that curve gives there, and classes[0] otherwise. Over many samples a row gets each class as often as probabilities() says, and two rows close together tend to get the same class.

n_samples is a whole number above zero, 1 by default. random_state is a whole number from 0 to 9,223,372,036,854,775,807, 0 by default: the same prediction and random_state give the same samples. It builds the latent curve’s covariance, so memory and time grow with the square of the number of rows.

to_frame() → Any[source]#

Your rows, every column you passed, followed by the probability of each class and the more likely class.

The probability columns are named probability_ followed by the class, such as probability_rain, in the order of classes, and the last column is most_likely_class. It is the dataframe type passed to predict, with the same rows in the same order.

If you passed suffix to predict, it is added to the name of every column skgp adds. If one of your columns already has the name of a column skgp would add, this raises ValueError naming it; pass a suffix to predict to avoid the clash.

classes: tuple[Any, Any]#

The two values of your target column: the one coded 0 first, then the one coded 1. The probabilities are in this order.

suffix: str#

The text added to the names of the columns skgp adds: what you passed to predict as suffix, empty by default.