The idea
Think of each class as a candidate in an election, with a score that rises as you move in its favoured direction across the plane. Softmax converts the scores into vote shares that add up to one. Where two candidates tie, you get the boundary.
On its own the score is linear, so boundaries are straight lines. Feed it extra features like , and , and the same linear model can draw circles, ellipses and curves in the original plane.
How it learns
- Start with all weights at zero, so every class has equal probability everywhere.
- Compute each point's predicted probabilities with softmax.
- Measure the log loss: how surprised the model is by the true labels.
- Compute the gradient over all points at once and step the weights downhill by the learning rate.
- Repeat until the gradient is tiny or the epoch limit is reached.
Reading the picture
The background colour shows the most likely class, and its strength shows confidence. Pale bands mark places where the model is unsure. The boundary line is where two classes are equally likely.
Press play to watch the boundary rotate and slide into place. Log loss in the stats should fall steadily; if it bounces around, the learning rate is too high.
Try this
- On Blobs, press play and watch the boundaries settle. Then add a class C point deep in A's territory and see how far it can pull the line.
- Switch to Circles with Feature degree 1. No straight line works. Set Feature degree to 2 and the boundary becomes a ring.
- Try XOR at Feature degree 2. The feature alone is enough to solve it.
- On Moons, set Feature degree to 6 and Regularisation () to the far left, then slide up. Watch an overly twisty boundary smooth out.
The maths
Features
Scores
Softmax
Loss
Gradient step
Strengths and weaknesses
Good at
- Outputs calibrated-looking probabilities, not just labels.
- Weights are interpretable and training is stable.
- Feature expansion makes it surprisingly flexible.
Struggles with
- Linear in its features: curves need hand-made features.
- High feature degrees overfit without regularisation.
- Gradient descent can be slow with a poor learning rate.