What is encoding categorical variables?

Updated May 17, 2026

Short answer

It converts categorical data into numeric format for ML models.

Deep explanation

Methods include one-hot encoding and label encoding depending on ordinal or nominal data.

Real-world example

Used in customer segmentation for marketing analytics.

Common mistakes

  • Using label encoding for non-ordinal categories.

Follow-up questions

  • What is one-hot encoding?
  • When to avoid encoding?

More Scikit-Learn interview questions

View all →