Quiz: linear classifiers

Short questions to test your understanding. Try each on paper first, then open the answer. A linear classifier decides by the sign of f(\mathbf x) = \mathbf w\cdot\mathbf x + b; labels are y = \pm 1.


Q1. Give one example each of a classification problem where the points are pixels, objects and image windows. What are the features?

What is measured for each pixel, each object, each window?

Pixels: nucleus / cytoplasm / background, with features from a stack of filtered images (smoothed intensity at several scales, edge strength, blob and texture responses). Objects: cell / debris, with features from the measurement table (area, mean intensity, form factor). Windows: “cell here” / “no cell”, with a descriptor of the patch (e.g. histograms of gradient directions). In all three each item becomes a point in a feature space with a label.


Q2. For f(\mathbf x) = 2x_1 - x_2 + 1, which side is class +1? What is the signed distance of (0, 3) to the line?

The distance is f/\|\mathbf w\|.

Class +1 is the side \mathbf w = (2, -1) points to (right and down). f(0, 3) = 0 - 3 + 1 = -2, \|\mathbf w\| = \sqrt5, distance -2/\sqrt5 = -0.894: the point lies on the -1 side, 0.894 from the line.


Q3. You multiply \mathbf w and b by 10. Which of these change: the line, the classification of each point, the value of f, the distance of each point to the line?

Write f/\|\mathbf w\| for the scaled classifier.

Only the value of f (ten times larger). The line f = 0, the signs (classes) and the distances f/\|\mathbf w\| are unchanged. So the value of f alone means nothing until the scale of (\mathbf w, b) is fixed.


Q4. The two class means are \boldsymbol\mu_+ = (2, 2) and \boldsymbol\mu_- = (0, 0). Give the nearest-class-mean line.

Perpendicular to \boldsymbol\mu_+ - \boldsymbol\mu_-, through the midpoint.

\mathbf w = (2, 2), midpoint (1, 1), b = -(2 + 2) = -4: f = 2x_1 + 2x_2 - 4, the line x_1 + x_2 = 2.


Q5. Two long, thin, parallel clouds are shifted mostly along their length. Why does the nearest-class-mean line do badly, even though a line with zero errors exists?

In which direction does \boldsymbol\mu_+ - \boldsymbol\mu_- point?

\boldsymbol\mu_+ - \boldsymbol\mu_- points mostly along the clouds, so the nearest-mean line, perpendicular to it, runs across both clouds and cuts them. The separating line runs along the clouds, through the narrow gap. Nearest mean only looks at the two means, not at the shape of the clouds.


Q6. Why can no line separate a nucleus (inside) from the cytoplasm around it when the features are the pixel’s (x, y) position, or two intensity features in which the cytoplasm surrounds the nucleus?

A line splits the plane into two half-planes. Can a half-plane contain the inside of a ring but not the ring?

A half-plane is convex and unbounded: if it contains the inner blob it also contains every point on the far side, including part of the ring, because the ring surrounds the blob in all directions. A ring around a blob needs a closed boundary (a circle), which a linear classifier on these two features cannot produce. Adding a feature such as the squared distance from the centre makes it linear again (unit 3).


Q7. Is the SVM generative or discriminative? And a classifier that fits one Gaussian per class and picks the more likely class?

Does the method describe how each class is distributed?

The SVM is discriminative: it only looks for a boundary. The Gaussian-per-class classifier is generative: it models each class and compares likelihoods (the minimum-error threshold of the thresholding day is the 1D case; the Gaussian mixtures day goes further).


Q8. (math) Show that f(\mathbf x)/\|\mathbf w\| is the same for (\mathbf w, b) and (c\mathbf w, cb) with c > 0.

\|c\mathbf w\| = |c|\,\|\mathbf w\|.

(c\mathbf w\cdot\mathbf x + cb)/\|c\mathbf w\| = c(\mathbf w\cdot\mathbf x + b)/(c\|\mathbf w\|) = f(\mathbf x)/\|\mathbf w\| for c > 0. For c < 0 the sign flips: the same line, the sides swapped.