MSE punishes large errors quadratically, so a single wild outlier can dominate the whole loss. MAE treats every error the same regardless of size, but its gradient never shrinks even for tiny errors near zero. Huber loss is a compromise: quadratic for small errors, linear for large ones.
Let a = y_true - y_pred be the residual for one sample:
Task: write huber_loss(y_true, y_pred, delta) returning the mean loss over all samples, rounded to 4 decimal places.
delta is the threshold where the loss switches from quadratic to linear.|a| = delta — both give 0.5 * delta**2 there.