Key Ideas
1Why Preprocessing Matters. Imagine you're predicting house prices. Two features:
2StandardScaler — Zero Mean, Unit Variance. The most common scaler. For each feature, it subtracts the mean and divides by the standard deviation:
3MinMaxScaler — Compress to a Fixed Range. Scales each feature to a specific range, usually [0, 1]:
4RobustScaler — Handles Outliers. Uses the median and the interquartile range (IQR) instead of mean and std. Outliers have much less influence:
5Which Scaler to Choose
Decision guide
Does your data have significant outliers?
├── Yes → RobustScaler
└── No → Does the model need values in [0,1]?
├── Yes → MinMaxScaler
└── No → StandardScaler (default)
ScalerCenters onScale unitOutlier resistantBest for
StandardScalerMeanStd deviationNoMost models (default)
MinMaxScalerMin valueValue rangeNoNeural nets, image data
RobustScalerMedianIQRYesData with real outliers
None———Tree-based models (RF, XGBoost)
Encoding Categorical Variables. Models work with numbers. A column containing "red", "green", "blue" needs to become numbers. There are two main approaches, and choosing wrong causes subtle bugs.