Databricks Machine Learning Associate Question 534
Select 2You are building a machine learning model to predict customer churn using a dataset that includes categorical columns such as 'Customer Segment' (e.g., 'Low Income', 'Middle Income', 'High Income') and 'Customer ID' (a unique identifier for each customer). Which of the following scenarios describe when one-hot encoding is appropriate or inappropriate?
- A
One-hot encoding is appropriate for the 'Customer Segment' column because it represents categorical data with a small number of distinct values.
- B
One-hot encoding is inappropriate for the 'Customer Segment' column because it would create too many new columns.
- C
One-hot encoding is inappropriate for the 'Customer ID' column because it is a unique identifier and does not represent meaningful categories.
- D
One-hot encoding is appropriate for the 'Customer ID' column because it can help the model differentiate between customers.
Show answer and explanation
Correct answers: A, C
Explanation
One-hot encoding is appropriate for categorical features with a small, manageable number of distinct categories, such as 'Customer Segment'. However, it is inappropriate for columns like 'Customer ID', which are unique identifiers and do not represent meaningful categories. Encoding such columns would result in unnecessary complexity and inefficiency without benefiting the model.
- A. Correct.
One-hot encoding is well-suited for the 'Customer Segment' column because it is a categorical variable with a manageable number of unique categories. This allows the model to learn relationships between these categories and the target variable.
- B. Incorrect.
This is incorrect because the 'Customer Segment' column has only a few distinct values, so one-hot encoding would not create an excessive number of new columns.
- C. Correct.
This is correct because the 'Customer ID' column is a unique identifier, not a meaningful categorical feature. One-hot encoding it would create as many new columns as there are unique customers, which is inefficient and adds no value to the model.
- D. Incorrect.
This is incorrect because one-hot encoding the 'Customer ID' column would not help the model differentiate between customers in a meaningful way. Instead, it would introduce unnecessary complexity without improving model performance.