← AI / ML Foundations
14 / 25
Lesson 14 — Mean squared error
Mean squared error: punish big misses
For number predictions, the standard error measure is MSE (mean squared error): for each example square the difference between prediction and truth, then average. Squaring makes every error positive and makes one big miss count much more than several small ones.
# preds [2, 4], truth [3, 4] -> ((2-3)**2 + 0) / 2 = 0.5
Lower MSE is better; 0 means perfect.
Why it matters: MSE is the "loss" that most regression models minimise during training, and the number you use to compare two models.
Want it another way?
Task
Finish mse(preds, truth). Then the program compares two models and picks the better one.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.