Foundations to Frontier
Tests
D. Classical Machine Learning › D1 Linear Models for Regression

Huber Regression

Huber regression replaces the squared loss with Huber's loss, quadratic for small residuals and linear for large ones, so a few wild observations cannot dominate the fit. It is the classic M-estimator: nearly as efficient as least squares on clean Gaussian data, yet much less affected by outliers in y. It is fitted by iteratively reweighted least squares with a robust residual scale, and its tuning constant δ = 1.345σ gives 95% efficiency at the normal model. This page covers the loss and influence function, IRLS, scale estimation, the choice of δ, and the key limitation: like all M-estimators, it is not robust to high-leverage outliers. In the exercises you implement Huber regression by IRLS with MAD scale and show both its robustness to vertical outliers and its breakdown under a leverage point; then you measure the efficiency–robustness trade-off of δ against OLS and least absolute deviations.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Don’t let a few shouters run the meeting

Least squares listens to everyone, and the louder you are (the bigger your error), the more you count: squared. One shouting outlier can drag the line. Huber regression listens normally to people speaking calmly, but caps how much anyone can count, so a few shouters can’t take over. It still listens to them a little: they are turned down, not thrown out.

Huber regression: down-weighting large residuals
outliers:
ψ(r): pull of a residual
slope: true 0.80 · OLS 1.21 · Huber 0.87 · mean weight of outliers 0.11
Dot size and opacity show each point's weight; orange dots are the planted outliers; the dotted green line is the truth. Smaller δ caps the pull of large residuals sooner (more robust, slightly less precise on clean data). Leverage outliers pull the fit toward themselves so their residuals look small: Huber cannot see them, and robust methods such as RANSAC or Theil–Sen are needed.
Why engineers care

Telemetry and lab data contain glitches: a stuck sensor, a transmission error, a mislabeled unit. Huber regression is a simple, drop-in replacement for least squares that tolerates such glitches in the measured response without hand-cleaning, and it is standard in robust state estimation (robust kernels in SLAM and bundle adjustment).

📝 Quick check (Level 0)
0/3 answered
  1. 1. Huber regression treats big errors…
  2. 2. On clean data, Huber regression is…
  3. 3. In the demo, leverage outliers…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Weights by hand

Huber regression can be computed by reweighting. Each point gets weight 1 if its scaled residual |r|/s ≤ δ, and δ/(|r|/s) otherwise.

With δ = 1.345 and s = 1:

Residual r Weight Effective pull w·r
0.5 1 0.5
1.0 1 1.0
4.0 1.345/4 = 0.34 1.345
30 0.045 1.345

A residual of 30 pulls no harder than one of 1.345, while in least squares it would pull 30 times harder than a residual of 1.

The steps in plain English:

  1. Start with least squares.
  2. Compute residuals and a robust spread: MAD = 1.4826 × median |r − median r|.
  3. Give each point its Huber weight.
  4. Refit weighted least squares.
  5. Repeat until the coefficients stop changing.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Weight of a scaled residual 2.69 with δ = 1.345?
  2. 2. Why use the MAD rather than the standard deviation for scale?
  3. 3. IRLS repeats…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.

The M-estimator

Objective: minimise Σ ρ_δ((yᵢ − xᵢᵀβ)/s), where ρ_δ(r) = ½r² if |r| ≤ δ and δ(|r| − δ/2) otherwise.

Estimating equation: Σ ψ_δ(rᵢ/s)·xᵢ = 0, with the influence function ψ_δ(r) = clip(r, −δ, δ). It is bounded, so no single residual can exert unlimited pull.

IRLS: wᵢ = ψ(rᵢ)/rᵢ. Then solve (XᵀWX)β = XᵀWy and repeat. Each step does not increase the objective, so the iteration converges (the objective is convex for fixed s).

Scale:

  • re-estimate s by the MAD of the residuals each iteration; or
  • estimate β and s jointly (Huber’s “proposal 2”, used by scikit-learn’s HuberRegressor).

Choosing δ: δ = 1.345 gives 95% asymptotic efficiency at normal errors. Smaller δ is more robust but less efficient; δ → 0 approaches least absolute deviations, and δ → ∞ gives OLS.

from sklearn.linear_model import HuberRegressor
model = HuberRegressor(epsilon=1.35, alpha=0.0).fit(X, y)   # epsilon = δ; alpha = optional L2 penalty
print(model.coef_, model.scale_, model.outliers_.sum(), "flagged")
import statsmodels.api as sm; sm.RLM(y, sm.add_constant(X), M=sm.robust.norms.HuberT(t=1.345)).fit()

Use it when some y values are corrupted but the x values are trustworthy. Do not rely on it against bad x values (leverage points); use RANSAC, Theil–Sen or MM-estimators (D1.12, D1.13).

🐍 Exercise 1: Huber regression by IRLS
Implement Huber's loss and weights, the MAD scale, and Huber regression by iteratively reweighted least squares; show that with 10% vertical outliers it recovers the true line while OLS does not, that outliers get small weights, that on clean data it matches OLS, and that a single extreme leverage point still breaks it.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Huber's ψ function is…
  2. 2. δ = 1.345 is chosen for…
  3. 3. As δ → ∞ Huber regression becomes…

Level 3: Advanced

★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.

Robust statistics view

Influence function and breakdown.

  • An estimator’s influence function measures the effect of an infinitesimal contamination at a point. Huber’s is bounded in the residual direction (via ψ) but unbounded in x, because the estimating equation multiplies by xᵢ.
  • The breakdown point, the fraction of arbitrary contamination that can carry the estimate anywhere, is therefore 0 for regression M-estimators when x can be contaminated. A single far-out leverage point suffices (exercise 1).

Efficiency. The asymptotic relative efficiency at normal errors is E[ψ′]²/E[ψ²] (scale fixed). It equals 0.95 at δ = 1.345, and LAD’s is 2/π ≈ 0.64.

Fixing leverage:

  • GM-estimators down-weight high-leverage x’s;
  • MM-estimators (Yohai, 1987) start from a high-breakdown S-estimate and then do an efficient M-step, giving 50% breakdown with high efficiency;
  • LTS (least trimmed squares) and RANSAC (D1.12) use high-breakdown random subsets.

Related losses: Tukey’s bisquare (redescending, ψ → 0 for large r, can reject outliers fully but non-convex), Cauchy, and Welsch. These are the robust kernels of computer vision.

Interview questions.

  • Why is Huber regression not robust to leverage points? A leverage point pulls the fit until its own residual is small, so its weight stays near 1.
  • Convex or not? The Huber loss is convex, so there is a unique solution for fixed scale. Redescending losses are not convex.
📝 Quick check (Level 3)
0/3 answered
  1. 1. Breakdown point of Huber regression with contaminated x?
  2. 2. Tukey's bisquare is…
  3. 3. MM-estimators combine…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Efficiency versus robustness, measured

History. Huber’s 1964 paper founded robust statistics, introducing M-estimators and the minimax-optimal Huber loss for contaminated normal models. Huber (1973) extended it to regression. Hampel (1974) introduced the influence function. Rousseeuw (1984) introduced high-breakdown methods (LMS, LTS).

Exercise 1. With 10% vertical outliers (y + 30):

  • the OLS intercept shifts from 1 to 3.95, while Huber’s stays at 1.24 with slope 1.987;
  • the outliers’ weights fall below 0.2, and the MAD scale is about 1;
  • on clean data, Huber matches OLS;
  • a single point at x = 200 with y = 0 drags the Huber slope from 2 to −0.01.

Exercise 2: the trade-off. Setup: n = 60, y = 1 + 2x + N(0, 1), 200 datasets. Efficiency is the variance of the OLS slope divided by the method’s slope variance on clean data. Vertical outliers: 15% of points with x > 5 have y + 20. Leverage outliers: 10% of points moved to x = 25–30 with y ≈ 0.

Method Efficiency (clean) Slope bias, vertical outliers Slope bias, leverage outliers
OLS 1.00 +0.93 −2.15
Huber δ = 3 1.00 +0.47 −2.15
Huber δ = 1.345 0.93 +0.14 −2.15
Huber δ = 0.5 0.86 +0.10 −2.20
LAD (δ → 0) 0.70 +0.10 −2.00
  • δ = 1.345 keeps 93% of OLS precision on clean data (theory: 95%; scale estimation from 60 points costs a little) while cutting the outlier bias by 85%.
  • Smaller δ buys little extra robustness for a growing efficiency cost; LAD is near its theoretical 64% efficiency.
  • Against leverage outliers every M-estimator fails (the slope collapses toward 0). They need high-breakdown methods.
🐍 Exercise 2 (research): the efficiency–robustness trade-off
Compare OLS, Huber regression with δ = 3, 1.345 and 0.5, and least absolute deviations on clean data (efficiency), with vertical outliers and with leverage outliers (slope bias), over 200 simulated datasets.

Huber regression in AI, robotics and aerospace

  • SLAM and bundle adjustment: Huber kernels on reprojection errors reject bad feature matches.
  • Navigation filters: Huber-based robust Kalman filters tolerate sensor glitches.
  • Calibration with occasional faults: robust fits of sensor calibration curves.
  • Training robust models: smooth L1 (Huber) loss in object-detection box regression.

References

  1. P. J. Huber (1964). “Robust estimation of a location parameter.” Annals of Mathematical Statistics 35(1).
  2. P. J. Huber (1973). “Robust regression: asymptotics, conjectures and Monte Carlo.” Annals of Statistics 1(5).
  3. F. R. Hampel (1974). “The influence curve and its role in robust estimation.” JASA 69(346).
  4. V. J. Yohai (1987). “High breakdown-point and high efficiency robust estimates for regression.” Annals of Statistics 15(2).
  5. R. A. Maronna, R. D. Martin, V. J. Yohai, M. Salibián-Barrera (2019). Robust Statistics: Theory and Methods, 2nd ed. Wiley.