Five Percent of My Rows Were Lying. Winsorizing Fixed Nothing, Dropping Fixed Everything
I shifted 5% of training targets by 25 points and tested five outlier fixes at three sample sizes. The damage scaled with 1/n, Huber matched the clean-data floor without touching the data, and the most popular fix barely moved the needle.

Every regression tutorial has an outliers section, and every one of them says roughly the same thing: outliers distort OLS, so winsorize them or drop them. I have repeated that advice myself. But I had never measured how much damage a fixed share of bad rows actually does, or which fix earns its keep at which sample size. So I built a dataset where I knew the truth, planted the outliers myself, and scored each fix on a clean test set.
The setup
The target is synthetic and linear, so there is no model misspecification to confuse the results. Five standard normal features, true coefficients 3.0, -2.0, 1.5, 0.5, and 0.0, plus unit noise. The fifth feature is pure noise on purpose: it shows whether a fix distorts coefficients that should be zero.
Training sets of 150, 300, and 1,000 rows; a fixed clean test set of 500 rows. Then I corrupted 5% of the training targets, chosen at random, by shifting each one up or down by 25 points. The clean target has a standard deviation of 3.87 and a maximum absolute value of 11.66. The corrupted values reach 33.81. These are gross errors, the kind a broken sensor or a mis-keyed entry produces, not subtle drift.
The fixes, all applied to the training data only:
- Nothing. OLS on the corrupted data.
- Drop by residual. Fit OLS once, drop rows whose residual exceeds three standard deviations, refit.
- Winsorize the target at the 1st and 99th percentiles of the training targets.
- Clip the target at the training mean plus or minus three standard deviations.
- Huber loss.
HuberRegressorwith epsilon 1.35, the scikit-learn default, on the raw corrupted data. - Ridge (alpha 1.0) on the raw corrupted data, to test whether regularization helps at all.
- Random forest (300 trees) on the raw corrupted data, to test the folk claim that trees are naturally robust.
Metrics are RMSE and MAE on the clean test set. The floor is OLS trained on the uncorrupted data: RMSE 1.01 at n=150, 1.03 at n=300, 1.05 at n=1,000. Everything ran in scikit-learn 1.9.1, seed 42, with verification runs at a second seed and at 10% contamination.
rng = np.random.default_rng(42)
beta = np.array([3.0, -2.0, 1.5, 0.5, 0.0])
y_clean = X_train @ beta + rng.normal(scale=1.0, size=n_train)
idx = rng.choice(n_train, size=int(0.05 * n_train), replace=False)
y = y_clean.copy()
y[idx] += 25.0 * rng.choice([-1, 1], size=len(idx))
# the drop rule: two passes, threshold from the first fit
first = LinearRegression().fit(X_train, y)
resid = y - first.predict(X_train)
keep = np.abs(resid) <= 3 * resid.std()
model = LinearRegression().fit(X_train[keep], y[keep])
Finding 1: the damage scales with 1/n
Same corruption, same test set, three sample sizes:
| Train rows | Clean floor RMSE | OLS raw RMSE | Damage |
|---|---|---|---|
| 150 | 1.01 | 1.72 | +70% |
| 300 | 1.03 | 1.38 | +34% |
| 1,000 | 1.05 | 1.12 | +7% |
This is the finding that reframes the whole topic. Five percent bad rows is not a fixed amount of damage. At n=150, seven corrupted rows nearly doubled the test error. At n=1,000, fifty corrupted rows cost 7%. OLS averages over the data, so each bad row's influence shrinks as the clean rows pile up.
The practical consequence is that outlier handling matters most exactly where datasets are smallest, which is also where people are most reluctant to delete rows. On a 150-row training set, dropping 7 rows feels expensive. It is the right call anyway, as Finding 2 shows.
Finding 2: dropping by residual recovered the floor, and caught every planted outlier
The two-pass drop rule is the simplest fix in the list and it was the best at every sample size:
| Train rows | Drop RMSE | Clean floor | Rows dropped | Planted caught | Clean dropped |
|---|---|---|---|---|---|
| 150 | 1.01 | 1.01 | 7 | 7 of 7 | 0 |
| 300 | 1.04 | 1.03 | 15 | 15 of 15 | 0 |
| 1,000 | 1.05 | 1.05 | 50 | 50 of 50 | 0 |
At 5% contamination the rule was perfect: every planted outlier had a residual far beyond three standard deviations, and no clean row did. That is partly because the corruption was large (25 points against a residual scale near 1), so do not read this as a guarantee. At 10% contamination the rule started to miss: it caught 90 of 100 planted outliers, because 100 bad rows inflate the residual standard deviation and lift the threshold. Even then it scored RMSE 1.09 against a floor of 1.05, still far better than raw OLS at 1.14.
The reason the rule works here is that it looks at residuals, not at the target alone. A large target value can be legitimate if the features predict it. A large residual cannot be explained by the features, which is exactly what an outlier is. Rules based on the target distribution, like winsorizing, cannot make that distinction. That is the whole story of Finding 4.
Finding 3: Huber matched the floor without touching the data
Huber loss scored RMSE 1.02 at n=150, 1.04 at n=300, and 1.05 at n=1,000. At every sample size it was within 0.01 of the clean-data floor, and it did it without deleting or changing a single row. At 10% contamination it was the best method in the test (1.05 vs 1.09 for dropping), because unlike the drop rule its threshold does not degrade as the bad rows pile up.
The mechanism is in the loss function. Huber is quadratic for small residuals and linear for large ones, so a residual of 25 contributes 25 times as much as a residual of 1, not 625 times. The scikit-learn default epsilon of 1.35 is chosen to keep 95% statistical efficiency when the errors really are normal, so on clean data Huber costs almost nothing. That is the trade most practitioners should want: pay nothing when the data is clean, lose little when it is not.
If you take one thing from this piece, take this: HuberRegressor(epsilon=1.35) is a one-line change that recovered the clean-data floor in every run I did. It is the cheapest insurance in the experiment.
Finding 4: winsorizing barely helped, because the outliers set the caps
Winsorizing is the fix most people reach for first, and it was the worst of the serious fixes:
| Train rows | Winsorize 1/99 RMSE | OLS raw RMSE |
|---|---|---|
| 150 | 1.62 | 1.72 |
| 300 | 1.40 | 1.38 |
| 1,000 | 1.11 | 1.12 |
At n=1,000 it recovered 0.01 of RMSE. At n=300 it scored worse than doing nothing. On a second seed it scored 1.23 against raw OLS at 1.22, worse again. Clipping at mean plus or minus three standard deviations was no better (1.10 at n=1,000, and 1.17 at 10% contamination, worse than raw).
The failure has a specific cause, and it is worth understanding because it generalizes. Winsorizing replaces values beyond the 1st and 99th percentiles with the values at those percentiles. But the percentiles are computed from the corrupted data, and the corrupted rows are the extremes. At n=1,000, the caps landed at -25.55 and +25.55, while the shifted values sit near plus or minus 25 plus their clean value. The caps barely touched the corrupted rows. The fix was calibrated by the very values it was supposed to tame.
Winsorizing works when the outliers are a small number of extreme values in an otherwise clean tail, so the percentile caps sit well inside the corrupted values. It fails when the outliers are numerous enough to define the percentiles themselves. Five percent contamination at the 1st/99th percentiles is exactly that case: the top 1% of the data is corrupted rows, so the 99th percentile is a corrupted value. If you winsorize, winsorize at a tighter cutoff than the contamination rate you suspect, or use a robust scale (median and MAD) to set the caps instead of percentiles. Better still, use a residual-based rule or Huber and skip the percentile logic entirely.
Finding 5: ridge did nothing, and trees are not a fix
Ridge with alpha 1.0 scored RMSE 1.118 at n=1,000, identical to plain OLS at 1.118 to three decimals. Regularization shrinks coefficients toward zero. It does not downweight bad rows. If your model is being hurt by outliers, adding a penalty term is answering a different question.
The random forest scored RMSE 2.24 on the corrupted data, far worse than OLS at 1.12, which looks like an indictment of trees until you run the control: the same forest trained on clean data scored 1.37. Trees were already worse than OLS on this linear target before any corruption existed, because axis-aligned splits approximate a linear surface poorly. The outliers cost the forest about 0.87 of RMSE on top of that, so trees are not immune either. The lesson is narrower than "trees handle outliers": a model family can be robust to outliers and still be the wrong model for the target. Do not switch model families to fix a data problem.
One more place the damage showed up: the coefficients. Raw OLS estimated the smallest true coefficient, 0.5, as 0.17, while the clean-data fit estimated it as 0.47. The pure-noise fifth feature, true coefficient 0.0, got -0.137 in the raw fit and 0.02 in the clean fit. Outliers do not just inflate your error metric. They distort the small effects most, which are usually the effects you care about interpreting.
What to do on Monday morning
- Check the scale of the problem before choosing a fix. If your training set is small, 5% bad rows can cost 70% of your accuracy. If it is large, the same share costs 7%. Plot residuals first and count how many rows sit beyond three standard deviations.
- Try Huber first. One line, no data surgery, matched the clean-data floor at every sample size and both contamination rates I tested. If it does not help, the problem is probably not outliers.
- If you drop rows, drop by residual, not by target value. Fit once, drop rows beyond three residual standard deviations, refit. In this experiment it caught every planted outlier and zero clean rows at 5% contamination.
- Do not winsorize at percentiles looser than your suspected contamination rate. At 5% contamination, 1st/99th percentile caps are set by the corrupted rows themselves. If you must winsorize, set the caps from a robust scale, median plus or minus a multiple of the MAD, not from percentiles of the dirty data.
- Do not expect regularization to fix outliers. Ridge changed nothing here. Regularization and robustness are different tools.
- Watch the small coefficients. The damage showed up most in the smallest true effect (0.5 estimated as 0.17). If your interpretation depends on a small coefficient, outliers are a bigger threat than your RMSE suggests.
In favour
The design is clean: one known data-generating process, contamination applied only to training targets, a fixed clean test set, and a clean-data floor to compare against. The headline ranking reproduced across three sample sizes, two contamination rates, and a second seed. The drop rule's perfect catch at 5% and partial catch at 10% is exactly the degradation pattern theory predicts, which is a good sign the experiment is measuring what it claims to measure.
Against
The corruption is cartoonishly large: a 25-point shift on a target with standard deviation 3.87. Real outliers are often subtler, and subtler outliers are harder for the residual rule to catch and less damaging to OLS, which would compress every gap in the table. The target is linear with independent features, which flatters both OLS and Huber and punishes the random forest for reasons unrelated to outliers. And the drop rule's threshold uses the residual standard deviation, which the outliers themselves inflate, so at higher contamination rates it starts missing exactly the rows it exists to catch.
What would make me wrong
- If a smaller shift, say 5 points instead of 25, leaves the drop rule catching only half the planted rows, then the "perfect catch" result is an artifact of how large I made the corruption.
- If winsorizing at the 5th/95th percentiles beats the 1st/99th version by a wide margin, then my Finding 4 is about the cutoff choice, not about winsorizing as a method.
- If leverage-point contamination flips the ranking and Huber beats dropping by a wide margin, then the advice to drop by residual needs a leverage qualifier I did not test.
- If a proper cross-validated comparison on a real dataset shows no difference between the fixes, then the whole ranking is a synthetic-data artifact and the honest advice is that fix choice does not matter much in practice.
Key takeaways
- The same 5% corruption cost OLS 70% of test RMSE at n=150 and 7% at n=1,000. Outlier damage scales with 1/n.
- Dropping rows by residual (three standard deviations, two passes) recovered the clean-data floor at every sample size, catching all 50 planted outliers and zero clean rows at 5% contamination.
- Huber loss with epsilon 1.35 matched the floor at every sample size without touching the data, and was the best method at 10% contamination.
- Winsorizing at the 1st/99th percentiles barely helped and sometimes hurt, because the corrupted rows set the percentile caps. At n=300 it scored 1.40 against raw OLS at 1.38.
- Ridge changed nothing (1.118 vs 1.118), and a random forest was worse than OLS even on clean data (1.37 vs 1.05), so neither is an outlier fix.
When did you last look at the distribution of your regression residuals? If the answer is "never," fit the model, plot the residuals, and count what sits beyond three standard deviations. You might find your dataset has a few rows doing most of the damage.
Related on Everyday Data Science: Scaling Gave SVM 8 Points and Trees Nothing. I Ran Four Models Raw and Scaled. · Five Leaks That Inflate Your AUC: I Measured Each One · Drift Is Three Different Failures, and One Metric Cannot See Them All
Sources: scikit-learn, HuberRegressor · Wikipedia, Winsorizing
98% Accurate and Useless: Six Imbalance Fixes, Measured on a 2% Positive Class
Next →Your 0.85 Meant 0.98: A 20,000-Row Calibration Test That Caught a Top Model Misstating Its Own Odds
About the writer
Data Scientist & AI Researcher
Data scientist and AI researcher at Pace University. I coined Artificial Frictional Unemployment, and built the first machine learning model for crop yield prediction in Sierra Leone. Author of Understanding Agentic AI. I write about agentic systems and applied ML, with a bias toward what actually works, and who gets left out when it doesn't.
Found this useful? Passing it on to someone who builds is the best way to help the publication grow.
Built something worth sharing? Write it up for us →