All problems
Kling-Gupta Efficiency
Problem
Compute the Kling-Gupta efficiency: 1 - sqrt((r - 1)^2 + (alpha - 1)^2 + (beta - 1)^2), where r is the Pearson correlation, alpha = std_forecast / std_actual, and beta = mean_forecast / mean_actual, all with population moments.
Return 0.0 when the lists are empty, mismatched, or any reference moment is zero.
Hint
The score decomposes into correlation, variability, and bias components.
Test cases
case 1
in: [[1,2,3,4],[1,2,3,4]]
expected: 0.9999999999999998
case 2
in: [[1,2,3,4],[2,2,2,2]]
expected: 0
case 3
in: [[1,2,3],[1,3,2]]
expected: 0.5000000000000001
case 4
in: [[2,4,6],[4,8,12]]
expected: -0.41421356237309515
Starter codePython
def kling_gupta_efficiency(actual, forecast):
# Your code here
pass4 test cases · run your code against them in the editor