Categories are not numbers in disguise
Why representing labels as arbitrary integers can mislead a model.

A label carries meaning
Categories such as fabric, delivery method or region do not automatically have a numerical order. Assigning cotton the value one, wool two and silk three can suggest a distance or ranking that the task never intended. Encoding converts categories into a form an algorithm can process, but the choice also introduces assumptions about relationships among the values.
A furniture catalogue example
Imagine predicting delivery damage from packaging material and shipping route. If routes receive arbitrary numeric identifiers, a distance-based model might treat route 12 as more similar to route 13 than route 90. The numbering system may reflect only the order in which routes were created. A prediction based on that accidental proximity would be difficult to defend.
Representation creates tradeoffs
One-hot encoding gives categories separate indicators, avoiding a fabricated order but potentially producing many columns. Hashing can limit representation size while allowing collisions. Encodings based on outcomes require particular care because they can leak target information when computed incorrectly. Rare and previously unseen categories also need an explicit treatment rather than an improvised response after launch.
Design for the next category
A catalogue is never finished. New materials, suppliers and routes will appear after training, so test those situations deliberately. Keep a mapping from source values to encoded features, record how missing values differ from unknown ones, and inspect whether grouping rare categories hides meaningful differences. The best representation is not the most elaborate. It preserves the distinctions relevant to the prediction while remaining understandable when the underlying catalogue changes. For ordered categories such as small, medium and large, explicitly decide whether order alone is meaningful or whether measured dimensions would better express the relationship.
Sources & further reading
developers.google.com — categorical data ↗
AI-assisted editorial explainer. Sources are provided for verification.
Continue reading
The quiet power of a straight line ↗
Probability is not a verdict ↗