The Huber loss with threshold δ is ℓ(r)=12r2 for ∣r∣≤δ and δ(∣r∣−12δ) otherwise, where r is the residual. How do you derive ℓ′(r), show that ℓ is convex, and use this to show that the optimal constant c for the data {1,2,3,4,100} with δ=1.5 is c=3?

Supervised learning, Robust regression
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can differentiate a piecewise loss, argue convexity from a monotone derivative, and turn that into a global optimality check.

Key idea

ℓ′(r)=ψ(r)=max⁡(−δ,min⁡(δ,r)), the residual clipped to [−δ,δ]. It is continuous and non-decreasing, so ℓ is convex. For a constant fit, ddc∑iℓ(yi−c)=−∑iψ(yi−c), so any c with ∑iψ(yi−c)=0 is a global minimiser.

Steps

  1. This is the harder follow-up to `huber-loss-constant-fit-outlier`, which comes first. Differentiate each piece. For ∣r∣≤δ: ℓ′(r)=r. For r>δ: ℓ(r)=δr−12δ2, so ℓ′(r)=δ. For r<−δ: ℓ′(r)=−δ. This is ψ(r).
  2. Check that the pieces join smoothly. At r=δ the values agree, 12δ2=δ(δ−12δ), and the slopes agree, both equal to δ. So ℓ is differentiable everywhere.
  3. Convexity: ψ equals r in the middle and is flat outside, so it never decreases as r grows. A differentiable function whose derivative is non-decreasing is convex, so any stationary point is a global minimum.
  4. Constant fit: with residual ri=yi−c, the chain rule gives ddc∑iℓ(yi−c)=−∑iψ(yi−c). Set it to zero: S(c)=∑iψ(yi−c)=0. S is non-increasing in c.
  5. Test c=3 with δ=1.5. Residuals −2,−1,0,1,97 clip to −1.5,−1,0,1,1.5, and the sum is 0. Nearby, S(2.9)=0.3>0 and S(3.1)=−0.3<0, so S crosses zero at 3 and this is the minimiser.
  6. Contrast with squared loss. The mean c=22 gives S(22)=−1.5×4+1.5=−4.5≠0, so it is not the Huber optimum. The outlier 100 can add at most δ=1.5 to S, so it cannot drag c far.

Common mistakes

How long your answer should be

Half a page, about 4 minutes.

Read this

Previous in Supervised learning: Two classes have one-dimensional Gaussian class-conditional densities with the same variance σ2, means μ1<μ2 and priors P(C1), P(C2). What is the Bayes decision boundary x∗ (derive it), and what is it for μ1=0, μ2=4, σ2=1, P(C1)=0.9, P(C2)=0.1, and which class is predicted at x=2.4?
Next in Supervised learning: You want an ensemble of linear SVMs. What are two different ways to get different linear SVMs from one training set, why does each make the SVMs differ, and why must the ensemble combine their votes rather than average their real-valued scores?