Mean squared error (MSE) is a loss function that squares the difference (error) between the prediction and the ground truth and averages it over all examples. It is the most basic loss for training regression models, which predict values.
Here is the number of examples, is the model's prediction, and is the ground-truth value. It is 0 when every prediction matches the ground truth and grows as they diverge.
The figure at the top plots the loss of a single example as a function of the error . The MSE curve (solid line) is a parabola with the following characteristics.
- Lenient on small errors: For , the loss is , smaller than the absolute error .
- Harsh on large errors: For , the loss is ; doubling the error quadruples the loss.
For example, in a model that predicts daily temperatures, being off by 1 degree on 4 days and being off by 4 degrees on 1 day both give a total error of 4 degrees. Under MSE, however, the former is and the latter is , showing that MSE strongly dislikes predictions that are far off.

