Learn machine learning · part 4 · session 1
The dot product is a score
Every model from here to the end of the track computes a score the same way. This session is that sum, by hand and then on sixty generated points.
After this session you will be able to look at a set of weights and a bias and say which side of the line any row falls on, and why.
To pass: three hand-computed dot products right without the working shown, and a setting of the three sliders that puts none of the sixty points on the wrong side.
01 · The question
Every model from here to the end of the track computes a score the same way. Multiply each input by a , add them up, add a , and read the sign. That sum has a name, and the name is the only difficult part of it: it is a .
A weight says how much one input counts, and how it counts: positive pushes the score up, negative drags it down. The bias is a fixed amount added no matter what the inputs are, like a starting handicap.
On this page the score is drawn as a line: on one side the score is positive, on the other it is negative, and the line itself is where the score is zero. Three sliders move that line. Before you touch them, say what happens to the line when the bias goes up and both weights stay where they are.
02 · Predict
Before anything runs
Raise the bias b from 0 to 1 with w1 and w2 unchanged. What happens to the boundary line?
Choose something first.
03 · Try it
Three dot products, by hand
The score is s = w1 * x1 + w2 * x2 + b, and the predicted class is 1 when s is above zero and 0 otherwise. Enter each score, then call its class.
A score, built
illustrativeexercise ATwo inputs: x1 = 3 and x2 = 4.
Exercise A: w1 2, w2 -1, b 0.5, x1 3, x2 4
To two decimals.
Attempts: 0
Exercise B: w1 2, w2 -1, b 0.5, x1 1, x2 3
To two decimals.
Attempts: 0
Exercise C: w1 -0.5, w2 1.5, b -2, x1 4, x2 2
To two decimals.
Attempts: 0
Read the boundary as a line
With A and B's weights loaded, the score line 2 * x1 - 1 * x2 + 0.5 = 0 rearranges to x2 = 2 * x1 + 0.5. What is x2 at x1 = 1.5?
Move the x1 term and the 0.5 across: -x2 = -2 * x1 - 0.5. Multiply both sides by -1: x2 = 2 * x1 + 0.5. That is a line: slope 2, crossing at 0.5.
To two decimals.
Attempts: 0
Move the line onto the data
Sixty points from a generated shape, thirty in each class, with a corridor kept clear down the middle so a separating line exists. Move the three numbers until none of the points is on the wrong side, then record the setting.
It opens badly on purpose. Get it under twenty first, then under five.
The three numbers
w1 -1.00, w2 1.00, b 0.50. Boundary passes through (0, -0.50) with slope 1.00. 43 of 60 points on the wrong side.
43 of 60 on the wrong side
x1 runs -2.27 to 2.86 left to right, x2 runs -1.92 to 1.92 bottom to top. A ring is class 0, a filled square is class 1, and a larger ring around a point marks it on the wrong side of the line.
w1 -1.00, w2 1.00, b 0.50. Boundary passes through (0, -0.50) with slope 1.00. 43 of 60 points on the wrong side.
Show the first eight points as numbers
| point | x1 | x2 | actual class | predicted class |
|---|---|---|---|---|
| 1 | -0.26 | -1.03 | 0 | 0 |
| 2 | 1.07 | 1.24 | 1 | 1 |
| 3 | -1.56 | -0.59 | 0 | 1 |
| 4 | 1.17 | 0.65 | 1 | 0 |
| 5 | -2.19 | -0.30 | 0 | 1 |
| 6 | 2.04 | 1.71 | 1 | 1 |
| 7 | -1.72 | -0.96 | 0 | 1 |
| 8 | 2.38 | 0.85 | 1 | 0 |
Every point, with its own arithmetic. Move through them with Tab, or hover one.
The other 54 points
04 · Compare
Record a setting and the verdict lands here, against the position you took above.
05 · Check your understanding
Your check: an outcome you produce
not yetBoth: the three dot products and their classes right without the working shown, and a recorded setting with 0 of 60 on the wrong side.
Not met yet. Keep working the session.
Where you are
- Hand computations right without the working shown: 0 of 3.
- Recorded setting: none yet
Ask for a hint
Rungs open as you run the session, not as time passes. You have run it 0 times.
1. A question: available after 3 evaluated runs.
2. A narrowing: available after 5 evaluated runs.
3. A worked fragment, on a different set: available after 7 evaluated runs.
4. The answer: available after 9 evaluated runs.
Save your takeaway
Your takeaway
Edit it into your own words, or keep the line as it is.