SciPy

scipy.special.huber

scipy.special.huber(delta, r) = <ufunc 'huber'>

Huber loss function.

\[\begin{split}\text{huber}(\delta, r) = \begin{cases} \infty & \delta < 0 \\ \frac{1}{2}r^2 & 0 \le \delta, | r | \le \delta \\ \delta ( |r| - \frac{1}{2}\delta ) & \text{otherwise} \end{cases}\end{split}\]
Parameters:
delta : ndarray

Input array, indicating the quadratic vs. linear loss changepoint.

r : ndarray

Input array, possibly representing residuals.

Returns:
res : ndarray

The computed Huber loss function values.

Notes

This function is convex in r.

New in version 0.15.0.

Previous topic

scipy.special.kl_div

Next topic

scipy.special.pseudo_huber