All problems
Mean Absolute Percentage Error for Forecasts
Problem
Compute the mean absolute percentage error (MAPE) as a percentage: (100 / n) * sum(abs(actual[t] - forecast[t]) / abs(actual[t])).
All actual values are assumed to be nonzero. Return 0.0 when the actual list is empty.
Hint
Scale each error by the actual magnitude before averaging.
Test cases
case 1
in: [[100,200],[110,190]]
expected: 7.500000000000001
case 2
in: [[50],[55]]
expected: 10
case 3
in: [[10,10],[10,10]]
expected: 0
case 4
in: [[4,8],[5,6]]
expected: 25
Starter codePython
def mean_absolute_percentage_error(actual, forecast):
# Your code here
pass4 test cases · run your code against them in the editor