Firstly, kudos on the package.
I twould be good to add the potential to allow for an adjusted modell to feed into the cv process.
For instance we could feed it with custom holidays from the prophet internal dataset and add regressors as follows:
tune_prophet_custom <- function (df, horizon, units, args.list, regressor_to_use = NULL, ...){
available.args <- c("changepoint.prior.scale", "seasonality.prior.scale",
"holidays.prior.scale", "seasonality.mode", "changepoint.range")
if (!all(names(args.list) %in% available.args)) {
stop(paste("parameters that can be tuned are:", paste(paste0("\"",
available.args, "\""), collapse = ", ")))
}
if (length(args.list) == 0) {
stop("argument \"args.list\" cannot empty")
}
dots <- list(...)
all_params <- expand.grid(args.list)
tuning <- lapply(1:nrow(all_params), function(i) {
#arg <- c(list(df = df), dplyr::slice(all_params, i))
# I added
arg <- dplyr::slice(all_params, i)
arg$yearly.seasonality <- TRUE
arg$weekly.seasonality <- TRUE
arg$daily.seasonality <- FALSE
m <- do.call(prophet, arg)
m <- add_country_holidays(m, country_name = "DE")
if (is.character(regressor_to_use) && length(regressor_to_use) != 0L) {
for(i in regressor_to_use) {
m <- add_regressor(m, i)
}
}
m <- fit.prophet(m, df)
#
cv.arg <- c(list(model = m, horizon = horizon, units = units),
dots)
cv <- do.call(prophetuneR::par_cross_validation, cv.arg)
pm <- dplyr::select(prophet::performance_metrics(cv, rolling_window = 1),
-horizon)
return(pm)
})
result <- cbind(all_params, do.call(rbind, tuning))
return(result)
}
But mybe a more generic way would be suitable.
What do you think?
Firstly, kudos on the package.
I twould be good to add the potential to allow for an adjusted modell to feed into the cv process.
For instance we could feed it with custom holidays from the prophet internal dataset and add regressors as follows:
But mybe a more generic way would be suitable.
What do you think?