MLA-C01 Question 60
Single answerA data scientist is building a machine learning model to predict customer churn. The dataset includes a categorical feature 'Region' with values 'North', 'South', 'East', and 'West'. The target variable is binary: 0 for 'No Churn' and 1 for 'Churn'. Which encoding technique is most appropriate to transform the 'Region' feature for input into a tree-based model such as XGBoost?
- A
One-hot encoding
- B
Label encoding
- C
Binary encoding
- D
Tokenization
Show answer and explanation
Correct answer: B
Explanation
Tree-based models like XGBoost can handle categorical features effectively using label encoding, as they evaluate splits based on the feature's numeric representation without requiring distance-based relationships. One-hot encoding, while useful for linear models, could unnecessarily increase feature dimensionality for tree-based models, leading to inefficiency. Binary encoding is more suitable for high cardinality features, and tokenization is specific to text processing, making label encoding the most appropriate choice for the given scenario.
- A. Incorrect.
One-hot encoding creates a new binary feature for each category, but for tree-based models like XGBoost, this can introduce sparsity without providing significant benefits, as these models are not sensitive to distance-based relationships between categories.
- B. Correct.
Label encoding assigns a numeric value to each category and is well-suited for tree-based models like XGBoost, which can naturally handle categorical splits without requiring one-hot encoded features.
- C. Incorrect.
Binary encoding is a hybrid approach that reduces dimensionality by representing categories with binary digits. While it can be effective for high cardinality features, it is unnecessary for a feature with only four categories like 'Region'.
- D. Incorrect.
Tokenization is a technique primarily used for processing text data, where it splits text into smaller units such as words or subwords. It is not applicable for encoding categorical variables like 'Region'.