Raw data often needs preparation before it can be used by a machine learning model. Missing values may cause errors, numerical features can have very different scales, and categories such as colors or countries need to be represented in a form that a model can use.
In this unit, you will practice filling in missing values, scaling numerical features, and encoding categorical variables. You will also explore feature engineering and consider how unrepresentative data can contribute to biased model outcomes.
Identify why processing raw data into 'features' improves model performance.
Check how the scaler and encoder convert the data.
We examine how AI makes unfair judgments when the training data itself is biased or the sample is insufficient.
Work through each notebook in order. Make your own copy before editing.
Explore the customer data with histograms, scatterplots and box plots. Compare what you see before and after handling missing values, then answer the seven discussion questions.
Open the lab | View the completed version
Run the examples and complete the questions. Compare how scaling and encoding change the input data.
Explore categorical and text features, polynomial features, and a preprocessing pipeline.
DIY Challenge: Build a Preprocessing Pipeline
Create a DataFrame for five fictional students with columns for study hours, test score, and preferred subject. Include at least one missing numerical value. Fill in the missing value using the column mean, scale the numerical columns with MinMaxScaler, and one-hot encode the subject column. Display the data before and after each step, and explain why you chose each transformation.