Learning objectives
- Explain the ideas behind data preparation and feature engineering.
- Apply the ideas to the example and identify how you would check the result.
Concepts
Clean inconsistent types, remove accidental duplicates and investigate missing values. Fit imputation and encoding on training data only. Engineer features from information available at prediction time.
Practical example
Build a seven-day trailing transaction average, excluding the day you are predicting.
Try the exercise
- Define the task. Build a seven-day trailing transaction average, excluding the day you are predicting.
- Identify the key idea. Clean inconsistent types, remove accidental duplicates and investigate missing values.
- Check your decision. Describe an alternative and how you would compare its results.
Python example
train_median = train['amount'].median()
test['amount'] = test['amount'].fillna(train_median)