Databricks Machine Learning Associate Question 545
Single answerYou are developing a machine learning model on Databricks to predict customer churn. During the model development phase, you notice that your dataset contains several categorical features with high cardinality (e.g., 'Zip Code' and 'Product ID'). What is the most appropriate approach to handle these features before training the model?
- A
Use one-hot encoding to transform these features into binary columns
- B
Apply label encoding to convert the categories into numerical values
- C
Use a feature hashing technique to reduce the dimensionality of the categorical features
- D
Drop the categorical features to simplify the model and avoid overfitting
Show answer and explanation
Correct answer: C
Explanation
High-cardinality categorical features can create challenges in terms of memory and computational efficiency. One-hot encoding and label encoding are not ideal in this scenario due to scalability and potential introduction of ordinal relationships, respectively. Feature hashing is the most appropriate method as it effectively reduces the dimensionality while retaining the essential information from the categorical features.
- A. Incorrect.
One-hot encoding is not ideal for features with high cardinality because it can lead to a very large number of binary columns, which increases memory usage and computational cost.
- B. Incorrect.
Label encoding assigns numerical values to categories, but it can introduce unintended ordinal relationships between the categories, which is problematic for most machine learning algorithms.
- C. Correct.
Feature hashing is a suitable approach for high-cardinality categorical features as it reduces dimensionality by mapping categories to a fixed-size numeric representation, making it computationally efficient.
- D. Incorrect.
Dropping the features may simplify the model, but it sacrifices potentially valuable information that could improve model performance.