Precision-Recall Curve: Meaning, Uses and How to Interpret Average Precision
A precision–recall curve plots precision (the share of positive predictions that are correct, also called positive predictive value) against recall (the share of true positives found, also called sensitivity) for every threshold of a classifier. This guide explains what the precision–recall curve shows, when and why to use the precision–recall curve, the key points of interpretation, and how to create the precision–recall curve in SPSS, R and Python or in seconds on statfas.com.
What is a precision–recall curve?
A precision–recall curve plots precision (the share of positive predictions that are correct, also called positive predictive value) against recall (the share of true positives found, also called sensitivity) for every threshold of a classifier. The precision–recall curve focuses entirely on the positive class.
The summary number is average precision (AP), often called AUPRC. Because the precision–recall curve ignores true negatives, the precision–recall curve stays honest when negatives vastly outnumber positives.
When and why should you use a precision–recall curve?
Use a precision–recall curve in these situations:
- Rare outcomes: pathogenic variants, rare diseases, cancer screening, adverse events or any setting with fewer than about 10–20% positives.
- Costly false alarms: when follow-up tests are expensive and precision matters as much as sensitivity.
- Model comparison on imbalanced data: where a ROC curve looks uniformly excellent and hides differences.
- Threshold selection: choosing the cut-off with the best F1 score or a target precision.
On imbalanced data a model can reach an AUC above .90 while most positive calls are wrong. The precision–recall curve exposes that problem, which is why Saito and Rehmsmeier (2015) recommend the precision–recall curve for imbalanced classification.
How to interpret a precision–recall curve: key points
- The baseline is the prevalence. A model with no skill gives a flat line at the proportion of positives, not a diagonal.
- Compare AP with the baseline. With 10% positives, an AP of .52 is about five times the baseline. Report the lift.
- Top-right is best. A precision–recall curve that stays high as recall increases means few false alarms even when most positives are found.
- Expect a jagged line. With few positives, each case moves precision noticeably, so report a bootstrap confidence interval.
- Do not compare AP across datasets with different prevalence, because the baseline changes.
- F1 is one choice of threshold. F1 weights precision and recall equally; screening and confirmatory tests often need different weights.
How to make a precision–recall curve in SPSS, R and Python
The snippets below show the core commands; the full precision–recall curve tutorial has complete, copy-and-run code. Examples assume a data frame df with the columns named in the code.
Precision–Recall Curve in SPSS
Standard SPSS menus do not offer a dedicated precision–recall curve. Run Analyze > Classification > ROC Curve with Coordinate points of the ROC Curve ticked, copy the Coordinates table (sensitivity and 1 − specificity) into a new dataset, then compute precision from the prevalence of the positive class with the syntax below and draw recall against precision with Graphs > Chart Builder (scatter/line).
SPSS syntax
* sens = Sensitivity column, fpr = 1 - Specificity column from the ROC coordinates table.
* 0.10 is the prevalence of the positive class in your data; replace it with your own value.
COMPUTE prec = (sens*0.10) / (sens*0.10 + fpr*0.90).
EXECUTE.
GRAPH /SCATTERPLOT(BIVAR)=sens WITH prec.Precision–Recall Curve in R
R code
library(PRROC)
pr <- pr.curve(scores.class0 = df$score[df$outcome == 1],
scores.class1 = df$score[df$outcome == 0], curve = TRUE)
pr$auc.integralPrecision–Recall Curve in Python
Python code
from sklearn.metrics import precision_recall_curve, average_precision_score
p, r, thr = precision_recall_curve(df["outcome"], df["score"])
ap = average_precision_score(df["outcome"], df["score"])The easy way: free precision–recall curve maker on statfas.com
The Precision–Recall Curve maker on statfas.com uploads an Excel, CSV or SPSS file, draws the precision–recall curve with the no-skill baseline, and returns average precision with a bootstrap 95% CI, the lift over prevalence, a bootstrap p value and the best-F1 threshold. No coding is needed: upload the file, confirm the columns and read the results.
- Edit the precision–recall curve: title, axis labels, colours, line and marker sizes, fonts, grid lines and resolution (150, 300 or 600 dpi).
- Copy ready-to-use APA 7 text for free.
- Download the precision–recall curve (PNG or SVG), the tables (CSV) and a Word report that combines the table, the figure and the interpretation after a free sign-up and log-in.
Try the precision–recall curve maker
How to report a precision–recall curve in APA 7
Example wording (illustrative values; replace with your own results):
Place the figure number and title above the precision–recall curve and a note below, as the APA 7 style requires. The statfas.com precision–recall curve maker writes the caption and results paragraph automatically.
Frequently asked questions
- When should I use a precision-recall curve instead of a ROC curve?
- Use a precision–recall curve when the positive class is rare or when false positives are costly. Report both curves if space allows.
- What is a good average precision?
- Judge average precision against the baseline, which equals the prevalence. An AP of .30 is excellent when prevalence is .02 but poor when prevalence is .40.
- What is the difference between AUPRC and average precision?
- Both summarise the precision–recall curve. Average precision uses a step-wise sum, while some packages use trapezoidal or Davis–Goadrich interpolation, so values can differ slightly.
- How do I find the best threshold on a precision-recall curve?
- Many analysts take the threshold with the highest F1 score. Others fix a minimum precision, such as .90, and choose the highest recall that meets the target.
References
Chicco, D., & Jurman, G. (2020). The advantages of the Matthews correlation coefficient (MCC) over F1 score and accuracy in binary classification evaluation. BMC Genomics, 21, Article 6.
Saito, T., & Rehmsmeier, M. (2015). The precision-recall plot is more informative than the ROC plot when evaluating binary classifiers on imbalanced datasets. PLOS ONE, 10(3), Article e0118432.