Category Encoders
✅
Description
Converts categories into integer labels.
Relevant Class/Implementation
sklearn.preprocessing.LabelEncoder
, OrdinalEncoder
Scikit-learn
✅
Label Encoding
- What It Does: Label Encoding assigns a unique integer to each unique category.
- Best For: Ordinal data (categories with a
natural order
, e.g., low, medium, high). - Suitable for ordinal data (where categories have an inherent order, like "low," "medium," "high").
- Example:
"low" → 0
,Â"medium" → 1
,Â"high" → 2
. - Caution: Can mislead models for nominal data since it imposes ordinal relationships
‣
Example 1
‣
Example 2
‣