Precision and recall are important evaluation metrics used in machine learning to measure the performance of classification models, especially when dealing with imbalanced datasets. They help assess how well a model identifies positive cases and handles classification errors.
In simple terms:
👉 Precision measures how many predicted positives are actually correct, while recall measures how many actual positives are successfully identified by the model.
1. What Is Precision?
Precision measures the proportion of positive predictions that are correct.
Formula:
Precision = True Positives / (True Positives + False Positives)
A high precision means that when the model predicts a positive result, it is usually correct.
Example
In a spam email detector:
- 100 emails are predicted as spam
- 90 are actually spam
- 10 are not spam
Precision = 90 / 100 = 90%
👉 High precision means fewer false alarms.
2. What Is Recall?
Recall measures the proportion of actual positive cases that the model correctly identifies.
Formula:
Recall = True Positives / (True Positives + False Negatives)
A high recall means the model successfully finds most of the positive cases.
Example
If there are 100 spam emails in total and the model identifies 90 of them:
Recall = 90 / 100 = 90%
👉 High recall means fewer missed positive cases.
3. Precision vs Recall
Although both metrics evaluate classification performance, they focus on different types of errors.
Precision Focuses On:
- Reducing False Positives
- Ensuring positive predictions are correct
Recall Focuses On:
- Reducing False Negatives
- Finding as many positive cases as possible
In many situations, improving one metric may slightly reduce the other.
4. How Are They Different from Accuracy?
Accuracy
Accuracy measures the overall percentage of correct predictions.
Accuracy = Correct Predictions / Total Predictions
However, accuracy can be misleading for imbalanced datasets.
Example
Suppose:
- 990 normal transactions
- 10 fraudulent transactions
A model that predicts every transaction as normal achieves 99% accuracy but detects zero fraud cases.
👉 Precision and recall provide a more meaningful evaluation in such scenarios.
5. When Should Precision Be Prioritized?
Precision is more important when false positives are costly.
Examples:
- Email spam filtering
- Product recommendation systems
- Fraud alerts that may inconvenience customers
In these cases, incorrect positive predictions should be minimized.
6. When Should Recall Be Prioritized?
Recall is more important when missing positive cases is costly.
Examples:
- Disease diagnosis
- Fraud detection
- Cybersecurity threat detection
In these applications, failing to identify a true positive can have serious consequences.
7. Real-World Example
Consider a medical screening system:
- High Precision → Most patients identified as sick truly have the disease.
- High Recall → Most patients who actually have the disease are detected.
Depending on the healthcare objective, recall is often prioritized because missing a disease can be dangerous.
Conclusion
Precision and recall are essential metrics for evaluating classification models beyond simple accuracy. Precision measures how many positive predictions are correct, while recall measures how many actual positive cases are successfully identified. They are especially valuable when working with imbalanced datasets where accuracy alone can be misleading. Choosing between precision and recall depends on the business problem, the cost of false positives, and the cost of false negatives. Understanding both metrics helps build more reliable and effective machine learning models.