Softmax regression
Let several competing classes share one probability budget. A larger class score receives a larger share, and all shares add to one.
Start with an example
For exactly one of three delivery routes, three equal scores give probabilities of one third each. Increasing one score raises that route's share.
How it learns
An input feature is a measurement about an example. The target is its known answer: a number for regression, or a category for classification. Training means learning from examples whose answers are already known.
- Learn a score for each possible class. Turn each score into a positive amount, then divide it by the total across classes. The resulting shares are probabilities that add to one.
- Compare the probability assigned to each training example's known class. Giving that class very little probability incurs a large cost; training adjusts the scores to reduce that cost. Prediction selects the class with the largest share.
Try it yourself
The example above gives the idea. The experiment below uses a separate, made-up dataset with unitless measurements so you can focus on how the model works. Read the graph guide first, then change one thing at a time.
1. Understand what you are looking at
Compare three competing classes at the same input. Each colored line belongs to one class; softmax shares a total probability of 1 between them.
- Across: the horizontal axis
- The input measurement x, from 0 to 10. Compare all class lines at the same horizontal position.
- Up: the vertical axis
- Each class's estimated probability, from 0 to 1. A height of 0.8 means an estimate of 80% for that class.
Green, orange, and purple lines belong to classes A, B, and C. There are no observed training dots here: these class scores or contests are constructed for illustration.
How to read one result: Start at x on the bottom axis and follow the vertical dashed line. Compare the three curve heights there: the highest identifies the winning class. The outlined diamond marks that highest value.
2. Predict, change, observe
- Keep Center of class B at 5. Inspect x = 2, then 5, then 8, and notice which class has the highest line at each position.
- Predict what raising Score sharpness will do near each class center. Increase it: the favored class gets a larger share, while the others get smaller shares.
- Class A
- Class B
- Class C
- Inspected result (diamond)
Compare class lines at this input. This readout is the highest value, not the sum of the class values.
3. Explain it in your own words
At one input, two softmax probabilities are 0.2 and 0.3. What must the third be, and why?
Compare your reasoning
It must be 0.5 because the three probabilities add to 1. These hand-chosen score curves illustrate the conversion to probabilities, not a fitted linear softmax model. If unsure, read all three heights at the same x rather than comparing different inputs.
Ready to continue when you can explain the result and why it changes. If the explanation is still unclear, reset and repeat the two steps above with one control at a time.
What this experiment simplifies
Softmax converts three scores into probabilities that sum to 1. The toy scores favor the class whose center is closest. These scores are illustrative, not a trained model.
These are small teaching implementations, not scikit-learn runs. Training error on these examples does not estimate performance on new data.
The math, one step at a time
Read the symbols after the idea makes sense. You do not need to memorize the formula.
z꜀ is class c's score, m is the largest score in the row, and p_true is the probability assigned to its observed class. The sum covers competing classes.
What to watch for
- One shared probability budget suits mutually exclusive classes; independent tags need a different output structure.
- Large confidence is not proof of correctness or calibration.
Explore a related model
Further reading
The official documentation goes further when you are ready.