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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions doc/modules/model_evaluation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2489,11 +2489,11 @@ relative percentage error with respect to actual output.

.. note::

The MAPE formula here represents a relative error and outputs a value in the
range [0, 1]. It is not a percentage in the range [0, 100] and a value of 100
does not mean 100% but 1e2. The motivation for the MAPE formula here to be in
the range [0, 1] is to be consistent with other error metrics in scikit-learn
such as `accuracy_score`.
The MAPE formula here does not represent 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.
The motivation here is to have a range of values that is more consistent with other
error metrics in scikit-learn, such as `accuracy_score`.

To obtain the mean absolute percentage error as per the Wikipedia formula,
multiply the `mean_absolute_percentage_error` computed here by 100.
Expand Down
11 changes: 5 additions & 6 deletions sklearn/metrics/_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,11 @@ def mean_absolute_percentage_error(
):
"""Mean absolute percentage error (MAPE) regression loss.

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
: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>`.

.. versionadded:: 0.24

Expand Down