EstimatorReport.get_predictions#

EstimatorReport.get_predictions(*, data_source, response_method, X=None, pos_label=None)[source]#

Get estimator’s predictions.

This method has the advantage to reload from the cache if the predictions were already computed in a previous call.

Parameters:
data_source{“test”, “train”, “X_y”}, default=”test”

The data source to use.

  • “test” : use the test set provided when creating the report.

  • “train” : use the train set provided when creating the report.

  • “X_y” : use the provided X and y to compute the metric.

response_method{“predict”, “predict_proba”, “decision_function”}

The response method to use.

Xarray-like of shape (n_samples, n_features), optional

When data_source is “X_y”, the input features on which to compute the response method.

pos_labelint, float, bool or str, default=None

The positive class when it comes to binary classification. When response_method="predict_proba", it will select the column corresponding to the positive class. When response_method="decision_function", it will negate the decision function if pos_label is different from estimator.classes_[1].

Returns:
np.ndarray of shape (n_samples,) or (n_samples, n_classes)

The predictions.

Raises:
ValueError

If the data source is invalid.

Examples

>>> from sklearn.datasets import make_classification
>>> from sklearn.model_selection import train_test_split
>>> from sklearn.linear_model import LogisticRegression
>>> X, y = make_classification(random_state=42)
>>> X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
>>> estimator = LogisticRegression().fit(X_train, y_train)
>>> from skore import EstimatorReport
>>> report = EstimatorReport(estimator, X_test=X_test, y_test=y_test)
>>> predictions = report.get_predictions(
...     data_source="test", response_method="predict"
... )
>>> predictions.shape
(25,)