Festival Season OfferUp to 25% off on all our programmes — claim it before you enrol
← All Career InsightsData Science

What are precision, recall and F1 score, and when should I use each?

Precision is the share of the model's positive predictions that were actually positive; recall is the share of real positives the model managed to find; F1 score is the balance of the two. Use precision when false alarms are costly, recall when missed cases are costly, and F1 when you need both and the classes are imbalanced, which is exactly when plain accuracy misleads.

Why accuracy alone can fool you

Imagine a fraud model where only 1 in 100 transactions is fraud. A model that predicts "not fraud" every time is 99% accurate and completely useless. Accuracy hides this because it treats every correct answer the same.

Precision, recall and F1 look specifically at how the model handles the class you care about. They are among the most common topics in data science interviews for exactly this reason.

The confusion matrix in four boxes

Every classification metric is built from these four counts.

True positive (TP)

The model said positive and it was positive. A fraud transaction correctly flagged.

False positive (FP)

The model said positive but it was negative. A genuine customer's payment wrongly blocked.

False negative (FN)

The model said negative but it was positive. A fraud transaction that slipped through.

True negative (TN)

The model said negative and it was negative. A genuine payment correctly allowed.

The formulas, in plain words

Each metric answers a different question:

  • Precision = TP / (TP + FP) – of everything the model flagged, how much was right?
  • Recall = TP / (TP + FN) – of everything that should have been flagged, how much did the model find?
  • F1 score = 2 × precision × recall / (precision + recall) – one number that is only high when both are high.
  • Accuracy = (TP + TN) / all predictions – useful only when the classes are roughly balanced.

How to choose the right metric for a project

Start from the business cost of each kind of mistake, not from the metric.

  1. Name the positive class

    Decide what "positive" means: fraud, churn, disease, spam. All the metrics are about that class.

  2. Compare the cost of mistakes

    Ask which hurts more: a false alarm or a missed case. Blocking a good customer and missing a disease have very different costs.

  3. Pick the main metric

    Favour precision when false alarms are expensive, recall when misses are expensive, and F1 when both matter.

  4. Tune the threshold

    Most models output a probability. Moving the cut-off from 0.5 trades precision for recall; plot both to find the right point.

  5. Report more than one number

    Share the confusion matrix with your main metric, so others can see exactly where the model goes wrong.

Quick answers about precision, recall and F1

Short answers to the questions learners search for most.

What is the difference between precision and recall?

Precision measures how many of the model's positive predictions were correct. Recall measures how many of the actual positives the model found. Improving one often lowers the other.

When should I use F1 score instead of accuracy?

Use F1 when classes are imbalanced, such as fraud or rare disease detection, and when both false positives and false negatives matter. Accuracy can look high on imbalanced data even for a useless model.

What is a good F1 score?

It depends on the problem and the baseline. Compare against a simple model and against the cost of mistakes in that domain rather than chasing a fixed number.

How do I calculate precision and recall in Python?

Use scikit-learn: precision_score, recall_score and f1_score from sklearn.metrics, or classification_report to see all of them per class at once.

What is the precision-recall trade-off?

Raising the model's decision threshold usually increases precision and lowers recall, and lowering it does the opposite. You choose the threshold that best fits the business cost of each error.

Go further with model evaluation

See where evaluation sits in the syllabus, or read the guides that build on it.

See the Data Science programmeSee the Python Programming moduleRead: supervised vs unsupervised learningRead: detect and prevent data leakageRead: prepare for a data science interviewBrowse all Career Insights

Evaluate one imbalanced dataset

Train a simple classifier on a public fraud or churn dataset, print the confusion matrix and classification report, then move the threshold and watch precision and recall change. Explaining that trade-off clearly is a standout interview answer.

Train for a Data Science role

The same programme, duration and fees, with the learning path built around one job role.

Data ScientistML EngineerData AnalystBI AnalystData EngineerAnalytics Consultant

Learn model evaluation with a mentor

Ask our team how the Data Science programme in Madhapur, Hyderabad teaches machine learning, evaluation and real projects.

Our admissions team will call you back within 90 minutes.
AddressHouse No. 3-535, 3rd Floor A Section, LR Towers, 100 Feet Road, Ayyappa Society, Madhapur, Hyderabad, Telangana 500081