devnotes.

The Data Preprocessing Workflow

Data preparation is a sequence of steps. Each step in this notebook has its own chapter.

StepGoalChapter
1Understand shape, types and quality of the dataIntroduction
2Remove duplicates, fix types and formatsData Cleaning
3Remove or fill blank valuesMissing Values
4Detect and treat extreme valuesOutliers
5Create train / validation / test setsSplitting Data
6Keep only the useful featuresFeature Selection
7Bring features to comparable rangesFeature Scaling
8Create new informative features, encode categoriesFeature Engineering
9Compress or transform features (PCA, TF-IDF)Feature Extraction
10Fix skewed class distributionsImbalanced Data

The order is flexible, but one rule is not

Anything that learns from the data — imputation values, outlier bounds, scaling statistics, selected features, PCA components, resampling — must be learned from the training set only and then applied to validation and test data.

This is why data splitting usually happens before imputation, scaling, selection and resampling.

A typical order in practice

  1. Inspect the data and clean obvious errors (duplicates, wrong types).
  2. Split into train and test sets.
  3. Inside a pipeline fitted on the training set: impute, treat outliers, encode, engineer, scale, select or extract features.
  4. Resample the training set if classes are imbalanced.
  5. Train and evaluate the model.
The Data Preprocessing Workflow - Introduction | Data Preparation | DevNotes