Lesson 1 · Unit 04
Loss and descent
Measure how wrong, then step downhill
What you practise
- Mean squared error, a loss surface, one step of gradient descent by hand, local minima, why features get scaled
Try a question from this lesson
Pick one
True prices: 100, 200, 300. Model A predicts 110, 190, 310. Model B predicts 100, 200, 240. If one big miss should count for more than a few small ones, which is worse?
Hint
Square each error before you add them up, and compare the totals.
Correct answer
B: one miss of 60 outweighs three of 10
Why
Squared errors: A has 100 + 100 + 100 = 300, B has 0 + 0 + 3,600. Squaring makes the miss of 60 count 36 times as much as a miss of 10. Counting wrong predictions would have blamed A.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Mean squared error
A loss is one number that says how wrong the model is. Training means making it small.
Mean squared error (MSE): take each prediction minus its target, square it, and average.
Squaring does two jobs. Errors of +10 and -10 cannot cancel, and large errors dominate.
import numpy as np
y = np.array([100, 200, 300])
pred = np.array([110, 190, 310])
mse = ((pred - y) ** 2).mean()
print(mse) # 100.011 more exercises in the app
- 3× type the answer
- 4× multiple choice
- 1× fill the blanks
- 1× true or false
- 1× order the lines
- 1× match the pairs
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.