📚

Label Encoding

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

‣

When Not to use label Enconding