Modeltime unlocks time series forecast models and machine learning in one framework
540
stars
85
forks
source link
Add RMSLE metric to `extended_forecast_accuracy_metric_set` function in yardstick-metric-sets.R script #229
Open
rserran opened 1 year ago
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.