topskill.dev
CoursesTracks
All courses/Machine Learning FundamentalsPrediction errors and residuals
Understanding prediction errors
1 / 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

Prediction errors and residuals

For regression, compare each prediction with its observed target before summarizing errors. A residual is the observed value minus the prediction. The term is often used for fitted training examples; we use the same subtraction for errors on held-out examples.

r=y−y^r=y-\hat{y}r=y−y^​

Here rrr is the signed difference, yyy is the observed target, and y^\hat{y}y^​ is the prediction. The hat marks an estimate. Positive rrr means the prediction was too low; negative rrr means it was too high.

For an actual time of 18 minutes and a prediction of 20, r=18−20=−2r=18-20=-2r=18−20=−2 minutes. For an actual time of 25 and a prediction of 21, r=25−21=4r=25-21=4r=25−21=4 minutes. The first prediction is two minutes too high; the second is four minutes too low.

The signs are useful when checking whether a model tends to overpredict or underpredict. Their magnitudes describe how far off the predictions are. Simply averaging signed differences lets opposite errors cancel: predictions two minutes too high and two minutes too low have an average signed error of zero, despite both being wrong.

A residual plot places a signed difference against an input or prediction. A visible trend can suggest missed structure, and a wider spread in one region suggests less consistent errors there. These patterns support investigation; they do not identify a unique cause by themselves. The next lessons summarize magnitudes without cancellation.

Check your understanding

With the convention r=y−y^r=y-\hat{y}r=y−y^​, what does a positive residual mean?

Answer: The observed value exceeds the prediction, so the model underpredicted.

Fact 1
1 / 1
FACT 1

The observed value exceeds the prediction, so the model underpredicted.