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.

Level: beginnerTopic: Feature engineering data prep

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

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.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.