One line, eight days
We have a line with w = 1.20 and b = 10. It is hard to say by eye how close it passes to the dots; we want to measure that with a number.
One day's error
The largest difference is on day 8: 56 were actually sold, the line says 48.40. Error = actual − prediction = 7.60.
All the errors
Each day's error is a dashed line. On a blue line the dot is above the line and the error is positive; on a red line the dot is below and the error is negative.
Why not a sum
If we add the errors as they are, positives and negatives can cancel out: the sum is 23. Even a bad line can give a sum near zero, so the plain sum is not a good measure.
Squaring the errors
Each error is squared. The minus sign goes away and large errors weigh much more: an error of 2 counts as 4, an error of 6 as 36. The squares are the areas of these numbers.
Mean squared error
The mean of the squares is the loss: MSE = 18.82. The smaller the loss, the closer the line passes to the dots. The gauge at the top shows the loss.
The best line
The dashed blue line has the smallest loss for this data: w = 1.59, b = 4.43, loss 4.31. Yours has a loss of 18.82. Drag the rings and try to make the loss smaller.
Why it matters
The loss function is the goal of learning: to learn is to search for the parameters that make the loss smaller. In the next topic least squares finds this line with a formula, and gradient descent finds it step by step.