All problems
Mean Absolute Percentage Error with Zero Handling
Problem
Compute the mean absolute percentage error in percent. Terms with an actual value of 0 are skipped and the mean is taken over the remaining samples; if all actuals are 0, return 0.0.
Empty input returns 0.0.
Hint
Divide the absolute error by the actual value and report a percentage.
Test cases
case 1
in: [[100,200],[110,190]]
expected: 7.500000000000001
case 2
in: [[10],[12]]
expected: 20
case 3
in: [[0,10],[0,5]]
expected: 50
case 4
in: [[],[]]
expected: 0
Starter codePython
def mean_absolute_percentage_error(y_true, y_pred):
# Your code here
pass4 test cases · run your code against them in the editor