When do you use Huber loss instead of MSE or MAE?
Written by the mlprep team · Updated
Compare MSE, MAE, and Huber loss for regression. When does each break down and how do you choose?
MSE (L2 loss)#
Gradient is proportional to the error. Large errors produce large gradients, which means MSE is sensitive to outliers — a single example with a large residual dominates training. MSE is appropriate when:
- Errors are roughly Gaussian
- Large errors are genuinely worse than small errors in proportion to their square
- You want the model to predict the conditional mean
MAE (L1 loss)#
Gradient is constant (±1) regardless of error magnitude. More robust to outliers. Appropriate when:
- Outliers are frequent and should not dominate
- You want the model to predict the conditional median
- The error distribution has heavy tails
Drawback: gradient is undefined at zero and is a constant step size everywhere, which can make optimization slow and less stable near the solution.
Huber loss#
Quadratic near zero (smooth, fast convergence) and linear for large errors (robust to outliers). δ is a hyperparameter that defines the transition.
Huber loss combines the best of both: precise gradient signal near the solution, outlier robustness far from it. Default choice for robust regression when you don't know the outlier fraction.
Quantile loss#
MAE is quantile loss at τ=0.5. Setting τ=0.9 trains the model to predict the 90th percentile of the conditional distribution, which matters when underprediction and overprediction have asymmetric costs.
Examples:
- Predict delivery ETA conservatively (τ=0.8): better to overestimate arrival time than to miss it
- Predict demand for safety stock (τ=0.95): stockouts are more expensive than excess inventory
Choosing in practice#
| Situation | Loss | |-----------|------| | Clean labels, roughly Gaussian errors | MSE | | Heavy tails or frequent outliers | Huber or MAE | | Asymmetric cost of over vs underestimation | Quantile | | Unknown outlier level, need robustness | Huber with tuned δ |
Senior/staff considerations#
Loss function choice is a modeling assumption about the error distribution. MSE assumes Gaussian noise; MAE assumes Laplacian; Huber is a mixture. If the noise is actually Gaussian, MSE is statistically optimal (MLE). If you pick Huber for a clean Gaussian problem, you lose a small amount of efficiency; if you pick MSE for a heavy-tailed problem, outliers corrupt the model.
At scale, Huber loss is common in ranking and recommendation regression (predicting watch time, bid value, ETA). It is also used in reinforcement learning (DQN loss) because reward targets can be noisy and clipped error gradients improve stability.
Common traps#
- Using MSE on a label with known outliers and wondering why predictions are biased toward high values.
- Using MAE and getting slow, oscillating convergence near the optimum.
- Treating δ in Huber loss as a fixed constant rather than tuning it on validation data.
- Ignoring that loss function choice affects the conditional statistic the model learns: MSE → mean, MAE → median, quantile → quantile.
The key takeaway unlocks after you reveal an expert answer.
Key Takeaway
MSE is optimal for Gaussian noise but sensitive to outliers. MAE is robust but has constant gradients and predicts the median. Huber is quadratic near zero and linear for large errors — the default robust regression loss. Quantile loss extends MAE to predict arbitrary quantiles, useful when overestimation and underestimation have different costs.
Follow-up Questions to Test Yourself
Interviewers often pivot here once you cover the core concept.
- Why does MSE predict the conditional mean while MAE predicts the conditional median?
- How would you tune the δ parameter in Huber loss?
- You are predicting ad revenue per click. Clicks occasionally produce fraudulent high-value events. Which loss would you use and why?
How confident do you feel explaining this?
Track your understanding or flag it to revisit before your next loop.
Related Questions
Compare MSE, MAE, and Huber loss — when would you use each?
Explain cross-entropy loss — binary vs categorical, and why it works for classification
What is KL divergence and how does it relate to cross-entropy?
What is focal loss and when would you use it over cross-entropy?