Robust Scaling for Outliers
You'll learn how to scale features without letting extreme outlier values distort your scaling.
The Problem with Traditional Scaling
When you use standardization (mean and standard deviation) or min-max normalization, outliers can dramatically skew your results. Imagine you're scaling salaries: if most employees earn 80,000 but the CEO earns $5,000,000, that one value will compress everyone else's scaled values into a tiny range, making it hard for algorithms to learn meaningful patterns.
What is Robust Scaling?
Robust Scaling uses the median and interquartile range (IQR) instead of mean and standard deviation. The median is the middle value (50th percentile), and the IQR is the range between the 25th and 75th percentiles—essentially the "middle 50%" of your data.
The formula:
X_scaled = (X - median) / IQR
Think of it like this: instead of asking "how far from the average?" (which outliers distort), you ask "how far from the typical middle values?" Outliers can't manipulate the median or IQR nearly as much.
Why It Works
The median doesn't care if your highest value is 100 or 100,000—it's still just the middle point. Similarly, the IQR focuses on where most of your data lives, ignoring extreme tails. This makes robust scaling resistant to outliers while still centering and scaling your features appropriately.
When to Use It
Use robust scaling when you suspect outliers in your data but don't want to remove them (because they might contain valuable information), especially with algorithms sensitive to feature magnitude like KNN or neural networks.
Key Takeaway: Robust scaling uses median and IQR instead of mean and standard deviation, making it resistant to outliers that would otherwise distort your feature scaling.