F1 Score: Harmonic Mean of Precision and Recall
What You'll Learn
You'll learn how to combine precision and recall into a single balanced metric that penalizes extreme imbalances between the two.
The Problem with Separate Metrics
You've learned about precision (how accurate your positive predictions are) and recall (how many actual positives you catch). But what if you need one number to evaluate your model? Simply averaging them can be misleading.
Imagine a model with 100% precision but only 10% recall—it's ultra-cautious, making few predictions. The arithmetic mean would be 55%, which sounds decent but hides the terrible recall.
Enter the F1 Score
The F1 score uses the harmonic mean instead of the regular average. The harmonic mean heavily penalizes extreme values, forcing a balance between precision and recall.
The Formula
F1 = 2 × (Precision × Recall) / (Precision + Recall)
The harmonic mean answers: "What would precision and recall both need to be if they were equal to produce this score?"
Why Harmonic Mean?
Think of precision and recall like two speeds: driving 100 mph for half your trip and 10 mph for the other half. Your average speed isn't 55 mph—you spent most of your time going slow! The harmonic mean (18.2 mph) reflects the actual performance better.
Similarly, F1 ensures that both precision and recall must be reasonably high. If either metric is low, F1 will be dragged down.
When to Use F1
Use F1 when:
- You care equally about precision and recall
- You want a single metric for model comparison
- You need to balance false positives and false negatives
Key Takeaway: The F1 score combines precision and recall into a single balanced metric using the harmonic mean, preventing models with lopsided performance from appearing deceptively good.