Precision vs Recall vs F1 Score
What each classification metric measures and when to prioritize which one.
Precision, recall, and F1 all summarize a classifier's confusion matrix — the counts of true positives (TP), true negatives (TN), false positives (FP), and false negatives (FN) — but each answers a different question.
Precision: of what you flagged, how much was correct?
Precision = TP / (TP + FP)High precision means few false alarms. Prioritize precision when a false positive is costly — for example, flagging a legitimate transaction as fraud.
Recall: of what actually matters, how much did you catch?
Recall = TP / (TP + FN)High recall means few misses. Prioritize recall when a false negative is costly — for example, missing an actual case of fraud or a serious defect.
F1: the balance between them
F1 = 2 × Precision × Recall / (Precision + Recall)F1 is the harmonic mean of precision and recall — it penalizes an extreme imbalance between the two more than a simple average would. It's a useful single number when you need to compare models without picking a side between precision and recall, but it hides the underlying trade-off, so it's worth reporting alongside precision and recall rather than instead of them.
Why these can be undefined
Precision is undefined when a model never predicts positive (TP + FP = 0); recall is undefined when there are no actual positives in the data (TP + FN = 0). A good calculator should show "undefined" in these cases rather than silently returning zero, which would misrepresent an unmeasurable result as a measured one.
Try the Confusion Matrix Calculator to compute all of these — plus specificity and negative predictive value — from your own TP/TN/FP/FN counts.