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

Add RMSLE metric to extended_forecast_accuracy_metric_set function in yardstick-metric-sets.R script #229

Open
rserran opened this issue Jul 6, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@rserran
Copy link

rserran commented Jul 6, 2023

Hi!

I've noticed that in Kaggle competitions, the RMSLE metric is used frequently instead of the RMSE.

This request is to add the RMSLE metric to the existing extended_forecast_accuracy_metric_set function in the yardstick-metric-sets.R script.

Julia Silge has a specific blog on the code to create this particular metric (see https://juliasilge.com/blog/nyc-airbnb/)

Code (very similar to maape code):

`library(rlang)

rmsle_vec <- function(truth, estimate, na_rm = TRUE, ...) {
rmsle_impl <- function(truth, estimate) {
sqrt(mean((log(truth + 1) - log(estimate + 1))^2))
}

metric_vec_template(
metric_impl = rmsle_impl,
truth = truth,
estimate = estimate,
na_rm = na_rm,
cls = "numeric",
...
)
}

rmsle <- function(data, ...) {
UseMethod("rmsle")
}
rmsle <- new_numeric_metric(rmsle, direction = "minimize")

rmsle.data.frame <- function(data, truth, estimate, na_rm = TRUE, ...) {
metric_summarizer(
metric_nm = "rmsle",
metric_fn = rmsle_vec,
data = data,
truth = !!enquo(truth),
estimate = !!enquo(estimate),
na_rm = na_rm,
...
)
}`

I can volunteer to add this code to the script.

Thanks for the attention and consideration to the request.

@mdancho84
Copy link
Contributor

Hi yes, would you mind submitting a PR and we can discuss.

@mdancho84 mdancho84 added the enhancement New feature or request label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants