R/modeltime_wfs_multifit.R
modeltime_wfs_multifit.Rd
allows a workflow_set object to be fitted over multiple time series, using models from the 'modeltime' package.
modeltime_wfs_multifit(serie, .prop, .wfs)
serie | nested time series. |
---|---|
.prop | series train/test partition ratio. |
.wfs | worklows_set object. |
A list of 2 items. The first component is a tibble with a first column that contains the name of the series, and a second column called 'nested_column' that stores the time series, then a column for each workflow for each series are stored. The last 2 columns, 'nested_model' and 'calibration', store the 'n' trained workflows for each series and the adjustment metrics on the test partition. The second element is a tibble saved with the name of 'models_accuracy', it allows to visualize the performance of each workflow for each series according to a set of metrics.
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) sknifedatar::modeltime_wfs_multifit(.wfs = wfsets, .prop = 0.8, serie = df_emae)#>#> ✓ Workflow training finished OK.#>#> ── 1 models fitted ♥ ───────────────────────────────────────────────────────────#>#> 0 models deleted x ──#>#> $table_time #> # A tibble: 2 x 5 #> sector nested_column R_date_M_mars nested_model calibration #> <chr> <list> <list> <list> <list> #> 1 Comercio <tibble [194 × 2… <workflow> <model_time [1 × … <model_time [1 ×… #> 2 Ensenanza <tibble [194 × 2… <workflow> <model_time [1 × … <model_time [1 ×… #> #> $models_accuracy #> # A tibble: 2 x 11 #> name_serie .model_id .model_names .model_desc .type mae mape mase smape #> <chr> <int> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 Comercio 1 R_date_M_mars EARTH Test 10.8 7.33 0.848 7.29 #> 2 Ensenanza 1 R_date_M_mars EARTH Test 5.15 3.23 3.74 3.16 #> # … with 2 more variables: rmse <dbl>, rsq <dbl> #>