Feature Scaling
Many algorithms require scaled features.
StandardScaler
Standardizes: (x - mean) / std. Preserves distribution shape. fit_transform on train, transform on test.
For tree-based methods, scaling not needed.
MinMaxScaler
Scales to [0, 1] range: (x - min) / (max - min). Sensitive to outliers.
RobustScaler uses median and IQR: more robust to outliers.
Normalization
L2 normalization: unit vector. sklearn.preprocessing.normalize(X, norm='l2').
Used for text data or when direction matters.
Key Takeaways
- StandardScaler standardizes to mean=0, std=1
- MinMaxScaler scales to [0, 1]
- Fit on training data, transform test data