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 .
- 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 with = (3, 4) and = −5. How far is the point (3, 1) from its decision boundary?
The boundary is , and the signed distance of a point is = (9 + 4 − 5)/5 = 1.6. The origin sits at −5/5 = −1, on the negative side.
Name it
Linear discriminants
A two-class linear discriminant assigns when . The boundary is a hyperplane perpendicular to w, at distance from the origin, and 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 , and within-class scatter , the separation
is largest for , where . In one dimension, J is the squared difference of projected means over the sum of projected variances.
The perceptron
With targets , cycle through the data and, whenever (a mistake), update . If the data are linearly separable with margin γ by a unit vector, and every , it converges after at most 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), = diag(1, 4)).
Show the solution
- Fisher's direction. at an angle of = 14.0° from the first axis.
- Separation.
- Along the means' own direction. At 45°: 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
- Update.
- Check the output. Its output on x rises from 0 to 2.5, now correct.
- Mistake bound. 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 . Find Fisher's separation when their means differ by (1, 1), and when they differ by (1, −1).
Show the solution
- Invert the covariance.
- Means differing by (1, 1).
- Means differing by (1, −1). three times better, though both mean differences are the same length.
- 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 = 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 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°.
Step 2
What is the point's signed distance from the boundary?
Explain why
Why isn't the best direction for separating two classes simply the line joining their means?
Projecting onto the line between the means maximizes how far apart the projected means are, but it ignores how widely each class spreads along that line. If the classes are elongated in that direction, their projections overlap heavily despite the distant means. Fisher's criterion divides the squared separation by the projected spread, so it prefers a direction along which the classes are narrow, even at the cost of some mean separation. That's why the solution involves the inverse of the within-class scatter: it tilts the direction away from axes of large variance and toward axes where the classes are tight.
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.