A machine learning engineer is preparing a dataset for a classification model. The dataset contains a categorical feature with high cardinality (e.g., zip code). Which of the following techniques is most appropriate to handle this feature before training?

Answer

Target encoding

Explanation

Target encoding replaces categories with the mean of the target variable, which is effective for high-cardinality features and avoids the curse of dimensionality. One-hot encoding would create too many features, label encoding implies order, and binary encoding may still create many features.

Last reviewed: October 2026

Reviewed by FirstInTest Editorial Team

Report an error
QuestionBack to list