AI engineering glossary · Feature engineering data prep
What is label encoding?
Label encoding (also called LabelEncoder): Replacing each category with an arbitrary integer, such as Mumbai = 0, Delhi = 1. It is compact but creates a false ordering, which harms linear and distance-based models, though tree-based models can cope with it. It is best for targets or ordered categories.
Label encoding: an example
Encoding class labels cat, dog, bird as 0, 1, 2 for a classifier is fine because the target is not treated as a numeric quantity.
Related terms
More Feature engineering data prep terms
- Lag feature
- Last observation carried forward
- Leave-one-out encoding
- Lemmatization
- Listwise deletion
- Log transform
- Mahalanobis distance
- Max-abs scaling
Where you learn it
Label encoding is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.