Skip to main content

F1 Score Explained: Formula, Calculation, and Examples

 


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
A0.91
B0.82
C0.74
D0.61
E0.43
F0.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
Cat0.900.850.87
Dog0.880.920.90
Bird0.800.750.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
AccuracyHow many predictions were correct overall?
PrecisionWhen the model predicts positive, how often is it correct?
RecallHow many actual positive cases did the model find?
F1 ScoreHow well are precision and recall balanced?
SpecificityHow 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

What is a good F1 score?

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.

Is F1 score better than accuracy?

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

Popular posts from this blog

Godot, Making Games, and Earning Money: Turn Ideas into Profit

The world of game development is more accessible than ever, thanks to open-source engines like Godot Engine. In fact, over 100,000 developers worldwide are using Godot to bring their creative visions to life. With its intuitive interface, powerful features, and zero cost, Godot Engine is empowering indie developers to create and monetize games across multiple platforms. Whether you are a seasoned coder or a beginner, this guide will walk you through using Godot Engine to make games and earn money. What is Godot Engine? Godot Engine is a free, open-source game engine used to develop 2D and 3D games. It offers a flexible scene system, a robust scripting language (GDScript), and support for C#, C++, and VisualScript. One of its main attractions is the lack of licensing fees—you can create and sell games without sharing revenue. This has made Godot Engine a popular choice among indie developers. Successful Games Made with Godot Engine Several developers have used Godot Engine to c...

Filter Bubbles vs. Echo Chambers: The Modern Information Trap

In the age of digital information, the way we consume content has drastically changed. With just a few clicks, we are constantly surrounded by content that reflects our beliefs, interests, and preferences. While this sounds ideal, it often leads us into what experts call filter bubbles and echo chambers . A study by the Reuters Institute found that 28% of people worldwide actively avoid news that contradicts their views, highlighting the growing influence of these phenomena. Though the terms are often used interchangeably, they differ significantly and have a profound impact on our understanding of the world. This blog delves deep into these concepts, exploring their causes, consequences, and ways to break free. What are Filter Bubbles? Filter bubbles refer to the algorithmically-created digital environments where individuals are exposed primarily to information that aligns with their previous online behavior. This concept was introduced by Eli Pariser in...

Difference Between Feedforward and Deep Neural Networks

In the world of artificial intelligence , feedforward neural networks and deep neural networks are fundamental models that power various machine learning applications. While both networks are used to process and predict complex patterns, their architecture and functionality differ significantly. According to a study by McKinsey, AI-driven models, including neural networks, can improve forecasting accuracy by up to 20%, leading to better data-driven decision-making . This blog will explore the key differences between feedforward neural networks and deep neural networks, provide practical examples, and showcase how each is applied in real-world scenarios. What is a Feedforward Neural Network? A feedforward neural network is the simplest type of artificial neural network where information moves in one direction—from the input layer, through hidden layers, to the output layer. This type of network does not have loops or cycles and is mainly used for supervised learning tasks such as ...

Blue Ocean Red Ocean Marketing Strategy: Finding the Right One

In today's rapidly evolving business world, companies must choose between two primary strategies: competing in existing markets or creating new, untapped opportunities. This concept is best explained through the blue ocean and red ocean marketing strategy , introduced by W. Chan Kim and Renée Mauborgne in their book Blue Ocean Strategy . According to research by McKinsey & Company, about 85% of businesses struggle with differentiation in saturated markets (Red Oceans), while only a small percentage focus on uncontested market spaces (Blue Oceans). A study by Harvard Business Review also found that companies following a blue ocean strategy have 14 times higher profitability than those engaged in direct competition. But what exactly do these strategies mean, and how can businesses implement them successfully? Understanding consumer psychology in marketing is very important. Let’s dive into blue ocean marketing strategy and red ocean strategy, exploring their key differences, rea...

How Adler Psychology Shapes Digital Marketing Strategies?

In today's hyper-connected digital landscape, marketers are constantly searching for deeper insights into consumer behavior. While many turn to the latest technological innovations, there's profound value in revisiting established psychological frameworks—particularly Adler psychology . The pioneering work of Dr. Alfred Adler offers a remarkably relevant lens through which modern digital marketers can understand and influence consumer behavior. This blog explores how Adler psychology principles can revolutionize digital marketing strategies, enhance customer engagement, and drive meaningful conversions in our increasingly complex digital world. The Foundations of Adler Psychology Adler psychology , also known as individual psychology , emerged in the early 20th century when Dr. Alfred Adler broke from Freudian theory to establish his own psychological approach. Unlike Freud's emphasis on unconscious drives, Adler in psychology focused on social connections, the driv...

Echo Chamber in Social Media: The Digital Loop of Reinforcement

In today's hyper-connected world, the term "echo chamber in social media" has become increasingly significant. With billions of users engaging on platforms like TikTok, Instagram, YouTube Shorts, Facebook, and X (formerly Twitter), our online experiences are becoming more personalized and, simultaneously, more narrow. A recent report from DataReportal shows that over 4.8 billion people actively use social media—more than half the global population—making the impact of echo chambers more widespread than ever. This blog explores what an echo chamber in social media is, its psychological and societal impacts, and how users and brands can better navigate this digital terrain. What is an Echo Chamber in Social Media? An echo chamber in social media is a virtual space where individuals are only exposed to information, ideas, or beliefs that align with their own. This phenomenon results from both user behavior and algorithmic curation,...

The Mere Exposure Effect in Business & Consumer Behavior

Why do we prefer certain brands, songs, or even people we’ve encountered before? The answer lies in the mere exposure effect—a psychological phenomenon explaining why repeated exposure increases familiarity and preference. In business, mere exposure effect psychology plays a crucial role in advertising, digital marketing, and product promotions. Companies spend billions annually not just to persuade consumers, but to make their brands more familiar. Research by Nielsen found that 59% of consumers prefer to buy products from brands they recognize, even if they have never tried them before. A study by the Journal of Consumer Research found that frequent exposure to a brand increases consumer trust by up to 75%, making them more likely to purchase. Similarly, a Harvard Business Review report showed that consistent branding across multiple platforms increases revenue by 23%, a direct result of the mere exposure effect. In this blog, we’ll explore the mere exposure effect, provide re...

AI in Medical Imaging: Revolutionizing Diagnosis and Beyond

In the realm of modern healthcare, Artificial Intelligence (AI) has emerged as a powerful ally, particularly in the field of medical imaging. From enhancing diagnostic accuracy to optimizing workflow efficiencies, AI in medical imaging is reshaping how medical professionals diagnose and treat patients. As a PhD researcher or medical doctor, understanding the profound impact of AI in this specialized area is crucial for staying at the forefront of technological advancements in healthcare. Enhancing Diagnostic Accuracy with AI in Medical Imaging AI algorithms have demonstrated remarkable capabilities in analyzing complex medical images such as X-rays, CT scans, MRIs, and ultrasounds. These algorithms can detect subtle patterns and anomalies that might not be immediately apparent to human radiologists, thereby significantly improving diagnostic accuracy. For example, a study published in Nature Medicine showcased how AI-powered systems achieved a diagnostic accuracy comparable to ...

Random Forest in Machine Learning and Sales Data Analysis

In today's data-driven world, businesses increasingly rely on advanced techniques like random forest in machine learning to extract valuable insights from sales data. This powerful algorithm provides robust, accurate predictions, helping organizations make data-driven decisions. According to a study, businesses using machine learning for sales forecasting saw a 20% increase in forecast accuracy. This blog will explore how to apply random forest in machine learning to sales data analysis, including its workings, implementation with Python, and the insights it offers. What is Random Forest in Machine Learning? Random forest in machine learning is a versatile, ensemble-based algorithm that builds multiple decision trees and combines their outputs to improve accuracy and reduce overfitting. Each tree is trained on a random subset of the data, and the final prediction is based on a majority vote (for classification) or the average (for regression). Understanding Random Forest With...

Understanding Average Revenue per User (ARPU), ARPPU & ROI

Imagine you’ve just launched a mobile app startup called StreamNest . At first, everything looks promising, users are signing up, engagement is decent, and your marketing campaigns seem to be working. But when it comes to actual revenue, things feel unclear. Are you really making money? Are your users valuable? Are your investments paying off? This is where metrics like Average Revenue per User , Average Revenue Per Paying User , and ROI step in. These aren’t just numbers—they are decision-making tools that can define whether your business thrives or struggles. If you understand main concepts from Data Analytics Guide then you can win the business growth race with tangible data facts.   In this blog, we’ll walk through these concepts using a simple, engaging story, break down definitions, provide formulas, include tabular data, and clearly explain the differences between these key metrics. “In God we trust, all others must bring data.” — W. Edwards Deming The S...