Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to interpret MAPE in Python (Sklearn)

I am trying to interpret the value that I get out of sklearn.metrics.mean_absolute_percentage_error(y_true, y_pred), but have difficulty to understand the interpretation. I need to interpret the result based on below accepted (?) schema enter image description here

Based on the official Python explanation:

Note here that the output is not a percentage in the range [0, 100] and a value of 100 does not mean 100% but 1e2. Furthermore, the output can be arbitrarily high when y_true is small (which is specific to the metric) or when abs(y_true - y_pred) is large (which is common for most regression metrics). Read more in the User Guide.

So again,

from sklearn.metrics import 
mean_absolute_percentage_error
y_true = [3, -0.5, 2, 7] 
y_pred = [2.5, 0.0, 2, 8]

mean_absolute_percentage_error(y_true, y_pred)
0.3273...

what does 0.32 mean? if this does not mean 32%, then what?

I am using this function and I am getting these results for two different data sets:

0.3 for one set of my data

1.3 for another set of my data

I can say the first set is more accurate, but can I say 30% is MAPE of the first set and 130% is MAPE of the second set, I guess I cannot. So How do I need to interpret these outputs?

like image 833
Mohsen Sichani Avatar asked Nov 02 '25 11:11

Mohsen Sichani


1 Answers

If you look at the source code for the mape calculation in sklearn you will see the value is not multiplied by 100, so it is not a percentage. Therefore, while interpreting your results, you should multiply the mape value by a 100 to have it in percentage. You must also pay a close attention to your actual data if there is value close to 0 then they could cause mape to be large. For instance, you could look at the wikipedia link on mape formulation. I suggest you plot the actual value and the predicted value as a scatter plot and then compare it with the line y=x.

like image 66
Pygin Avatar answered Nov 04 '25 01:11

Pygin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!