F1 Score
The F1 score is a single classification metric that combines precision and recall into one number by calculating their harmonic mean, providing a balanced measure of a model's performance when both false positives and false negatives…
Definition
The F1 score is a single classification metric that combines precision and recall into one number by calculating their harmonic mean, providing a balanced measure of a model's performance when both false positives and false negatives matter.
Overview
Reporting precision and recall as two separate numbers can make it hard to compare models directly, especially when one model has higher precision and another has higher recall. The F1 score solves this by combining them into a single value: F1 = 2 x (precision x recall) / (precision + recall). It uses the harmonic mean rather than a simple average because the harmonic mean penalizes extreme imbalances more heavily — a model with 100% precision but 1% recall gets a very low F1 score, correctly reflecting that it's not actually useful despite its perfect precision. The F1 score ranges from 0 to 1, with 1 representing perfect precision and recall simultaneously. It's particularly useful on imbalanced datasets, where overall accuracy can be misleadingly high, since it forces a model to perform reasonably on both fronts rather than gaming one metric at the expense of the other. A common variant, the F-beta score, generalizes this idea by letting teams weight recall more or less heavily than precision depending on which type of error matters more for their use case. Like precision and recall themselves, the F1 score is computed from the underlying counts in a confusion matrix, and for multi-class problems it's typically averaged across classes using macro, micro, or weighted averaging strategies, each handling class imbalance slightly differently. It's a standard reporting metric across applied machine learning, from binary fraud classifiers to multi-class image recognition, and appears throughout courses like Machine Learning Fundamentals.
Key Concepts
- Combines precision and recall into a single balanced score via the harmonic mean
- Ranges from 0 (worst) to 1 (perfect precision and recall)
- Penalizes extreme imbalance between precision and recall more than a simple average would
- Particularly useful for evaluating models on imbalanced datasets
- Has a generalized variant, F-beta, that lets teams weight recall versus precision
- For multi-class problems, typically averaged using macro, micro, or weighted strategies