The Supervised Learning Setup, Loss and Guess Work
On this page 8 headings
Measure how wrong two predictions are
Targets are [0, 1], predictions are [0.2, 0.8]. Here we choose mean squared error, with no extra factor of ½.
Calculate each squared error.
Average over the two examples.
What changed? The loss compresses prediction errors into one number. Summing instead of averaging would give 0.08, so check the question’s convention.
Quick check: If both predictions exactly matched their targets, what would this loss be?
0: both squared errors would be zero.
Swipe long formulas, tables or code sideways to see the rest.
Start here Before learning any weights we need to say clearly what we are learning and how we measure mistakes. Every machine learning problem in this course has the same five parts. Then we try the simplest possible way to learn — guessing — and see why it does not scale.
A single perceptron cannot perfectly classify data that is not linearly separable. “Cannot deal with” means: whatever line it draws, some points end up on the wrong side.
From now on we accept that driving the error to 0 is hard in most cases. Instead we aim for the minimum possible error.
| Part | Meaning | Examples |
|---|---|---|
| Data | n pairs {(xᵢ, yᵢ)} | movie features + like/dislike |
| Model | our guess of how y depends on x | , or , or |
| Parameters | numbers inside the model to learn | w (and W) |
| Learning algorithm | how we change the parameters | perceptron learning algorithm, gradient descent |
| Loss / objective / error function | how wrong the model is; guides the algorithm |
The learning algorithm should aim to minimise the loss function.
Lecture example — movie setup Data: { movie, like/dislike}. Model: probability of liking. Parameters: w. Algorithm: gradient descent. Loss: (squared error). Find the w that makes this smallest.
To keep things simple:
- only one input x,
- is renamed b (bias), as most books do,
- task: predict criticsRating (y) from imdbRating (x).
Model:
Training data: N pairs (x, y). Objective:
minimise
Lecture example — two points Train with (0.5, 0.2) and (2.5, 0.9). We want to find w*, b* such that f(0.5) → 0.2 and f(2.5) → 0.9. In other words: find a sigmoid curve that passes through both points.
Start with a random guess: . How bad is it? (The lecture uses ½ in front, since .)
Step by step:
- 0.9985
- 0.6225
- 0.0941
(The slide rounds f(2.5) to 0.99 and f(0.5) to 0.62.) We want L as close to 0 as possible. So we keep changing w and b by hand:
| w | b | Loss (computed) | Comment |
|---|---|---|---|
| 0.50 | 0.00 | 0.0731 | better than the first guess |
| −0.10 | 0.00 | 0.1481 | worse — went the wrong way |
| 0.94 | −0.94 | 0.0217 | better |
| 1.42 | −1.73 | 0.0029 | much better |
| 1.65 | −2.08 | 0.0003 | almost there |
| 1.78 | −2.27 | 0.0000 | (nearly) perfect |
(The slides show 0.14, 0.0214 and 0.0028 for three of these rows — small rounding differences from the values above.)
The exact best answer can be worked out because means :
- Subtract: , then .
So the guesses were walking towards (1.79, −2.28).
With only 2 parameters we can draw the loss for every (w, b) — this is the error surface. Then just pick the lowest point.
Problems with guessing / plotting everything:
- With many data points and many parameters (real networks have millions), plotting every combination is impossible (intractable).
- Even here, the plot covers only w, b in (−6, +6), not (−∞, +∞).
Geometrically, the guess-work algorithm is just hopping around on this surface. We need a principled way to move downhill to the minimum — that is gradient descent (next page).
In one line: Supervised learning data + model + parameters + learning algorithm + loss; training means finding parameters with the smallest loss, and guessing does not scale.
Exam words: supervised learning, data, model, parameters, learning algorithm, objective/loss/error function, squared error loss, training, error surface, intractable.
- , which part is the parameter?
- (x is the data; the formula is the model.)
