SigmaAnalytics & Tech
G1PythonAdvancedAbout 180 min to complete

Data Preparation for Machine Learning

Welcome to machine learning. You've already built predictive models by hand with statsmodels; now we switch to scikit-learn, the standard Python ML toolkit, and adopt its professional workflow.

Notebook

About 180 minutes to complete

Enrol to read the notebook and download it to run.

What this module covers

Welcome to machine learning. You've already built predictive models by hand with statsmodels; now we switch to scikit-learn, the standard Python ML toolkit, and adopt its professional workflow.

By the end of it

  • Describe the scikit-learn API — the fit / transform / predict pattern shared by every tool
  • Split data into train and test sets (with stratification) and explain why holding out data is non-negotiable
  • Scale features (StandardScaler, MinMaxScaler, RobustScaler) and know which models need it
  • Encode categorical variables (OneHotEncoder, OrdinalEncoder)
  • Impute missing values (SimpleImputer, KNNImputer)
  • Combine steps cleanly with ColumnTransformer and Pipeline
  • Recognise and prevent data leakage — the most damaging, most common ML mistake