← Back to the track

Learn machine learning · part 4 · session 6

Where lines fail

Four points, two of them on opposite corners. No setting of a single linear score separates them, and one computed column fixes it.

After this session you will be able to say what a single straight line cannot do, and what one constructed column buys.

xor.wallSession 4.6About 20 minutesYour check: predict results on new examples

To pass: call two of three candidate features correctly before the engine adds each one and fits.

01 · The question

Four points. Two of them are class one and they sit on opposite corners. This pattern has a name, XOR: class 1 when exactly one of the two inputs is on.

Take the three sliders from 4.1, the two and the , and try to place a line with all the ones on one side. Separable means a single straight line can be drawn with all the class-1 points on one side of it. Give it a real minute, because the minute is the point of the session: the failure here is not a matter of effort or of a better search.

Then there is a button that adds one new column computed from the two you already have, and the same line succeeds immediately. Before you press it, say what that column gives the model that x1 and x2 do not.

The four corners

x1x2label
000
011
101
110

02 · Predict

Before anything runs

The button adds the column x1 * x2. What does it buy?

The button adds the column x1 * x2. What does it buy?

Choose something first.

03 · Try it

Try it with the sliders

The three numbers

-3.0 to 3.0
-3.0 to 3.0
-3.0 to 3.0

w1 1.0, w2 1.0, b -0.50. 1 of 4 corners wrong. Best so far 1 of 4.

computed in this browserthe four corners

1 of 4 on the wrong side

x1 runs 0.00 to 1.00 left to right, x2 runs 0.00 to 1.00 bottom to top. A ring is label 0, a filled square is label 1, and a larger ring around a point marks it on the wrong side of the line.

Settings recorded: 0. Best reached: none yet

The lift

illustrativethe 4.6 corners and the hand setting

Flat, and every angle of line leaves a corner wrong.

The new column gives the four corners different heights, and once they have different heights a flat cut can separate them.

The four inequalities

One line per corner, written from the class it has to land in. Mark each one, then put them together.

At the corner (0, 0) both inputs are zero, so the score is just b. That corner has to be class 0, which means the score has to be below zero. So b < 0. The other three work the same way.

The score is s(x) = w1*x1 + w2*x2 + b. Mark each line true or false.

From (0, 0), class 0: b < 0
From (0, 1), class 1: w2 + b > 0
From (1, 0), class 1: w1 + b > 0
From (1, 1), class 0: w1 + w2 + b > 0

Mark all four first.

Add the column

Run it on the noisy cloud

Two hundred points around the same four corners, with a standard deviation of 0.15. Seventy percent train, the rest held out.

trained in this browserfitLogistic, 600 steps, seed 7

04 · Compare

Add the column and fit on the cloud, and the verdict lands here.

05 · Check your understanding

Your check: predict results on new examples

not yet

Two of three: for each candidate feature, call whether it makes the four corners separable by a line or changes nothing, before the engine adds it and fits on the four corners.

Variant 1 of 3

Add the column x1 + x2.

Call it before you run it.

Variant 2 of 3

Add the column x1 ** 2.

Call it before you run it.

Variant 3 of 3

Add the column abs(x1 - x2).

Call it before you run it.

Called 0 of 3 variants so far.

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 AND: 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.

This one stays on the shelf as a record of the session. The capstone's second brief is text, which has no x1 times x2 to construct, so nothing later reads it into a slot.