Databricks Machine Learning Professional Question 56
Select 3You are building a machine learning pipeline in Databricks to predict customer churn. Your dataset includes a 'join_date' column (timestamp format) and a 'last_active_date' column (timestamp format). You also have a 'customer_id' column with unique identifiers and a 'churn' column indicating if the customer churned (1 for churned, 0 for not churned). Which preprocessing steps are appropriate to prepare the data for training?
- A
Calculate the difference in days between 'last_active_date' and 'join_date' as a new feature.
- B
Drop the 'customer_id' column to avoid leakage of unique identifiers into the model.
- C
Use one-hot encoding on the 'churn' column to make it suitable for classification.
- D
Fill missing values in 'last_active_date' with the mean of the column.
- E
Convert the 'join_date' and 'last_active_date' columns into Unix timestamp format for easier processing.
Show answer and explanation
Correct answers: A, B, E
Explanation
In preprocessing, it's essential to create meaningful features (e.g., time differences), remove irrelevant or potentially problematic columns (e.g., unique identifiers), and ensure that date/time data is in a format suitable for numerical processing. The 'churn' column does not require one-hot encoding as it is already binary, and missing value handling should be context-dependent. By performing these steps, the dataset becomes more suitable for machine learning model training in Databricks.
- A. Correct.
Correct: Calculating the difference between 'last_active_date' and 'join_date' creates a meaningful feature (e.g., customer tenure or inactivity duration) that can improve model performance.
- B. Correct.
Correct: 'customer_id' is a unique identifier that does not provide predictive value and could introduce noise or leakage into the model.
- C. Incorrect.
Incorrect: The 'churn' column is already in a binary format (0 and 1), so one-hot encoding is unnecessary and inappropriate.
- D. Incorrect.
Incorrect: Filling missing values in 'last_active_date' with the mean may not be ideal since it could distort the representation of inactivity. A better strategy would depend on the context, such as imputing with a fixed value or dropping the records.
- E. Correct.
Correct: Converting timestamp columns into Unix format allows for easier numerical processing and ensures compatibility with downstream algorithms.