Precision, Recall and F1
Precision, recall and F1 in plain words, with a card fraud example, why accuracy misleads and the trade-off, for your AI interview.
In short
Precision is the share of flagged cases that were right. Recall is the share of real cases the model caught. F1 is one score that combines the two, so a weak side can't hide behind a strong one.
10 min readBeginnerVery common · estimateFacts checked 26 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
Precision is how many of my flags were right. Recall is how many of the real cases I caught. F1 combines the two into one number, and it drops when either side is weak. On a made-up fraud model, precision was 66.7 percent, recall 80 percent and F1 72.7 percent. I never judge a rare-event model on accuracy alone.
Precision, recall and F1 are three scores for a yes or no model, such as a fraud alert or a spam filter. Precision asks: of the payments I flagged, how many really were fraud? Recall asks: of all the real frauds, how many did I catch? F1 gives one number that combines the two, so a model can't score well by being strong on only one side.
Here is a case from a mid-size bank's card team, with made-up numbers. The model checked 10,000 payments, and 100 were real fraud. It flagged 120. Eighty flags were right, and 40 were genuine customers who got blocked. So precision is 80 out of 120, about 67 percent. Recall is 80 out of 100, which is 80 percent. The model missed 20 frauds, and the F1 score is about 73 percent.
Accuracy looks excellent here, at 99.4 percent. But a model that never flags anything scores 99 percent too, and it catches no fraud at all. When one class is very rare, accuracy hides the misses, so I judge the model on recall and F1 for fraud.
The two scores pull against each other. Raise the threshold and the model flags less, so precision usually rises and recall falls. F1 is a harmonic mean, an average that drops towards the weaker number. I would set the threshold from what a missed fraud costs the bank against what a blocked customer costs, then report all three numbers.
What are precision, recall and F1, in plain words?
Think about a triage nurse at a busy emergency desk. She flags patients who may need a doctor now. Some flags are right. Some are false alarms. And some patients who needed a doctor get past her. Precision and recall measure those two kinds of mistake.
Precision is about the flags: of everything flagged, how much was right? Recall is about the real cases: of everything that was real, how much did the model find? F1 is one number that combines them, so a model can't hide a weak side behind a strong one.
These scores are for yes or no models, called binary classifiers. The class you care about is called the positive class. For a fraud model, the positive class is fraud, and the genuine payments are the negatives.
Key words
- Positive
- The class you are looking for, such as fraud.
- True positive (TP)
- A flag that was right. A real case the model caught.
- False positive (FP)
- A flag on a genuine case. A false alarm.
- False negative (FN)
- A real case the model missed.
- F1
- One score that combines precision and recall, from 0 to 1.
How do you calculate them, with real numbers?
Start from the confusion matrix, the table of right and wrong calls. Then divide. The numbers below are made up for a card-fraud model at a mid-size bank, checked on 10,000 payments with 100 real frauds.
From 120 flags to one F1 score
The model's results
80 real frauds caught
true positives: the flag was right
40 genuine blocked
false positives: a customer blocked
20 frauds missed
false negatives: fraud got through
Two ratios
Precision 66.7%
of all flags, how many were right
Recall 80.0%
of all frauds, how many were caught
F1 score 72.7%
one score, a harmonic mean
- 1The 80 right flags are the top of precision.
- 2The 40 wrong flags add to the bottom, so precision drops.
- 3The same 80 are the top of recall.
- 4The 20 misses add to the bottom, so recall drops.
- 5Precision goes into the F1 score.
- 6Recall goes into the F1 score too.
- 1
Precision = TP / (TP + FP)
80 / (80 + 40) = 66.7%. Of the 120 flags, 80 were right.
- 2
Recall = TP / (TP + FN)
80 / (80 + 20) = 80.0%. Of the 100 real frauds, 80 were caught.
- 3
F1 = 2 × TP / (2 × TP + FP + FN)
160 / 220 = 72.7%. This is the harmonic mean of 66.7% and 80%, an average that leans towards the smaller number.
Here is the same calculation in plain Python. It uses only the standard library, so you can run it anywhere.
# A card-fraud model checked on 10,000 payments (made-up numbers).
# Positive = "this payment is fraud".
TP = 80 # fraud, flagged: the flag was right
FP = 40 # genuine, flagged: a customer is blocked
FN = 20 # fraud, not flagged: the fraud got through
TN = 9860 # genuine, not flagged
precision = TP / (TP + FP)
recall = TP / (TP + FN)
f1 = 2 * precision * recall / (precision + recall)
accuracy = (TP + TN) / (TP + TN + FP + FN)
print(f"precision {precision:.1%}")
print(f"recall {recall:.1%}")
print(f"f1 {f1:.1%}")
print(f"accuracy {accuracy:.1%}")
# A model that never flags anything: every fraud is missed.
print(f"never flags: accuracy {9900 / 10000:.1%}, recall {0:.1%}")Output
precision 66.7% recall 80.0% f1 72.7% accuracy 99.4% never flags: accuracy 99.0%, recall 0.0%
Why is accuracy not enough for fraud?
Accuracy counts every right call, flagged or not. Fraud is rare, so accuracy stays high even when the model misses most frauds. A model that never flags anything scores 99.0% accuracy on the same 10,000 payments, with recall of 0.0%. Our model scores 99.4% accuracy with recall of 80.0%. The accuracy gap is small. The recall gap matters most here.
Accuracy hides the misses
Baseline: always legit
Accuracy 99.0%
99 of every 100 payments look right
Recall 0.0%
catches none of the frauds
Our model
Accuracy 99.4%
only a little higher
Recall 80.0%
catches 80 of the 100 frauds
Judge on recall and F1
accuracy alone hides the misses
- 1The baseline looks fine on accuracy but catches no fraud.
- 2Our model's recall shows how many frauds it finds.
Tip
Asked about accuracy on an imbalanced problem? Say it can look excellent while the model catches nothing, then name the metric that matches the cost of a miss.
What is the trade-off between precision and recall?
Most models give each case a score, and a threshold turns that score into a yes or no. Raise the threshold and the model flags less: precision usually rises and recall falls. Lower it and recall rises, but more genuine payments get blocked. Google's crash course says it plainly.
“As a result, precision and recall often show an inverse relationship, where improving one of them worsens the other.”
Google Machine Learning Crash Course
F1 is a harmonic mean, so it sits close to the weaker of the two. Google puts it this way: when precision and recall are far apart, F1 is similar to whichever is worse. A model with precision 0.9 and recall 0.1 gets an F1 of only 0.18, even though its precision looks strong.
Which side matters more is a business call. A missed fraud costs money, and a blocked customer costs a call and some goodwill. Google also notes that when both true positives and false positives are 0, precision comes out as NaN, which means not a number. scikit-learn returns 0 with a warning instead. So check the counts before you trust a score.
How would you choose the metric for a sepsis alert?
A hospital wants an early warning for sepsis. A missed case is the costly error, so recall comes first. But every false alarm adds work for nurses.
So I would fix the recall target first, then check precision at that threshold, and track how many alerts each nurse gets per shift. Say it in one line: recall sets the safety floor, precision keeps the alerts trusted, and F1 is only a quick summary.
What does the interviewer want to hear?
A strong answer covers
- Precision: of the flags, how many were right. Recall: of the real cases, how many were found.
- A worked example with real counts, read from a confusion matrix.
- Why accuracy misleads when one class is rare.
- F1 as a harmonic mean, so a weak side pulls it down.
- The threshold trade-off, and the business picks the balance.
- What a false positive and a false negative cost in the real world.
Common traps
Trap"Accuracy is the best metric for this."
BetterOn rare events accuracy can look great while the model finds no positives. Use recall and F1.
Trap"Precision and recall are the same thing."
BetterThey divide by different things. Precision divides by the flags, recall divides by the real cases.
Trap"F1 is just the average of the two."
BetterIt is a harmonic mean, which sinks towards the weaker side, so one low score is hard to hide.
Can you spot the problem?
Spot the problem
A colleague shows this result for the fraud model. Which summary should make you ask for recall before it ships?
Quick check
A fraud team says the model catches 90% of real frauds. Which score is that?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
- Q421ROC-AUC vs PR-AUC?Coming soon
- Q422Train/validation/test splits?11 min
- Q424What is data leakage?Coming soon
- Q425How do you handle class imbalance?Coming soon
- Q430What is a confusion matrix?Coming soon
- Q436How do you tune hyperparameters?Coming soon
Learn it in depth
Last updated on 26 November 2026
Building a fraud, alert or triage model that must catch the rare cases?
I design and build AI products and agents, including the evaluation behind them. Book a short call and tell me what your model has to catch and what a false alarm costs.