R/modeltime_wfs_multiforecast.R
modeltime_wfs_multiforecast.Rd
generates forecasts of a workflow set object over multiple time series.
modeltime_wfs_multiforecast(models_table, .h = NULL, .prop = NULL)
models_table | a tibble that comes from the output of the |
---|---|
.h | prediction horizon of the |
.prop | decimal number, time series split partition ratio. If ".h" is specified, this function predicts on the testing partition. |
a tibble, corresponds to the same tibble supplied in the 'models_table' parameter but with an additional column called 'nested_forecast' where the nested previews of the workflows on all the time series are stored.
library(dplyr) library(earth) df <- sknifedatar::emae_series datex <- '2020-02-01' df_emae <- df %>% dplyr::filter(date <= datex) %>% tidyr::nest(nested_column=-sector) %>% head(2) receta_base <- recipes::recipe(value ~ ., data = df %>% select(-sector)) mars <- parsnip::mars(mode = 'regression') %>% parsnip::set_engine('earth') wfsets <- workflowsets::workflow_set( preproc = list( R_date = receta_base), models = list(M_mars = mars), cross = TRUE) wfsets_fit <- sknifedatar::modeltime_wfs_multifit(.wfs = wfsets, .prop = 0.8, serie = df_emae)#>#> ✓ Workflow training finished OK.#>#> ── 1 models fitted ♥ ───────────────────────────────────────────────────────────#>#> 0 models deleted x ──#>sknifedatar::modeltime_wfs_multiforecast(wfsets_fit$table_time, .prop=0.8)#>#>#> # A tibble: 2 x 6 #> sector nested_column R_date_M_mars nested_model calibration nested_forecast #> <chr> <list> <list> <list> <list> <list> #> 1 Comerc… <tibble [194 … <workflow> <model_time … <model_tim… <tibble [233 ×… #> 2 Ensena… <tibble [194 … <workflow> <model_time … <model_tim… <tibble [233 ×…