Metrics & Evaluation

Precision, Recall & F1

Understanding the difference between catching every positive case and avoiding false alarms.

🟢 beginner4 min readmetricsmust-know
Precision measures how often your model is right when it flags something as positive. Recall measures how many of the actual positive cases your model managed to find. Raising precision usually lowers recall and vice versa. Choosing which metric matters most comes down to understanding which type of mistake causes more real world harm.

Precision and Recall Explained Simply

Imagine you are fishing with a net:

  1. Precision: Out of all the fish you caught in your net, what percentage are actually the target fish you wanted? High precision means very few unwanted items ended up in your net.
  2. Recall: Out of all the target fish swimming in the lake, what percentage did your net manage to catch? High recall means very few target fish escaped.

The Simple Math

Precision = True Positives / (True Positives + False Positives)

Recall = True Positives / (True Positives + False Negatives)

F1 Score = 2 * (Precision * Recall) / (Precision + Recall)

Precision looks at everything your model flagged positive. Recall looks at everything that was actually positive in reality.

The Tradeoff and Thresholds

Most classification models output a confidence probability number between 0 and 1.

Changing the decision threshold changes your metrics:

  1. Lowering the threshold flags more items. Recall goes up, but precision goes down because you get more false alarms.
  2. Raising the threshold flags fewer items. Precision goes up because you are very pick, but recall goes down because you miss things.

You choose this threshold based on business needs rather than defaulting to 0.5.

Which Metric Matters More?

Ask yourself which error hurts more in your application.

  1. Cancer Screening: Missing a tumor is dangerous. Optimize for Recall. A false alarm just means one extra follow up test.
  2. Spam Filtering: Deleting an important real email is terrible. Optimize for Precision. It is better to let a little spam into the inbox than delete a real message.
  3. Automated Account Bans: Banning an innocent user destroys trust. Optimize for Precision.

Say this out loud

Precision tells me how often the model is right when it makes a positive claim. Recall tells me what fraction of real positive cases the model managed to find. Which one to optimize depends on which mistake costs more in the real product. If missing a case is dangerous, I focus on recall. If false alarms destroy user trust, I focus on precision.

Followups to expect

  1. Does bagging lower bias or variance? Bagging lowers variance by averaging predictions from many independent models. Boosting lowers bias by building models step by step.
  2. Why use macro versus micro averaging in multiclass problems? Macro averaging treats all classes equally regardless of size, which is great when rare classes matter. Micro averaging pools all predictions globally, which is dominated by large classes.

Check yourself

Question 1 of 3

A model flags 100 transactions as fraud and 30 of them are actually fraud. There were 60 total frauds in the dataset. What are precision and recall?

More in Metrics & Evaluation

See all →
Why Accuracy Lies4 minROC-AUC vs PR-AUC4 minData Leakage4 min