S1415 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

S14 · Lesson 15 · Linear classification

Linear discriminants and the geometry of their decision boundaries, the signed distance to a hyperplane, Fisher's discriminant that projects onto the direction separating classes best, and the perceptron with its convergence bound

The simplest classifier draws a straight line (or a flat hyperplane) through feature space and calls one side positive. How to place it is the interesting part. Fisher's 1936 answer was to look for the direction along which the two classes' projections are as far apart as possible relative to their spread, a direction that often isn't the one joining the class means. Rosenblatt's perceptron took the opposite approach, nudging the line every time it made a mistake, and was guaranteed to stop if any line could separate the data.

  • Two classes in two dimensions with means differing by (2, 2) and a shared within-class covariance with variances 1 and 4. Project onto a direction at angle θ and measure the separation J(θ)=(Δm along θ)2/(spread along θ).
  • Projecting along the line between the means (45°) gives J = 3.2; Fisher's direction, tilted toward the low-variance axis, gives J = 5.
  • Change the variances to see the best direction move.

Predict

A linear classifier computes 𝐰T𝐱+w0 with 𝐰 = (3, 4) and w0 = −5. How far is the point (3, 1) from its decision boundary?

Name it

Linear discriminants

A two-class linear discriminant assigns 𝒞1 when y(𝐱)=𝐰T𝐱+w0>0. The boundary is a hyperplane perpendicular to w, at distance −w0/‖𝐰‖ from the origin, and y(𝐱)/‖𝐰‖ is a point's signed distance from it. K classes use K functions and pick the largest.

Fisher's discriminant

Project onto a direction w. With class means 𝐦1, 𝐦2 and within-class scatter SW, the separation

J(𝐰)=(𝐰T(𝐦2−𝐦1))2𝐰TSW𝐰

is largest for 𝐰∝SW−1(𝐦2−𝐦1), where J=Δ𝐦TSW−1Δ𝐦. In one dimension, J is the squared difference of projected means over the sum of projected variances.

The perceptron

With targets tn=±1, cycle through the data and, whenever tn𝐰T𝐱n≤0 (a mistake), update 𝐰←𝐰+ηtn𝐱n. If the data are linearly separable with margin γ by a unit vector, and every ‖𝐱n‖≤R, it converges after at most (R/γ)2 mistakes. If they aren't separable, it never settles.

Worked example

Find Fisher's direction and its separation for the sim's classes (Δm = (2, 2), SW = diag(1, 4)).

Show the solution
  1. Fisher's direction. SW−1Δ𝐦=(2,0.5) at an angle of tan−1⁡(0.25) = 14.0° from the first axis.
  2. Separation. J=22/1+22/4=5
  3. Along the means' own direction. At 45°: J=(4/2)2(1+4)/2=3.2 Ignoring the spread wastes separation.

Answer Fisher's direction is (2, 0.5), 14.0° from the first axis, with a separation J = 5, against 3.2 along the means' own direction.

Worked example

A perceptron with w = (1, −2) and η = 0.5 misclassifies x = (2, 1) with t = +1. What's w after the update? And how many mistakes can it make on data with R = 5 and margin 0.5?

Show the solution
  1. Update. 𝐰=(1,−2)+0.5×(+1)×(2,1)=(2,−1.5)
  2. Check the output. Its output on x rises from 0 to 2.5, now correct.
  3. Mistake bound. (5/0.5)2=100 mistakes before it finds a separating line.

Answer after the update w = (2, −1.5), and on that data it can make at most 100 mistakes.

Worked example

Two classes have a within-class covariance of [2112]. Find Fisher's separation when their means differ by (1, 1), and when they differ by (1, −1).

Show the solution
  1. Invert the covariance. SW−1=13[2−1−12]
  2. Means differing by (1, 1). SW−1Δ𝐦=13(1,1)J=Δ𝐦TSW−1Δ𝐦=2/3
  3. Means differing by (1, −1). SW−1Δ𝐦=(1,−1)J=2 three times better, though both mean differences are the same length.
  4. Why. The noise is correlated along (1, 1), so a difference across that direction stands out against little noise; Fisher's direction finds that automatically.

Answer the separation is J = 2/3 for means differing by (1, 1), and J = 2 for (1, −1).

Check

A linear classifier has w = (1, 2) and w0 = 1. What's the signed distance of the point (4, 0) from its boundary?

Check

Two classes project onto a line with means 1 and 4 and variances 2 and 3. What's Fisher's separation J?

Check

Class means differ by (1, 1) and the within-class scatter is diagonal with variances 4 and 9. At what angle from the first axis is Fisher's direction?

Check

With the same classes (Δm = (1, 1), variances 4 and 9), what separation does Fisher's direction achieve?

Check

A perceptron with w = (1, −2) and learning rate 0.5 updates on the misclassified point (3, −1) with target 1. What's the new second component of w?

Check

Separable data lie within radius 5 with margin 0.1. At most how many mistakes does the perceptron make?

Check

Two classes share a within-class covariance [accb] with a = 2, b = 1.5, c = 0.9, and their means differ by (2, −1.5).

(a)

What separation J does Fisher's direction achieve?

(b)

What separation would projecting onto the mean difference itself give?

Check

A linear classifier has weights (a, b) and bias c; consider the point (x, y).

Step 1

What is its activation?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Explain why

Why isn't the best direction for separating two classes simply the line joining their means?

Practice

Keep practicing

10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.