Skip to content
Machine Learning

What is the difference between precision and recall?

Precision is the share of predicted positives that are correct, TP / (TP + FP). Recall is the share of actual positives the model finds, TP / (TP + FN).

datasciencetrivia.com

Card 1 of 280. Answer: Precision is the share of predicted positives that are correct, TP / (TP + FP). Recall is the share of actual positives the model finds, TP / (TP + FN).

Created by santiviquez

About · Quizzes · History of AI · To suggest new questions or report an error send me a dm.

The longer answer

Precision and recall both measure how a classifier handles the positive class, from opposite sides. Precision = TP / (TP + FP) asks how many of the cases the model flagged are really positive. Recall = TP / (TP + FN) asks how many of the real positives the model flagged. Recall is also called sensitivity, hit rate or the true positive rate.

One example shows both. A test set holds 100 fraudulent transactions. The model flags 120 transactions, 80 of them real fraud. Precision is 80 / 120 ≈ 0.67, so one flag in three is a false alarm. Recall is 80 / 100 = 0.80, so 20 frauds slipped through. Neither number uses the true negatives, the legitimate transactions left alone, which is why both stay informative when positives are rare and accuracy is not.

The two trade off through the decision threshold. Lowering it flags more cases, so recall rises or stays put while precision usually falls; raising it does the reverse. Recall never rises when the threshold goes up, but precision can dip at some steps, because the next case to drop out may be a true positive. Both extremes are easy to reach and useless: flagging everything gives recall 1.0 with precision equal to the share of positives, and a model that flags nothing has an undefined precision of 0/0, which scikit-learn reports as 0 with a warning.

Recall depends only on how the model treats the real positives, but precision also depends on how common they are. Take a screening test that catches 90% of sick patients and wrongly flags 5% of healthy ones. Among 10,000 people with 1% prevalence, it finds 90 of the 100 sick and flags 495 of the 9,900 healthy, so precision is 90 / 585 ≈ 0.15. At 10% prevalence it finds 900 and flags 450, and precision rises to 900 / 1,350 ≈ 0.67. Recall is 0.90 in both cases.

Which one to favor depends on which error costs more. Favor recall when a miss is expensive, as in cancer screening or fraud detection, and precision when a false alarm is, as in a spam filter that would bury real email. To report both as one number, use the F1 score, their harmonic mean; to compare models across every threshold, plot the precision-recall curve. In medicine the same quantities go by other names: recall is sensitivity, precision is the positive predictive value, and specificity, the share of healthy people correctly cleared, completes the usual pair.

All questions