All problems
Huber Threshold Apply
Problem
Apply the Huber gradient (clipped residual).
Return delta when residual > delta, -delta when residual < -delta, and residual itself inside the band. This caps the influence of large residuals.
Hint
Huber clips the residual into the interval [-delta, delta].
Test cases
case 1
in: [0.5,1]
expected: 0.5
case 2
in: [2,1]
expected: 1
case 3
in: [-3,2]
expected: -2
case 4
in: [0,1]
expected: 0
Starter codePython
def huber_gradient_apply(residual, delta):
# Your code here
pass4 test cases · run your code against them in the editor