MAPE calculation in python
问题 I want to calculate Mean Absolute percentage error (MAPE) of predicted and true values. I found a solution from here, but this gives error and shows invalid syntax in the line mask = a <> 0 def mape_vectorized_v2(a, b): mask = a <> 0 return (np.fabs(a - b)/a)[mask].mean() def mape_vectorized_v2(a, b): File "<ipython-input-5-afa5c1162e83>", line 1 def mape_vectorized_v2(a, b): ^ SyntaxError: unexpected EOF while parsing I am using spyder3. My predicted value is a type np.array and true value