Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predictions and Test & Score: MAPE produces value where it should fail #7041

Open
wvdvegte opened this issue Feb 27, 2025 · 1 comment
Open
Labels
bug A bug confirmed by the core team needs discussion Core developers need to discuss the issue snack This will take an hour or two

Comments

@wvdvegte
Copy link

wvdvegte commented Feb 27, 2025

What's wrong?
The formula for the Mean Absolute Percentage Error (see here or here) produces a zero division if the test data contains actual values that are zero.
Yet Predictions and Test & Score produce a (very large) value for MAPE if there are zeroes in the test data.

How can we reproduce the problem?
In the attached workflow, Formula is used to compute the Absolute Percentage Error for every record, of which MAPE is the mean over all rows. As it should, Formula fails if rows where the target equals zero are included, but at the same time Predictions and Test & Score produce very large values for MAPE.

MAPE 0div.zip

Perhaps my idea to include MAPE wasn't a very good one, since it is a problematic measure. Perhaps consider adding sMAPE (Python code provided here) or even replacing MAPE by it.

@wvdvegte wvdvegte added the bug report Bug is reported by user, not yet confirmed by the core team label Feb 27, 2025
@janezd
Copy link
Contributor

janezd commented Mar 6, 2025

Scipy tries to be smart and divides by the smallest non-zero float, resulting in an essentially arbitrarily chosen large value.

MAPE is trivial to compute: I believe we should replace it with our own, proper implementation which returns inf (and fix the widget, if it can't handle it). This will make the score useless in case of zero values in test data, but it is what it is.

I like sMAPE. I think we should add it.

@janezd janezd added bug A bug confirmed by the core team needs discussion Core developers need to discuss the issue snack This will take an hour or two and removed bug report Bug is reported by user, not yet confirmed by the core team labels Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug confirmed by the core team needs discussion Core developers need to discuss the issue snack This will take an hour or two
Projects
None yet
Development

No branches or pull requests

2 participants