Databricks Machine Learning Associate Question 494
Select 3You are working on a machine learning pipeline in Databricks to predict customer churn. Your dataset contains a column 'last_login_date' in string format (e.g., '2023-09-15') and another column 'total_purchase' in string format, which should be numeric. To ensure your data is clean and ready for modeling, which of the following steps should you take during preprocessing?
- A
Convert the 'last_login_date' column into a date type using a function like
to_date() - B
Remove the 'total_purchase' column since it is in string format and cannot be used directly in modeling
- C
Cast the 'total_purchase' column to a numeric type using functions like
cast()orwithColumn() - D
Split the 'last_login_date' column into separate year, month, and day columns for feature engineering
- E
Leave the columns in their current format since Databricks automatically handles these formats during modeling
Show answer and explanation
Correct answers: A, C, D
Explanation
Preparing the data for machine learning requires proper type conversions and feature engineering. Converting 'last_login_date' to a date type and creating additional columns for year, month, and day can enhance the model's understanding of temporal patterns. Similarly, casting 'total_purchase' to a numeric type ensures it can be used as a predictive feature. These steps are crucial for effective preprocessing in Databricks.
- A. Correct.
Correct. Converting 'last_login_date' to a date format is essential for proper feature engineering and downstream processing.
- B. Incorrect.
Incorrect. Removing the 'total_purchase' column is unnecessary as it can be cast to a numeric format and used in modeling.
- C. Correct.
Correct. Casting the 'total_purchase' column to numeric ensures it can be used as a valid feature in the machine learning model.
- D. Correct.
Correct. Splitting the 'last_login_date' into year, month, and day columns can provide additional features for the model to leverage.
- E. Incorrect.
Incorrect. Databricks does not automatically handle such format transformations; preprocessing is required to ensure the data is in the correct format.