Databricks Machine Learning Associate Question 544
Select 3You are building a machine learning model in Databricks to predict customer churn. After loading the data and performing basic exploratory data analysis, you observe that the dataset contains categorical features like 'customer_region' and 'subscription_type'. To properly incorporate these features into your machine learning pipeline, what should you do before passing the data to the model?
- A
Apply one-hot encoding to transform the categorical features into numerical format.
- B
Remove all categorical features from the dataset as they cannot be used by most machine learning models.
- C
Use StringIndexer to convert the categorical features into numerical indices.
- D
Apply feature scaling (e.g., standardization) directly to the categorical features.
- E
Use a pipeline to automate the feature transformation steps for categorical features.
Show answer and explanation
Correct answers: A, C, E
Explanation
In Databricks, categorical features need to be transformed into numerical formats before being used by machine learning models. Techniques like one-hot encoding and StringIndexer are commonly used for this purpose. Additionally, leveraging a pipeline helps automate and standardize the transformation process, ensuring scalability and consistency in the workflow.
- A. Correct.
Correct: One-hot encoding is a common technique to convert categorical variables into numerical format, which is required for many machine learning models.
- B. Incorrect.
Incorrect: Categorical features can be very informative, and removing them entirely would lead to a loss of valuable information.
- C. Correct.
Correct: StringIndexer is a valid approach to convert categorical labels into numerical indices, which some models can handle directly.
- D. Incorrect.
Incorrect: Feature scaling is not applicable to raw categorical features. These need to be transformed into numerical format first.
- E. Correct.
Correct: Databricks ML pipelines can automate feature transformations, including handling categorical features, which ensures a streamlined and reproducible process.