Skip to content

DOC improve conventions used in MAPE #30012

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

Merged
merged 6 commits into from
Oct 8, 2024

Conversation

Rachit23110261
Copy link
Contributor

@Rachit23110261 Rachit23110261 commented Oct 5, 2024

Reference Issues/PRs

Fixes #30008.

What does this implement/fix? Explain your changes.

This pull request addresses an issue in the documentation related to the Mean Absolute Percentage Error (MAPE) formula. The following changes have been made:

  • Clarified the Output Range: Updated the documentation to indicate that the MAPE formula represents a relative error and its output is in the range of ([0, \infty)), not ([0, 1]) or ([0, 100]).
  • Removed Upper Bound Notion: Removed any references to a maximum error value, as MAPE can indeed be arbitrarily large, allowing for errors exceeding 100%.
  • Added Examples: Included examples to illustrate cases where the MAPE could be 1 (100%) or higher, ensuring clarity that the returned value is not a percentage in the traditional sense despite the term "percentage" in its name.

These changes aim to improve user understanding and align the documentation with the intended use of the MAPE metric.

Any other comments?

Please feel free to reach out if there are any questions or if further adjustments are required. I appreciate your time and attention to this contribution.

Copy link

github-actions bot commented Oct 5, 2024

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 71f1446. Link to the linter CI: here

@glemaitre glemaitre self-requested a review October 7, 2024 07:23
Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, a couple of feedbacks

Comment on lines 333 to 336
MAPE output is a relative measure of error that does not have an upper bound, unlike typical percentages.
It can return values greater than 1 (e.g., 2 representing a 200% error). For example, an error of 1
represents a 100% deviation from the true value. Read more in the
:ref:`User Guide <mean_absolute_percentage_error>`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first sentence is incorrect: typical percentage can exceed 100%. Also you need to make sure to not have more than 88 characters per line and no trailing space.

This is the reason for the linter CI to raise error.

Here is my suggestion to keep the docstring short.

Suggested change
MAPE output is a relative measure of error that does not have an upper bound, unlike typical percentages.
It can return values greater than 1 (e.g., 2 representing a 200% error). For example, an error of 1
represents a 100% deviation from the true value. Read more in the
:ref:`User Guide <mean_absolute_percentage_error>`.
Note that we are not using the common "percentage" definition: the percentage
in the range [0, 100] is converted to a relative value in the range [0, 1]
by dividing by 100. Thus, an error of 200% corresponds to a relative error of 2.
Read more in the :ref:`User Guide <mean_absolute_percentage_error>`.

Comment on lines 2463 to 2464
For example, if the true value is 1 and the predicted value is 2, the MAPE will be 1 (or 100% error).
Similarly, if the true value is 1 and the predicted value is 3, the MAPE will be 2 (or 200% error).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not document it here. Instead we should amend the note below (this is currently incorrect).

You can reuse part of my other suggestion to amend it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure @glemaitre, I will implement this fix.

@glemaitre glemaitre changed the title Fix MAPE documentation: clarify output range and provide examples DOC improve conventions used in MAPE Oct 7, 2024
@glemaitre glemaitre self-requested a review October 8, 2024 16:35
Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a fix. The rendering looks good.

Enabling auto-merge.

@glemaitre glemaitre enabled auto-merge (squash) October 8, 2024 17:24
@glemaitre
Copy link
Member

Thanks @Rachit23110261

@glemaitre glemaitre merged commit 35f106c into scikit-learn:main Oct 8, 2024
28 checks passed
BenJourdan pushed a commit to gregoryschwartzman/scikit-learn that referenced this pull request Oct 11, 2024
Co-authored-by: Guillaume Lemaitre <guillaume@probabl.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC update MAPE description
2 participants