topskill.dev
CoursesTracks
All courses/Machine Learning FundamentalsPrecision and recall
Understanding prediction errors
5 / 7
← Machine Learning Fundamentals
○What machine learning learns○Features and labels○Training and inference○Regression or classification○The machine learning process○Data quality and coverage○Representing data✦Module Quiz
○Linear regression○Try a tiny linear model○Logistic regression○Nearest neighbors○Decision trees○Random forests○Boosting○Naive Bayes○Support vector machines✦Module Quiz
○Clustering○K-means○Choosing and interpreting clusters○Principal component analysis○Neural networks and deep learning○Self-supervised learning○Transfer learning○Reinforcement learning✦Module Quiz
○Generalization and overfitting○Holding out evaluation data○Data leakage○Baselines○Bias and variance intuition○Reading learning curves✦Module Quiz
○Prediction errors and residuals○Measuring regression error○Squared error and large misses○The confusion matrix●Precision and recall○Try a held-out classifier✦Module Quiz
○Bias and limits○Monitoring and drift○Comparing models for a decision✦Module Quiz
Understanding prediction errors

Precision and recall

Use the previous lesson's late-trip counts: 6 correct warnings, 3 false alarms, and 2 missed late trips. Precision and recall answer different questions about the positive class.

precision=correct warningsall warnings=66+3≈0.67\begin{aligned} \text{precision}&=\frac{\text{correct warnings}}{\text{all warnings}}\\ &=\frac{6}{6+3}\approx0.67 \end{aligned}precision​=all warningscorrect warnings​=6+36​≈0.67​

Precision asks how often a warning is right. Here it is about 67%. The ≈\approx≈ sign means approximately; the decimal is rounded.

recall=correct warningsall actual late trips=66+2=0.75\begin{aligned} \text{recall}&=\frac{\text{correct warnings}}{\text{all actual late trips}}\\ &=\frac{6}{6+2}=0.75 \end{aligned}recall​=all actual late tripscorrect warnings​=6+26​=0.75​

Recall asks how many actual late trips we caught. Here it is 75%. A warning system can have high precision by warning only on a few obvious cases while missing many others.

For fixed scores, lowering a threshold flags more cases: recall cannot fall, but the extra warnings can reduce precision. Precision does not have to move monotonically in every finite dataset. Choose the threshold using validation data and the cost of missed cases versus false alarms.

Neither number is a universal quality score. If no warnings are made, precision has a zero denominator and is undefined under this formula; a reporting tool may adopt a convention. If there are no actual positives, recall has the analogous problem. Always inspect the counts behind a reported metric.

When positives are rare, also inspect how many examples support each fraction. Precision of 100% from one warning is much weaker evidence than the same proportion from many representative warnings. The metric describes the observed sample; it is not a guarantee for the next case.

Check your understanding

Which metric directly measures the fraction of actual late deliveries that receive a warning?

Answer: Recall. Precision instead measures the fraction of issued warnings that are correct.

Fact 1
1 / 1
FACT 1

Recall. Precision instead measures the fraction of issued warnings that are correct.