MLS-C01 Question 55
Select 3You are building a machine learning pipeline to predict customer churn for a subscription-based service. The dataset contains categorical columns such as 'region' and 'subscription_type', as well as numerical columns like 'monthly_usage' and 'age'. You notice that the categorical columns have a mix of high-cardinality and low-cardinality values. Which of the following steps should you implement to appropriately transform this data for training your machine learning model?
- A
Use one-hot encoding for low-cardinality categorical columns and target encoding for high-cardinality categorical columns.
- B
Apply standardization (z-score normalization) to the numerical columns.
- C
Use one-hot encoding for all categorical columns, regardless of cardinality.
- D
Apply min-max scaling to the numerical columns.
- E
Use hashing-based categorical encoding for all categorical columns.
Show answer and explanation
Correct answers: A, B, D
Explanation
To prepare the dataset for machine learning, it is crucial to select appropriate transformation techniques for different types of data. Low-cardinality categorical columns can be one-hot encoded to create a manageable number of features, while high-cardinality columns benefit from target encoding to reduce dimensionality. Numerical columns should be standardized or scaled depending on the model requirements. Avoid using inefficient or less interpretable methods like blanket one-hot encoding for all categorical columns or hashing-based encoding unless there is a specific use case that justifies it.
- A. Correct.
This is correct. One-hot encoding is suitable for low-cardinality categorical columns, while target encoding is better for high-cardinality columns to avoid high-dimensionality problems.
- B. Correct.
This is correct. Standardization is a common preprocessing step for numerical columns, especially when the machine learning model is sensitive to feature scaling (e.g., linear regression, logistic regression).
- C. Incorrect.
This is incorrect. One-hot encoding all categorical columns, including high-cardinality columns, can lead to a very large feature space, making the model computationally expensive and prone to overfitting.
- D. Correct.
This is correct. Min-max scaling is another common preprocessing technique for numerical columns, especially when the model benefits from normalized feature ranges (e.g., neural networks).
- E. Incorrect.
This is incorrect. Hashing-based encoding is not always the best choice, as it can introduce collisions in categorical data and is less interpretable than other methods like one-hot or target encoding.