Precision-Recall Curve
noun
say it: “prih-SIZH-un REE-kawl KURV” /prɪˈsɪʒən ˈriˌkɔl ˈkɝv/
A graph showing how a classifier's precision and recall change as its decision threshold moves, used to choose a balance between them.
What is a precision-recall curve?
A precision-recall curve plots precision against recall at every possible decision threshold. Moving along it
trades misses for false alarms, so you can pick the threshold whose balance suits the job. scikit-learn's
precision_recall_curve() gives the points and PrecisionRecallDisplay draws them.
from sklearn.metrics import precision_recall_curve
fraud = [0, 0, 1, 0, 1, 1]
chances = [0.1, 0.3, 0.4, 0.6, 0.8, 0.9] # predict_proba()'s fraud column
precision, recall, thresholds = precision_recall_curve(fraud, chances)
print(thresholds) # [0.1 0.3 0.4 0.6 0.8 0.9]
print(precision.round(2)) # [0.5 0.6 0.75 0.67 1. 1. 1. ]
print(recall.round(2)) # [1. 1. 1. 0.67 0.67 0.33 0. ]: at 0.4, precision 0.75 and recall 1.0
In a sentence
- “She chose the threshold at the bend of the precision-recall curve.”
- “The precision-recall curve showed that catching 90% of the fraud would drop precision to 0.3.”
Level: Freelancer · More AI Basics terms at this level
Updated