Skip to content
DeepForgeby svx
All problems

IQN Quantile Huber Loss

Problem

Compute the IQN quantile Huber loss for one predicted quantile value.

With delta = target - predicted, the Huber term is 0.5 * delta^2 when |delta| <= kappa and kappa * (|delta| - 0.5 * kappa) otherwise, and the quantile weight is (1 - tau) when delta < 0 else tau. Return weight * huber / kappa. kappa is positive.

Hint

The asymmetric weight |tau - 1{delta < 0}| turns regression into quantile estimation.

Test cases

case 1
in: [1,1.5,0.5,1]
expected: 0.0625
case 2
in: [1,2.5,0.9,1]
expected: 0.9
case 3
in: [2,1,0.1,0.5]
expected: 0.675
case 4
in: [0,0,0.5,1]
expected: 0
case 5
in: [3,2,0.9,0.25]
expected: 0.08749999999999998
Starter codePython
def iqn_quantile_huber(predicted, target, tau, kappa):
    # Your code here
    pass

5 test cases · run your code against them in the editor