Skip to content
M.U.N.U.O.Data × AI × Systems

Machine Learning Foundations

Data Preparation and Feature Engineering

Module 2 of 10

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
  1. Define the task. Build a seven-day trailing transaction average, excluding the day you are predicting.
  2. Identify the key idea. Clean inconsistent types, remove accidental duplicates and investigate missing values.
  3. Check your decision. Describe an alternative and how you would compare its results.
Open the interactive lab

Python example

train_median = train['amount'].median()
test['amount'] = test['amount'].fillna(train_median)

Knowledge check

Where do you fit an imputer?

What is a lag feature?

Why inspect duplicates?