In supervised learning a model maps inputs to predictions, and training chooses its parameters to minimize the average loss on labeled examples. The loss encodes what counts as a good prediction, and choosing it is one of the most consequential modeling decisions.
We will compute squared and absolute error and finish with what each loss rewards.
Step 1: Squared and absolute error
For a prediction ŷ of a numeric target y, the squared error is (ŷ − y)², and the mean squared error (MSE) averages it over examples. Squaring makes large mistakes count far more than small ones: halving every error divides the MSE by 4, and one error of 4 costs as much as sixteen errors of 1. The absolute error |ŷ − y| grows only linearly, so the mean absolute error (MAE) is less dominated by a few large mistakes. Two models with errors (1, 1, 1, 1) and (0, 0, 0, 4) have the same MAE, 1, but MSEs of 1 and 4.
Step 2: What each loss rewards
The difference shows clearly in the simplest model, a single constant prediction c for every example. The MSE is minimized by the mean of the targets, the MAE by the median. For targets (1, 1, 4, 6, 35), the mean is 9.4, pulled up by the outlier 35, while the median is 4. So squared error chases outliers, and one huge outlier can drag the fit far from most of the data; absolute error is robust to them. Choosing a loss is choosing which kind of typical value the model aims for.