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.
classesare the two values of your target column, in the order the model coded them.probabilities()andmost_likely()give the results as numpy arrays, andto_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 forclasses[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_samplescolumns, 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, andclasses[0]otherwise. Over many samples a row gets each class as often asprobabilities()says, and two rows close together tend to get the same class.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: the same prediction andrandom_stategive 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 asprobability_rain, in the order ofclasses, and the last column ismost_likely_class. It is the dataframe type passed topredict, with the same rows in the same order.If you passed
suffixtopredict, 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 raisesValueErrornaming it; pass asuffixtopredictto avoid the clash.