Presets
Playback
Classes
Data
Training
Layers
Model check
The science
The problem
A logistic-regression classifier separates only two classes: p(t=1|x) = sigma(w.x + b), sigma(z) = 1/(1+e^-z). With K > 2 classes there are two classic ways to combine binary classifiers, and one native multiclass model to compare against.
The three strategies
- One-vs-Rest (OvR): K classifiers, classifier k trained on "class k" against all the others. Prediction:
argmax_k (w_k.x + b_k). Each classifier sees all N points but a lopsided 1 : (K-1) problem. - One-vs-One (OvO): K(K-1)/2 classifiers, one per class pair, each trained only on the two classes involved. Prediction: every classifier casts one vote, the class with most votes wins. A tie (margin 0) is an ambiguous cell. All together the classifiers visit (K-1)N points per step.
- Softmax (reference): one joint model,
p(k|x) = e^(s_k) / sum_j e^(s_j)withs_k = w_k.x + b_k, trained on the cross-entropy loss.
Training
Every model is trained live by batch gradient descent on the L2-regularised log-loss L = -mean[t ln p + (1-t) ln(1-p)] + (lambda/2)|w|^2, with gradient dL/dw = mean[(p - t) x] + lambda w. The page's first check differentiates the loss numerically and compares it to this formula.
What you see
Each cell of the map is coloured by the predicted class and darkened where the margin (winner minus runner-up score, or vote difference) is small. White dashed or coloured lines are the individual binary decision lines w.x + b = 0. The confusion matrix and recall bars use a held-out test set drawn from the same Gaussians.
Honest simplifications
The two features are 2-D Gaussian clusters, so the best possible classifier is the nearest true centre (the Bayes rule); its test accuracy is shown as the ceiling. Real data are higher-dimensional and not Gaussian. Linear models cannot draw curved boundaries. OvO "votes" use the hard sign of each classifier, not probabilities. The dataset is clipped to the plotted square. A fixed learning rate on unscaled features is used, so large rates can oscillate.
Model checks
(1) gradient against a finite difference, (2) classifier counts and vote conservation, (3) samples visited per step, (4) test accuracy against the Bayes limit. All four are recomputed every few seconds from the live models.