Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-193

Relative Error Aggregation

Problem

Aggregate relative error as weighted absolute percentage error: sum(abs(actual - forecast)) / sum(abs(actual)).

Return 0.0 when actual is empty or its absolute sum is zero.

Hint

WAPE scales total error by total volume rather than averaging per-point ratios.

Test cases

case 1
in: [[100,200],[110,190]]
expected: 0.06666666666666667
case 2
in: [[10,20,30],[12,18,33]]
expected: 0.11666666666666667
case 3
in: [[5,5],[5,5]]
expected: 0
case 4
in: [[0,0],[1,1]]
expected: 0
Starter codePython
def relative_error_aggregation(actual, forecast):
    # Your code here
    pass

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