MLA-C01 Question 1
Select 2You are building a machine learning pipeline on AWS to predict customer churn. Your training dataset is stored in an S3 bucket and contains several categorical fields, such as 'Customer Type', 'Region', and 'Subscription Plan'. You notice that some of these categorical fields have a high cardinality (e.g., hundreds of unique values). Which of the following preprocessing steps would be the most appropriate for handling these high-cardinality categorical fields?
- A
Use one-hot encoding for all categorical fields, including those with high cardinality
- B
Apply feature hashing to reduce the dimensionality of high-cardinality categorical fields
- C
Use AWS Glue DataBrew to perform frequency binning on high-cardinality categorical fields
- D
Replace high-cardinality categorical fields with their mean target value (target encoding)
- E
Remove all high-cardinality categorical fields from the dataset to simplify the model
Show answer and explanation
Correct answers: B, D
Explanation
High-cardinality categorical fields can significantly increase the dimensionality of your dataset, posing challenges for model training and efficiency. Feature hashing effectively reduces the dimensionality without losing much information, while target encoding provides a way to incorporate target-related information into the features. Both techniques are valid choices depending on the specific use case. One-hot encoding, while suitable for low-cardinality fields, is not recommended for high-cardinality fields due to feature explosion.
- A. Incorrect.
Using one-hot encoding for high-cardinality fields can lead to an explosion in the number of features, making the model computationally expensive and difficult to train.
- B. Correct.
Feature hashing is an effective technique to reduce the dimensionality of high-cardinality categorical fields while retaining their information. It is computationally efficient and reduces memory usage.
- C. Incorrect.
AWS Glue DataBrew can help preprocess data, but frequency binning is not specifically designed for handling high-cardinality categorical fields. It is more suitable for numerical data.
- D. Correct.
Target encoding (replacing with mean target value) is a valid approach for high-cardinality fields as it reduces dimensionality and retains information relevant to the target variable. However, it must be done carefully to avoid data leakage.
- E. Incorrect.
Removing high-cardinality categorical fields may result in the loss of valuable information that could improve the model's predictions. This should only be done as a last resort.