True Positive
15 examples
- Predicted: 1 (disease)
- Actual: 1 (disease)
- ✅ Correct positive prediction
When positive-to-negative example ratios are very far from 50-50, usual error metrics like accuracy don’t work effectively.
Scenario: Binary classifier for rare disease detection
Seems impressive, but…
If only 0.5% of population has the disease:
Simple baseline algorithm:
# Non-learning algorithmdef predict_disease(patient_data): return 0 # Always predict no disease
Baseline performance: 99.5% accuracy (0.5% error)
With three algorithms achieving:
Problem: Lowest error may correspond to useless prediction (always y=0) rather than meaningful medical diagnosis.
Actual Class | ||
Predicted Class | 1 | 0 |
1 | 15 (True Positive) | 5 (False Positive) |
0 | 10 (False Negative) | 70 (True Negative) |
True Positive
15 examples
False Positive
5 examples
False Negative
10 examples
True Negative
70 examples
Precision: Of all patients predicted to have disease, what fraction actually has it?
Formula:
Precision = True Positives / (True Positives + False Positives) = True Positives / Total Predicted Positive
Example calculation:
Precision = 15 / (15 + 5) = 15/20 = 0.75 (75%)
Interpretation: When algorithm predicts disease, it’s correct 75% of the time.
Recall: Of all patients who actually have disease, what fraction did we correctly detect?
Formula:
Recall = True Positives / (True Positives + False Negatives) = True Positives / Total Actual Positive
Example calculation:
Recall = 15 / (15 + 10) = 15/25 = 0.60 (60%)
Interpretation: Algorithm correctly identifies 60% of all disease cases.
Algorithm that always predicts y=0:
Both precision and recall will be very low or zero for algorithms that just print y=0, making them easy to identify as non-useful.
Good algorithms need both:
Example interpretation:
Precision and recall provide much better evaluation than accuracy for skewed datasets, ensuring algorithms are both accurate in their positive predictions and effective at detecting the rare class.