Creates an Ensemble Model using Mean/Median Averaging

ensemble_average(object, type = c("mean", "median"))

Arguments

object

A Modeltime Table

type

Specify the type of average ("mean" or "median")

Value

A mdl_time_ensemble object.

Details

The input to an ensemble_average() model is always a Modeltime Table, which contains the models that you will ensemble.

Averaging Methods

The average method uses an un-weighted average using type of either:

Examples

# \donttest{ library(tidymodels)
#> ── Attaching packages ────────────────────────────────────── tidymodels 0.1.4 ──
#> broom 0.7.9 recipes 0.1.17 #> dials 0.0.10 rsample 0.1.0 #> dplyr 1.0.7 tibble 3.1.5 #> ggplot2 3.3.5 tidyr 1.1.4 #> infer 1.0.0 tune 0.1.6 #> modeldata 0.1.1 workflows 0.2.3 #> parsnip 0.1.7 workflowsets 0.1.0 #> purrr 0.3.4 yardstick 0.0.8
#> ── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ── #> x purrr::discard() masks scales::discard() #> x dplyr::filter() masks stats::filter() #> x dplyr::lag() masks stats::lag() #> x recipes::step() masks stats::step() #> Use tidymodels_prefer() to resolve common conflicts.
#> ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
#> readr 2.0.2 forcats 0.5.1 #> stringr 1.4.0
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ── #> x readr::col_factor() masks scales::col_factor() #> x purrr::discard() masks scales::discard() #> x dplyr::filter() masks stats::filter() #> x stringr::fixed() masks recipes::fixed() #> x dplyr::lag() masks stats::lag() #> x readr::spec() masks yardstick::spec()
library(timetk) # Make an ensemble from a Modeltime Table ensemble_fit <- m750_models %>% ensemble_average(type = "mean") ensemble_fit
#> ── Modeltime Ensemble ─────────────────────────────────────────── #> Ensemble of 3 Models (MEAN) #> #> # Modeltime Table #> # A tibble: 3 × 3 #> .model_id .model .model_desc #> <int> <list> <chr> #> 1 1 <workflow> ARIMA(0,1,1)(0,1,1)[12] #> 2 2 <workflow> PROPHET #> 3 3 <workflow> GLMNET
# Forecast with the Ensemble modeltime_table( ensemble_fit ) %>% modeltime_forecast( new_data = testing(m750_splits), actual_data = m750 ) %>% plot_modeltime_forecast( .interactive = FALSE, .conf_interval_show = FALSE )
#> Warning: 'keep_original_cols' was added to `step_dummy()` after this recipe was created. #> Regenerate your recipe to avoid this warning.
#> Warning: 'keep_original_cols' was added to `step_dummy()` after this recipe was created. #> Regenerate your recipe to avoid this warning.
#> Warning: 'keep_original_cols' was added to `step_dummy()` after this recipe was created. #> Regenerate your recipe to avoid this warning.
#> Warning: 'keep_original_cols' was added to `step_dummy()` after this recipe was created. #> Regenerate your recipe to avoid this warning.
#> Warning: 'keep_original_cols' was added to `step_dummy()` after this recipe was created. #> Regenerate your recipe to avoid this warning.
#> Warning: 'keep_original_cols' was added to `step_dummy()` after this recipe was created. #> Regenerate your recipe to avoid this warning.
#> Warning: 'keep_original_cols' was added to `step_dummy()` after this recipe was created. #> Regenerate your recipe to avoid this warning.
# }