Skip to content
LearnPY
Matplotlibfunction reference

PrecisionRecallDisplay

Plot precision against recall for a binary classifier.

Signature

PrecisionRecallDisplay.from_estimator(estimator, X, y)

What it does

PrecisionRecallDisplay shows the tradeoff between finding positives and avoiding false alarms. The baseline is the positive rate, which makes it more informative than ROC under heavy class imbalance.

Parameters

estimatorestimator
A fitted classifier with predict_proba or decision_function.
Xarray-like
Feature matrix to score.
yarray-like
True binary labels.

Returns

PrecisionRecallDisplay

Example

pythonPrecisionRecallDisplay example
import matplotlib.pyplot as plt
from sklearn.metrics import PrecisionRecallDisplay

PrecisionRecallDisplay.from_estimator(model, X_test, y_test)
plt.show()

Watch out for

  • The no-skill baseline equals the positive class rate, not 0.5.
  • Precision at one threshold does not describe the whole curve.