Huber Loss Calculator
Calculate Huber loss, a robust regression loss combining MSE and MAE behavior.
About Huber Loss Calculator
Huber loss combines the best properties of MSE and MAE: for small residuals (|a| ≤ δ), it behaves like squared error, Huber(a) = 0.5 × a²; for large residuals (|a| > δ), it switches to a linear penalty, Huber(a) = δ × (|a| − 0.5 × δ). This makes it quadratic (and smoothly differentiable) near zero for stable gradients, while remaining linear — and therefore robust to outliers — for large errors, unlike pure MSE which lets outliers dominate the loss. The delta parameter controls where this transition happens: smaller delta makes the loss behave more like MAE, larger delta makes it behave more like MSE.
Formulas
Quadratic region (|a| ≤ δ)
L = 0.5 * a^2
- a
- Residual (predicted - actual)
- \delta
- Threshold between quadratic and linear regions
Linear region (|a| > δ)
L = delta * (|a| - 0.5 * delta)
- a
- Residual (predicted - actual)
- \delta
- Threshold between quadratic and linear regions
Worked example
With the default values below, Huber Loss Calculator returns Huber Loss of 2.000000. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Actual Value (y)
- 10
- Predicted Value (ŷ)
- 12.5
- Delta (δ)accepts 0–1,000
- 1
Results
- Huber Loss
- 2.000000
- Residual (ŷ − y)
- 2.5000
- Quadratic Region?
- false
Step by step
- 1Residual: a = ŷ − y= 2.5000
- 2Linear region (|a| > δ): δ × (|a| − 0.5 × δ)= 2.000000
Assumptions and limits
- The result is derived only from the 3 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 6 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
How do I choose the delta parameter?
Delta should reflect the scale of 'normal' residuals you expect — errors smaller than delta are treated as ordinary noise (quadratic penalty), while errors larger than delta are treated as likely outliers (linear penalty); it's often tuned via cross-validation or set based on domain knowledge of acceptable error magnitude.
Why is Huber loss preferred over MSE for noisy data?
MSE squares every error, so a few extreme outliers can dominate the total loss and distort model training; Huber loss caps the penalty growth to linear beyond delta, making the model less sensitive to a small number of extreme residuals.
What happens as delta approaches infinity or zero?
As delta → ∞, Huber loss behaves exactly like MSE everywhere (always quadratic); as delta → 0, it behaves increasingly like MAE (nearly always linear), so delta effectively interpolates between the two loss functions.
