An error of 10 means something different for a house priced at 100 thousand than for one priced at 10 million. Mean absolute percentage error (MAPE) expresses each error as a fraction of the true value, then averages those fractions. The result reads as a percentage: a MAPE of 5 means the forecasts are off by about 5 percent on average.
Implement mean_absolute_percentage_error(y_true, y_pred), which returns 100 * mean(|y_true - y_pred| / |y_true|).
ValueError.y_true makes the percentage undefined: raise ValueError.Open one at a time. Each gives away a little more than the last.
Divide the absolute error by the absolute true value elementwise, then take the mean, then multiply by 100.
Check np.any(y_true == 0) before dividing so the error message is clear.
No results yet
Run your code to check it against the examples, or submit to run every test.