Skip to content

predict_proba

Apply the model to the given dataset to predict the probability that the object belongs to the given classes.

Note

The model prediction results will be correct only if the X parameter with feature values contains all the features used in the model. For a polars DataFrame or LazyFrame, the features are matched by name: extra columns are ignored and the order of the columns does not matter (a LazyFrame collects only the columns the model needs). For other types, and for a model trained without feature names, the features must be in the same number and order as the columns provided during the training.

Method call format

predict_proba(X, *, offset=None)

Parameters

X

Description

Feature values data.

Possible types

  • polars.DataFrame
  • polars.LazyFrame
  • numpy.ndarray of shape (object_count, feature_count)
  • other array-like data of the same shape

Default value

Required parameter

offset

Description

The link-scale offset to add to the raw score of each object, as passed to the offset parameter of fit. A string names a column of a polars X. If omitted, the objects are scored with a zero offset.

Possible types

  • numpy.ndarray of shape (object_count,)
  • polars.Series
  • list
  • string

Default value

None

Return value

A two-dimensional numpy.ndarray of shape (number_of_objects, number_of_classes) with the probability for every class for each object. Column \(j\) is the probability of classes_[j].

The values are float64. The model calculates in float32, and the wider type avoids accumulating rounding errors in downstream metrics such as log loss and AUC.

Usage examples

proba = model.predict_proba(test_data)
p_lapse = proba[:, 1]