topskill.dev
CoursesTracks
All courses/Machine Learning FundamentalsMeasuring regression error
Understanding prediction errors
2 / 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

Measuring regression error

Mean absolute error, or MAE, averages the size of the misses without allowing early and late errors to cancel.

MAE=∣y1−y^1∣+∣y2−y^2∣2\text{MAE}=\frac{|y_1-\hat{y}_1|+|y_2-\hat{y}_2|}{2}MAE=2∣y1​−y^​1​∣+∣y2​−y^​2​∣​

This version is for two trips. y1y_1y1​ and y2y_2y2​ are their actual times; y^1\hat{y}_1y^​1​ and y^2\hat{y}_2y^​2​ are their predicted times. The subscripts identify the trips, the hats mark predictions, and the bars mean absolute value. Dividing by 2 averages the two error sizes.

If actual times are 18 and 25 minutes and predictions are 20 and 21, the absolute errors are 2 and 4 minutes. MAE is (2+4)/2=3(2+4)/2=3(2+4)/2=3 minutes. That does not mean every trip misses by three minutes.

For more than two examples, add every absolute error and divide by the number of examples. Each example receives equal weight in this ordinary version. Compute the same measure on the same held-out rows when comparing models.

MAE retains the target's units, making it easier to interpret than an abstract score. It does not express error as a percentage: three minutes can matter differently for a five-minute prediction and a two-hour prediction. The next lesson considers squared error, which emphasizes larger misses.

Choose the measure around the decision. An average alone can hide rare, very large delays; inspect those cases separately and compare the chosen measure with the baseline.

Check your understanding

Why should the signed misses of plus 2 and minus 4 not simply cancel when measuring error size?

Answer: Both are mistakes. Absolute values measure their sizes rather than allowing opposite directions to hide each other.

Fact 1
1 / 1
FACT 1

Both are mistakes. Absolute values measure their sizes rather than allowing opposite directions to hide each other.