All problems
Average Pinball Loss
Problem
Compute the mean pinball loss across several quantiles. forecasts holds one forecast list per quantile and quantiles the matching probabilities. For each pair let d = actual - forecast; add q * d when d is non-negative and (q - 1) * d otherwise, then average over all actual-forecast pairs.
Return 0.0 when there are no pairs.
Hint
Underprediction is penalized by q and overprediction by 1 - q.
Test cases
case 1
in: [[10,12,14],[[11,11,11],[15,15,15]],[0.5,0.9]]
expected: 0.5666666666666667
case 2
in: [[5],[[5]],[0.5]]
expected: 0
case 3
in: [[1,2],[[0,0],[3,3]],[0.1,0.9]]
expected: 0.15
case 4
in: [[1,2,3],[[2,2,2]],[0.5]]
expected: 0.3333333333333333
Starter codePython
def average_pinball_loss(actual, forecasts, quantiles):
# Your code here
pass4 test cases · run your code against them in the editor