All problems
CRPS from Quantile Losses
Problem
Approximate the continuous ranked probability score from quantile forecasts as CRPS = 2 * sum over k of QS_k / (K * n), where QS_k is the total pinball loss at quantile q_k, K the number of quantiles, and n the number of observations.
Return 0.0 when inputs are empty or when the counts of forecast lists and quantiles differ.
Hint
The quantile-score representation lets a finite set of quantiles approximate CRPS.
Test cases
case 1
in: [[10,12,14],[[9,11,13],[13,14,15]],[0.25,0.75]]
expected: 0.75
case 2
in: [[5],[[4],[6]],[0.1,0.9]]
expected: 0.19999999999999998
case 3
in: [[1,2,3],[[1,2,3]],[0.5]]
expected: 0
case 4
in: [[1,2],[],[]]
expected: 0
Starter codePython
def crps_from_quantile_losses(actual, forecasts, quantiles):
# Your code here
pass4 test cases · run your code against them in the editor