Reach for ordinal encoding when the categories have a genuine order and the model can exploit it. Low, medium, and high severity, education level, t-shirt sizes, and survey ratings all carry order that one-hot throws away.
Encoded as 1, 2, 3, the model can learn a single split at "greater than 2". One-hot would need several splits to express the same idea, and it treats each level as unrelated.
The second case is high cardinality feeding a tree model. Integer codes keep the frame narrow, and trees do not read the integers as magnitudes anyway.
The cost lands on linear and distance-based models. They assume the gap from 1 to 2 equals the gap from 2 to 3. If your order is invented, say country codes, you have handed the model a relationship that does not exist.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓