
Outlier-detection algorithms usually work with numbers, but important data is often categorical: country, product, device, or customer type. To analyze it, categories must become numerical representations without losing their meaning. 📊
The article explains that encoding depends on context. One-hot encoding creates one column per category; ordinal encoding assigns an explicit order; and frequency, target, or embedding methods represent more complex relationships. A poor choice can create artificial distances and produce false outliers.
💡 Explanation in a nutshell#
If a model receives “red,” “green,” and “blue” as 1, 2, and 3, it may believe blue is closer to green than red. That relationship may not exist. Good encoding chooses a representation that reflects how values are actually similar.
Avoid leakage, handle unknown categories, and validate results with domain knowledge. Outlier detection does not start with the algorithm; it starts with representing data correctly.
More information at the link 👇

