Calculating Mean Squared Error
Calculate MSE step by step with five house-price predictions.
Calculating Mean Squared Error explained visually
Follow five house-price errors through squaring, averaging, and a final MSE value.
What you will learn
Measure numerical prediction errors and compare MSE, MAE, and Huber loss.
Start with prediction errors
Subtract each real value from its prediction. Positive and negative errors show opposite directions, but both still represent mistakes.
Square every error
Squaring prevents positive and negative errors from cancelling and gives larger mistakes greater influence.
Average the squared errors
Add all squared errors and divide by the number of examples. The result is Mean Squared Error.
Track improvement
MSE uses squared units, so its trend usually matters more than its isolated value. Falling validation loss can indicate improving predictions.
Quick check: test your understanding
Why square the errors?
To prevent opposite errors from cancelling and to emphasize larger mistakes.
How is MSE completed?
Add the squared errors and divide by the number of examples.
What usually matters during training?
Whether MSE decreases on appropriate data.
Accessible referenceLesson 8 transcript356 words · Matches the published narration and captionsOpen transcript
In Lesson 7, Maya predicted that a house would sell for three hundred thousand dollars. The real price was two hundred eighty thousand dollars. We called the difference an error. Now let's calculate Mean Squared Error step by step and see exactly what that number means.
Imagine that our neural network predicts the prices of five houses. For the first house, it predicts three hundred thousand dollars. The real price is two hundred eighty thousand. The error is twenty thousand dollars. For the second house, the prediction is three hundred fifty thousand dollars, but the real price is three hundred twenty thousand. The error is thirty thousand dollars.
For the third house, the prediction misses by ten thousand dollars. For the fourth house, it predicts thirty thousand dollars below the correct price. For the fifth house, it predicts twenty thousand dollars below the correct price. Our five errors are positive twenty thousand, positive thirty thousand, positive ten thousand, negative thirty thousand, and negative twenty thousand dollars.
If we simply added them, the positive and negative errors would cancel each other. The result could look perfect even though every prediction was wrong. Mean Squared Error prevents that problem by squaring every error. Twenty thousand squared is four hundred million. Thirty thousand squared is nine hundred million.
Ten thousand squared is one hundred million. Negative thirty thousand squared also becomes nine hundred million. And negative twenty thousand squared becomes four hundred million. Add these values together and we get two point eight billion. Divide by five, because we evaluated five houses, and the Mean Squared Error is five hundred sixty million dollars squared.
That number may look unusual because the unit is squared. During training, however, we normally care more about how it changes. If the loss decreases from five hundred sixty million to three hundred million, and then to one hundred million, the model is moving closer to the correct prices.
Mean Squared Error gives the training process one clear score to minimize. But squaring errors also creates an important side effect: large mistakes can become extremely powerful. That is what we will explore in Lesson 9.