Precision and recall are the two metrics that reveal what accuracy hides. Whenever your classes are imbalanced β fraud, disease, spam, defect detection β these two numbers, not raw accuracy, tell you whether a model is actually useful. They are also the classic trade-off in machine learning: push one up and the other tends to fall.

Where precision and recall come from
Both are simple ratios of the cells in a confusion matrix β the table of True Positives (TP), False Positives (FP), True Negatives (TN), and False Negatives (FN). If you have not met that table yet, read the confusion matrix guide first; everything below builds on it.
What is precision?
Precision answers: “Of everything the model flagged as positive, how much really was positive?” It measures the trustworthiness of a positive prediction. A spam filter with high precision rarely dumps a real email into the spam folder β when it says “spam,” you can believe it. Precision is hurt by false positives (false alarms).
What is recall?
Recall β also called sensitivity or the true positive rate β answers: “Of all the real positives, how many did the model actually catch?” It measures coverage. A cancer-screening model with high recall misses very few sick patients. Recall is hurt by false negatives (misses).
A concrete precision and recall example
Return to a disease test on 100 patients where 20 are truly sick. The model produces TP = 18, FN = 2, FP = 5, TN = 75:
Precision = 18 / (18 + 5) = 78% β when it says “sick,” it is right 78% of the time. Recall = 18 / (18 + 2) = 90% β it caught 90% of the patients who were actually sick. The raw accuracy of 93% told you nothing about the 2 missed patients or 5 false alarms.
The precisionβrecall trade-off
Most classifiers output a probability, and you convert it to a label using a threshold (often 0.5). Move that threshold and you move both metrics in opposite directions:
- Lower the threshold β the model predicts “positive” more freely β recall rises (fewer misses) but precision falls (more false alarms).
- Raise the threshold β the model is more cautious β precision rises but recall falls (more misses).
Combining them: the F1 score
When you need a single number that balances both, use the F1 score β the harmonic mean of precision and recall. The harmonic mean punishes imbalance, so a model can only score a high F1 if both are high. For our example, F1 = 2 × (0.78 × 0.90) / (0.78 + 0.90) ≈ 0.84. See the Wikipedia precision and recall article for the formal definitions.
Computing them in Python
from sklearn.metrics import precision_score, recall_score
y_true = [1, 0, 1, 1, 0, 1, 0, 0]
y_pred = [1, 0, 1, 0, 0, 1, 1, 0]
print("Precision:", precision_score(y_true, y_pred))
print("Recall: ", recall_score(y_true, y_pred))Frequently asked questions
Is recall the same as sensitivity?
Can precision and recall both be high?
What is a good precision or recall value?
Do I always need both precision and recall?
Related guides
- Confusion Matrix β the table these ratios come from.
- F1 Score β one balanced number from precision and recall.
- ROC Curve & AUC β evaluating across all thresholds.
- Classification Metrics β which metric to use and when.