Picture the flowers as points floating in a four-dimensional room, one axis per measurement, coloured by species. The two colours form overlapping clouds. Now shine a light through the room and read the shadow the points cast on a wall — a one-dimensional line. Most directions give a useless shadow where the colours smear together, but some direction gives the cleanest separation, and that direction is the whole of linear discriminant analysis. Once you have it, classification is trivial: project a flower onto that line and see which side of a threshold it lands on.
“Cleanest” is not simply the direction where the two cloud centres land furthest apart — a direction can spread the centres and spread each cloud equally, gaining nothing. What you want is the gap between the centres relative to how fat the clouds are along that same direction. Three equivalent ways to say the same thing: LDA is a two-sample -statistic maximised over every possible linear combination of the measurements; LDA is PCA that has been told the labels, finding the direction of largest between-species spread per unit of within-species spread rather than largest total spread; LDA is “whiten, then point at the difference” — rescale the room so the within-species scatter becomes a sphere, and in that reshaped room the best direction is simply the line joining the two cloud centres.
Let be a flower's measurements and its species. With class means and mean difference , the within-class scatter and between-class scatter give Fisher's criterion — the squared gap between projected means divided by the pooled variance of the projection:
fixes a direction, never a scale: any two implementations must agree by angle, not by raw coefficient magnitude. Because has rank one, the maximiser of collapses to one line — no iteration, no learning rate, one matrix solve:
This is the whole fitting procedure — which is why lda_all4 carries
no random_state at all in this study's recipe table, and why its fit noise is
exactly zero by construction. It is also not merely a reasonable rule; under two
Gaussian classes sharing one covariance , the
log posterior odds is exactly linear in with this same
:
so LDA is the plug-in Bayes rule — the mathematically best possible classifier in that world, with population moments replaced by sample estimates. Iris versicolor and virginica are close to that world: four smooth, roughly bell-shaped measurements, two species whose scatter is similar in shape. If the assumption holds even approximately, a more flexible learner has nothing left to find; it can only add variance. That is the method card's central bet, and section 4 shows what happened when it was tested.
ROC-AUC is the probability that a randomly chosen virginica scores above a randomly chosen versicolor — the Mann–Whitney statistic over every positive–negative pair. The development block holds 13 versicolor and 12 virginica, so the statistic is a count over 156 ordered pairs and can only move in steps of :
That is the instrument's resolution — the smallest non-zero difference it can express. It is not the same thing as its noise floor: resample the same 25 rows, or redraw which 25 they are, and the statistic wanders by a different, usually much larger amount. This study's own convention is a paired bootstrap: draw one shared resample index and apply it to both the candidate and the reference score in lock-step (common random numbers by construction), so the errors that are common to both cancel and only the genuine difference remains. The resulting bar is over the replicates — a floor that is measured, at Phase 0, before a single challenger runs. Confusing the 0.0064 resolution with this measured floor is exactly the mistake this study's own doctrine refuses to make.
The whole fitting procedure, with no framework:
mus = np.stack([X[y == c].mean(axis=0) for c in classes]) # class means
priors = np.array([(y == c).mean() for c in classes]) # empirical priors
S_W = np.zeros((p, p)) # within-class scatter
for k, c in enumerate(classes):
Z = X[y == c] - mus[k]
S_W += Z.T @ Z
Sigma = S_W / (n - K) # pooled covariance, unbiased
d = mus[1] - mus[0]
w = np.linalg.solve(Sigma, d) # Sigma^-1 (mu1 - mu0)
b = -0.5 * (mus[1] @ np.linalg.solve(Sigma, mus[1])
- mus[0] @ np.linalg.solve(Sigma, mus[0])) + np.log(priors[1] / priors[0])
score = X @ w + b # > 0 -> predict virginica
Run at the METHOD gate against LinearDiscriminantAnalysis(solver="svd") on
this study's own 49 training rows, before any evidence was spent: cosine similarity of the
two discriminant directions 1.000000000000000, maximum absolute coefficient
difference 7.105e-15, maximum decision-score difference over the 49 rows
1.776e-14. Two implementation details cost that agreement if skipped:
np.linalg.solve rather than an explicit matrix inverse, and the
prior term in the intercept, which on
this study's 25-versus-24 training split is
— small enough to hide, large enough to move a borderline flower's predicted label
even though it never touches the fitted direction.
| Recipe | First published | Intuition |
|---|---|---|
logreg_l2 | Berkson 1944 / Cox 1958 | The same flat boundary, chosen by a different question — not “which direction separates the clouds” but “which boundary makes the observed labels most likely” — with an L2 penalty shrinking the coefficients toward zero. |
knn5 | Fix & Hodges 1951 / Cover & Hart 1967 | No model at all: classify a flower by a majority vote of its five nearest training flowers. Infinitely flexible in principle; with 49 training flowers, a coarse instrument in practice. |
svm_rbf | Boser–Guyon–Vapnik 1992 / Cortes & Vapnik 1995 | Lay the widest possible road between the two classes, after bending space with a Gaussian kernel so the road may curve. |
hgbt | Friedman 2001 / Ke et al. 2017 | A committee of short, axis-aligned staircases, each fitted to what the committee so far still gets wrong. |
Two of these (logreg_l2, and svm_rbf with a narrow enough
kernel) can reproduce something close to Fisher's straight boundary. Two of them
(knn5, hgbt) cannot draw a smooth oblique line at all — if
the true boundary really is close to a plane, that is a handicap, not a feature: variance
spent buying flexibility the boundary does not need. Section 4 measures which of
these two pictures the data actually supports.