Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-080

Quantile Loss

Problem

Compute the mean quantile (pinball) loss for quantile q: q*r when r >= 0 and (1 - q)*(-r) otherwise, where r = y - pred.

Empty input returns 0.0.

Hint

Over-predictions and under-predictions are penalized with different weights q and 1-q.

Test cases

case 1
in: [[1,2,3,4],[1.5,1.5,1.5,1.5],0.5]
expected: 0.625
case 2
in: [[1,2,3,4],[1.5,1.5,1.5,1.5],0.9]
expected: 1.025
case 3
in: [[2,4],[1,1],0.25]
expected: 0.5
case 4
in: [[],[],0.5]
expected: 0
Starter codePython
def quantile_loss(y_true, y_pred, q):
    # Your code here
    pass

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