Artificial intelligence is becoming part of everyday business operations. According to Stanford's 2026 AI Index, 88% of surveyed organizations reported using AI in at least one business function in 2025, up from 78% in 2024. As machine learning models become more widely used, evaluating whether their predictions are actually useful becomes just as important as building the models themselves.
One of the most widely used classification metrics is the F1 score.
But what does F1 score actually tell you?
In simple terms, F1 score combines precision and recall into a single metric. It is particularly useful when you care about both false positives and false negatives, especially when your dataset is imbalanced.
If you are new to classification evaluation, start with Kovendo's Mastering the Confusion Matrix in Machine Learning. That guide explains the complete confusion matrix, including true positives, true negatives, false positives, false negatives, accuracy, precision, recall, specificity and F1 score.
This guide goes one step deeper and focuses specifically on F1 score: its formula, calculation, interpretation, practical examples, limitations, multiclass classification, threshold selection and when you should or should not use it.
What Is F1 Score in Machine Learning?
F1 score is a classification metric that combines precision and recall using their harmonic mean.
Precision measures how reliable positive predictions are.
Recall measures how many of the actual positive cases the model successfully identifies.
F1 score combines both.
The standard formula is:
F1 Score = 2 × (Precision × Recall) / (Precision + Recall)
F1 ranges from 0 to 1.
A score of:
- 1.0 means perfect precision and recall.
- 0.0 means the model has no useful balance between the two.
A higher F1 generally indicates a better balance between precision and recall for the evaluated class.
Scikit-learn describes F1 as the harmonic mean of precision and recall and provides the equivalent formula directly in terms of true positives, false positives and false negatives.
The important point is that F1 does not use true negatives directly in its formula.
That makes it particularly different from accuracy.
Why Is F1 Score Important?
Imagine a fraud detection model.
The model identifies 1,000 transactions as potentially fraudulent.
If it flags too many legitimate transactions, investigators may waste time reviewing false alarms. If it misses too many fraudulent transactions, actual fraud can pass through the system.
This creates two competing objectives:
Precision: When the model predicts fraud, how often is it actually fraud?
Recall: Of all actual fraudulent transactions, how many did the model detect?
F1 score provides a single number that considers both.
This is why F1 is often useful when neither precision nor recall can be ignored.
However, F1 should not automatically be treated as the "best" metric. The correct metric depends on what mistakes matter most in the application.
F1 Score Formula
There are two common ways to write the F1 formula.
Formula Using Precision and Recall
F1 = 2 × (Precision × Recall) / (Precision + Recall)
Where:
Precision = TP / (TP + FP)
Recall = TP / (TP + FN)
Formula Using the Confusion Matrix
The same metric can be written directly using true positives, false positives and false negatives:
F1 = 2TP / (2TP + FP + FN)
Where:
TP = True Positive
FP = False Positive
FN = False Negative
Notice something important:
TN does not appear in the F1 formula.
This is one reason F1 can provide a different perspective from accuracy, which includes both true positives and true negatives.
If you need a deeper explanation of TP specifically, see Kovendo's Understanding True Positives in Machine Learning.
How to Calculate F1 Score Step by Step
Let's use a simple classification example.
Suppose a machine learning model is detecting fraudulent transactions.
After evaluating the model, you obtain:
- True Positives = 80
- False Positives = 20
- False Negatives = 10
- True Negatives = 890
The total number of observations is:
80 + 20 + 10 + 890 = 1,000
Step 1: Calculate Precision
Precision is:
Precision = TP / (TP + FP)
Therefore:
Precision = 80 / (80 + 20)
Precision = 80 / 100 = 0.80
So precision is:
80%
This means that 80% of the transactions identified as fraudulent were actually fraudulent.
Step 2: Calculate Recall
Recall is:
Recall = TP / (TP + FN)
Therefore:
Recall = 80 / (80 + 10)
Recall = 80 / 90 = 0.8889
So recall is approximately:
88.89%
The model detected about 88.89% of the actual fraudulent transactions.
Step 3: Calculate F1 Score
Now use:
F1 = 2 × (Precision × Recall) / (Precision + Recall)
Therefore:
F1 = 2 × (0.80 × 0.8889) / (0.80 + 0.8889)
F1 ≈ 0.8421
So the F1 score is approximately:
84.21%
This single number summarizes the balance between the model's 80% precision and approximately 88.89% recall.
Why Does F1 Use a Harmonic Mean?
You might wonder why F1 does not simply calculate the normal arithmetic average:
(Precision + Recall) / 2
The reason is that the harmonic mean gives greater weight to low values.
Consider a model with:
Precision = 95%
Recall = 20%
The arithmetic average would be:
57.5%
But that can make the model appear better balanced than it actually is.
The F1 score is much lower because recall is poor.
This property makes F1 useful when you want both precision and recall to be reasonably strong rather than allowing one metric to compensate excessively for the other.
A useful way to remember it is:
- High precision + high recall = high F1
- High precision + very low recall = low F1
- Low precision + high recall = low F1
F1 Score vs Accuracy
Accuracy answers:
"What percentage of all predictions were correct?"
The formula is:
Accuracy = (TP + TN) / (TP + TN + FP + FN)
F1 asks a different question:
"How well does the model balance precision and recall for the positive class?"
This difference becomes important when classes are imbalanced.
Imagine a dataset containing 10,000 transactions:
9,900 legitimate
100 fraudulent
A model that predicts every transaction as legitimate would achieve:
Accuracy = 9,900 / 10,000 = 99%
That sounds impressive.
But it detects:
0 fraudulent transactions
Its fraud recall is therefore:
0%
Its F1 score for the fraud class would also be 0.
This illustrates why accuracy alone can be misleading for imbalanced classification problems.
The broader confusion matrix guide explains this problem in more detail and shows how precision, recall, specificity and F1 should be considered together.
F1 Score and the Precision-Recall Tradeoff
Precision and recall often change when the classification threshold changes.
Suppose a fraud model produces probabilities:
| Transaction | Fraud Probability |
|---|---|
| A | 0.91 |
| B | 0.82 |
| C | 0.74 |
| D | 0.61 |
| E | 0.43 |
| F | 0.27 |
If the classification threshold is 0.50, transactions A through D may be classified as fraud.
If the threshold is raised to 0.80, only A and B may be classified as fraud.
The result can be:
- Higher threshold → fewer positive predictions → potentially higher precision but lower recall
- Lower threshold → more positive predictions → potentially higher recall but lower precision
The relationship is not guaranteed to move perfectly in opposite directions in every dataset, but changing the decision threshold changes the set of predicted positives and therefore can change precision, recall and F1.
Kovendo's Precision vs Recall in Machine Learning provides a dedicated explanation of this tradeoff and shows how changing a classification threshold affects model evaluation.
When Should You Use F1 Score?
F1 score can be useful when:
1. Classes Are Imbalanced
If one class is much larger than another, accuracy can hide poor minority-class performance.
F1 focuses on precision and recall instead of allowing a large number of true negatives to dominate the metric.
2. Both False Positives and False Negatives Matter
If both types of errors are important, F1 can provide a useful summary.
Examples include:
- Fraud detection
- Spam detection
- Content classification
- Fault detection
- Medical screening
- Customer churn prediction
- Information retrieval
3. You Need a Single Comparison Metric
When testing several classification models, F1 can provide a convenient metric for comparing their precision-recall balance.
For example, you could compare:
- Logistic Regression
- Decision Tree
- Random Forest
- Support Vector Machine
- Neural Network
Kovendo's guide on Random Forest in Machine Learning and Sales Data Analysis provides an example of using Random Forest for classification and model evaluation.
When Should You Not Rely Only on F1?
F1 is useful, but it is not a universal measure of model quality.
Suppose false negatives are far more expensive than false positives.
A medical screening system may prioritize finding as many actual positive cases as possible.
In such a situation, recall may be more important than the overall F1 score.
Conversely, consider a system where false positives create significant operational costs. Precision may deserve more attention.
The key question is not:
"What is the highest F1 score?"
The better question is:
"Which type of model error matters most for this application?"
You should therefore consider F1 together with precision, recall, confusion-matrix counts and the actual consequences of prediction errors.
F1 Score for Imbalanced Datasets
F1 is particularly common in discussions about imbalanced classification.
Suppose:
9,500 samples belong to Class A
500 samples belong to Class B
A model can perform extremely well on Class A while performing poorly on Class B.
Looking only at overall accuracy may hide that problem.
Instead, you can calculate precision, recall and F1 for the minority class.
This allows you to ask:
- How accurately does the model identify Class B?
- How many Class B cases does it miss?
- How many incorrect Class B predictions does it make?
- What is the resulting F1 score?
For serious model evaluation, it is usually better to inspect the complete confusion matrix and class-level metrics rather than relying on a single overall score.
F1 Score in Multiclass Classification
F1 is not limited to binary classification.
Suppose an image classification model identifies:
Cat
Dog
Bird
You can calculate an F1 score for each class.
For example:
| Class | Precision | Recall | F1 |
|---|---|---|---|
| Cat | 0.90 | 0.85 | 0.87 |
| Dog | 0.88 | 0.92 | 0.90 |
| Bird | 0.80 | 0.75 | 0.77 |
The overall multiclass F1 depends on how the individual class scores are averaged.
Macro F1
Macro F1 calculates the F1 score independently for each class and then takes the simple average.
This gives each class equal weight.
It can therefore highlight poor performance on smaller classes.
Weighted F1
Weighted F1 calculates each class's F1 and weights it according to the number of true samples in that class.
Large classes therefore have more influence on the final score.
Micro F1
Micro F1 aggregates the underlying classification outcomes across classes before calculating the metric.
The choice between macro, weighted and micro F1 should depend on what you want the evaluation to represent.
For multiclass problems, always check which averaging method your software or reporting system is using.
F1 Score Example With Two Models
Imagine you are comparing two fraud-detection models.
Model A
Precision = 90%
Recall = 60%
F1:
F1 = 2 × (0.90 × 0.60) / (0.90 + 0.60)
F1 = 72%
Model B
Precision = 75%
Recall = 75%
F1:
F1 = 2 × (0.75 × 0.75) / (0.75 + 0.75)
F1 = 75%
Model B has a slightly higher F1 because its precision and recall are more balanced.
But this does not automatically mean Model B is the right model for every application.
If the business requirement strongly prioritizes precision, the difference between the models should be examined from that perspective.
If missing positive cases is more costly, recall may receive greater importance.
This is why model evaluation should start with the problem itself, not with the metric.
F1 Score From a Confusion Matrix
The easiest way to understand F1 is to trace it back to the confusion matrix.
Suppose:
TP = 180
FP = 50
FN = 20
TN = 750
First calculate precision:
Precision = 180 / (180 + 50) = 78.26%
Then recall:
Recall = 180 / (180 + 20) = 90%
Then:
F1 ≈ 83.8%
These are the same values used in Kovendo's main confusion-matrix guide.
Instead of manually calculating these values every time, you can use the Confusion Matrix Analyzer.
The tool supports binary and multiclass confusion matrices and provides accuracy, precision, recall, F1 score, class-level performance, error analysis and other diagnostic insights. The matrix data is processed in the browser according to the tool page.
F1 Score and Model Explainability Are Different
A high F1 score tells you something about predictive performance.
It does not tell you why the model makes its predictions.
For example:
F1 score: 0.84
This tells you about the balance between precision and recall.
It does not tell you which features caused the model to make those predictions.
That is where explainability methods can become useful.
Kovendo's SHAP Analysis guide explains how SHAP can help investigate which features influence individual predictions and overall model behavior.
A practical evaluation workflow can therefore look like:
Confusion Matrix → Precision & Recall → F1 → Error Analysis → Model Explanation
This separates two important questions:
How well does the model perform?
and
Why does the model behave this way?
How to Improve a Low F1 Score
If your F1 score is low, do not immediately assume that you need a more complicated algorithm.
Start by identifying the problem.
Step 1: Inspect Precision and Recall
A low F1 can result from:
- Low precision
- Low recall
- Both
Find out which one is responsible.
Step 2: Inspect False Positives
If precision is low, investigate why the model is generating too many positive predictions.
Look for:
- Weak features
- Incorrect labels
- Overlapping classes
- Poor decision thresholds
- Data quality problems
Step 3: Inspect False Negatives
If recall is low, investigate the cases the model is missing.
Look for:
- Insufficient training examples
- Minority-class problems
- Weak features
- Classification threshold issues
- Labeling errors
Step 4: Examine the Confusion Matrix
The confusion matrix shows exactly where predictions are going wrong.
Step 5: Test the Classification Threshold
For probability-based classifiers, changing the threshold can alter precision, recall and F1.
Step 6: Improve the Data
Better features, representative training data and higher-quality labels can matter more than simply switching algorithms.
F1 Score and Real-World Machine Learning
F1 becomes especially useful when machine learning moves from experimentation into real applications.
Consider a customer churn model.
The model may predict which customers are likely to leave.
If precision is low, the company may contact many customers who were never going to churn.
If recall is low, the company may miss customers who actually needed intervention.
F1 provides a compact way to evaluate the balance.
But the business should still examine the actual cost of each error.
The same principle applies to:
- Fraud detection
- Spam filtering
- Medical classification
- Predictive maintenance
- Cybersecurity alerts
- Customer churn
- Defect detection
- Document classification
- Recommendation systems
Kovendo's article on How Predictive AI Can Improve Business Value Chains also highlights why model evaluation should ultimately connect technical metrics with real business outcomes.
Common F1 Score Mistakes
Mistake 1: Treating F1 as the Same as Accuracy
F1 and accuracy measure different things.
Mistake 2: Ignoring Class Imbalance
Always inspect class-level results when working with imbalanced datasets.
Mistake 3: Reporting F1 Without Saying Which Average Was Used
For multiclass classification, state whether the reported score is: Micro F1, Macro F1, or Weighted F1.
Mistake 4: Optimizing F1 Without Considering Business Costs
The highest F1 does not necessarily correspond to the most useful operational model.
Mistake 5: Looking at Only One Test Split
A single evaluation split may not represent how the model will behave on new data. Cross-validation and a properly separated test set can provide a more reliable assessment.
Quick F1 Score Cheat Sheet
| Metric | Main Question |
|---|---|
| Accuracy | How many predictions were correct overall? |
| Precision | When the model predicts positive, how often is it correct? |
| Recall | How many actual positive cases did the model find? |
| F1 Score | How well are precision and recall balanced? |
| Specificity | How well does the model identify actual negatives? |
The simplest way to remember F1 is:
F1 = balance between precision and recall.
And the formula is:
F1 = 2 × Precision × Recall / (Precision + Recall)
Frequently Asked Questions
There is no universal F1 score that is considered "good" for every machine learning problem. The acceptable value depends on the dataset, class distribution, application and consequences of false positives and false negatives. A model with an F1 of 0.85 may be useful in one application but insufficient in another. Always compare F1 with precision, recall, confusion-matrix results and the requirements of the specific problem.
F1 and accuracy answer different questions, so neither should automatically be treated as better. Accuracy can be useful when classes are reasonably balanced and different errors have similar importance. F1 can be more informative when class imbalance exists or when both false positives and false negatives matter. In practice, evaluating several complementary metrics usually gives a more complete picture of classification performance.
Conclusion
F1 score is one of the most useful metrics for understanding classification performance because it combines precision and recall into a single measure.
The core formula is:
F1 = 2 × (Precision × Recall) / (Precision + Recall)
Its value becomes especially clear when accuracy does not adequately describe model performance. In imbalanced classification problems, F1 can expose weaknesses that overall accuracy may hide.
But F1 should not be used in isolation.
A strong evaluation process starts with the confusion matrix and then examines:
- True positives
- False positives
- False negatives
- Precision
- Recall
- F1 score
- Class-level performance
- Error patterns
- Business consequences
For multiclass problems, also pay attention to whether you are using macro, micro or weighted F1.
Ultimately, the goal of model evaluation is not simply to produce a high metric. It is to understand whether the model makes useful predictions, what types of errors it produces, and whether those errors are acceptable for the application.
If you already have a confusion matrix, the Kovendo Confusion Matrix Analyzer can help calculate and interpret F1, precision, recall and other classification metrics directly.
Comments
Post a Comment