What is the purpose of LabelEncoder in scikit-learn and when should you use OrdinalEncoder instead?

Data Science with Python Medium

Data Science with Python — Medium

What is the purpose of LabelEncoder in scikit-learn and when should you use OrdinalEncoder instead?

Key points

  • LabelEncoder encodes target labels as integers
  • OrdinalEncoder preserves ordinal order for multiple input feature columns
  • LabelEncoder is used for target variables, OrdinalEncoder for feature columns
  • OrdinalEncoder is not limited to binary categories like LabelEncoder

Ready to go further?

Related questions