Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-167

Index of Agreement

Problem

Compute Willmott's index of agreement: 1 - sum((forecast - actual)^2) / sum((abs(forecast - mean_actual) + abs(actual - mean_actual))^2).

Return 0.0 when the denominator is zero or actual is empty.

Hint

The index of agreement is bounded and less sensitive to extreme errors than R squared.

Test cases

case 1
in: [[1,2,3,4],[1,2,3,4]]
expected: 1
case 2
in: [[1,2,3,4],[2,2,2,2]]
expected: 0.4
case 3
in: [[1,2],[2,1]]
expected: 0
case 4
in: [[5,5,5],[5,5,5]]
expected: 0
Starter codePython
def index_of_agreement(actual, forecast):
    # Your code here
    pass

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