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

Formula for mpe() #345

Open
FelicienLL opened this issue Nov 28, 2022 · 1 comment
Open

Formula for mpe() #345

FelicienLL opened this issue Nov 28, 2022 · 1 comment

Comments

@FelicienLL
Copy link

Hello,

I'm not sure the implementation of Mean Percentage Error is correct there:

error <- (truth - estimate) / truth

In my opinion it should be calculated by doing estimate - truth instead of truth - estimate. See below, the estimator clearly over-estimates the observations, yet a negative bias is calculated. Is this running as expected ?

df <- data.frame(
  actual = c(1, 2, 3, 4), 
  prediction = c(1.1, 2.2, 3.3, 4.4)
)

yardstick::mpe(df, truth = actual, estimate = prediction)
#> # A tibble: 1 x 3
#>   .metric .estimator .estimate
#>   <chr>   <chr>          <dbl>
#> 1 mpe     standard       -10.0

In addition, I would divide the results with abs(truth) instead of truth to preserve the sign of the difference if the actual value is negative.

Thanks in advance.

Félicien

@EmilHvitfeldt
Copy link
Member

The formula follows the equation from wikipedia https://en.wikipedia.org/wiki/Mean_percentage_error. This isn't well reflected in the documentation, so I'm going to keep this issue open to deal with that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants