MLA-C01 Question 40
Select 3You are building a machine learning pipeline in Amazon SageMaker to predict customer churn. Your dataset contains a 'LastLoginDate' column as a timestamp and a 'SubscriptionType' column as a categorical variable. What steps should you take to transform the data and perform feature engineering before training the model?
- A
Convert the 'LastLoginDate' column to a numeric feature, such as the number of days since the last login.
- B
One-hot encode the 'SubscriptionType' column to create binary indicator variables for each subscription type.
- C
Drop the 'LastLoginDate' column, as timestamps cannot be directly used in machine learning models.
- D
Normalize the 'SubscriptionType' column by scaling its values to a range of 0 to 1.
- E
Add a new feature representing the time difference between 'LastLoginDate' and the current date.
Show answer and explanation
Correct answers: A, B, E
Explanation
To transform and engineer features for machine learning, you must convert raw data into a format suitable for model training. Timestamps should be converted into numerical features (e.g., days since the last login), while categorical variables need to be one-hot encoded. Additionally, deriving new features, such as time differences, can enhance the model's ability to capture patterns in the data. Dropping relevant columns or applying inappropriate transformations, such as normalizing categorical variables, should be avoided.
- A. Correct.
Correct. Converting the 'LastLoginDate' column into a numeric feature, such as days since the last login, is a common feature engineering practice for timestamp data.
- B. Correct.
Correct. One-hot encoding the 'SubscriptionType' column transforms it into a machine-readable format, enabling the model to understand categorical data.
- C. Incorrect.
Incorrect. While timestamps cannot be directly used in most models, dropping the column is unnecessary since it provides valuable information that can be engineered into useful features.
- D. Incorrect.
Incorrect. Normalizing a categorical column like 'SubscriptionType' is not appropriate. Instead, one-hot encoding is the correct approach.
- E. Correct.
Correct. Adding a feature representing the time difference between the 'LastLoginDate' and the current date can provide additional predictive power to the model.