This is a boilerplate function to automatically create the following:
recipe
model specification
workflow
tuned model (grid ect)
calibration tibble and plot
Usage
ts_auto_smooth_es(
.data,
.date_col,
.value_col,
.formula,
.rsamp_obj,
.prefix = "ts_smooth_es",
.tune = TRUE,
.grid_size = 10,
.num_cores = 1,
.cv_assess = 12,
.cv_skip = 3,
.cv_slice_limit = 6,
.best_metric = "rmse",
.bootstrap_final = FALSE
)
Arguments
- .data
The data being passed to the function. The time-series object.
- .date_col
The column that holds the datetime.
- .value_col
The column that has the value
- .formula
The formula that is passed to the recipe like
value ~ .
- .rsamp_obj
The rsample splits object
- .prefix
Default is
ts_smooth_es
- .tune
Defaults to TRUE, this creates a tuning grid and tuned model.
- .grid_size
If
.tune
is TRUE then the.grid_size
is the size of the tuning grid.- .num_cores
How many cores do you want to use. Default is 1
- .cv_assess
How many observations for assess. See
timetk::time_series_cv()
- .cv_skip
How many observations to skip. See
timetk::time_series_cv()
- .cv_slice_limit
How many slices to return. See
timetk::time_series_cv()
- .best_metric
Default is "rmse". See
modeltime::default_forecast_accuracy_metric_set()
- .bootstrap_final
Not yet implemented.
Details
This uses modeltime::exp_smoothing()
and sets the parsnip::engine
to smooth_es
.
See also
https://business-science.github.io/modeltime/reference/exp_smoothing.html#ref-examples
https://github.com/config-i1/smooth
Other Boiler_Plate:
ts_auto_arima_xgboost()
,
ts_auto_arima()
,
ts_auto_croston()
,
ts_auto_exp_smoothing()
,
ts_auto_glmnet()
,
ts_auto_lm()
,
ts_auto_mars()
,
ts_auto_nnetar()
,
ts_auto_prophet_boost()
,
ts_auto_prophet_reg()
,
ts_auto_svm_poly()
,
ts_auto_svm_rbf()
,
ts_auto_theta()
,
ts_auto_xgboost()
Other exp_smoothing:
ts_auto_croston()
,
ts_auto_exp_smoothing()
,
ts_auto_theta()
Examples
# \donttest{
library(dplyr)
library(timetk)
library(modeltime)
data <- AirPassengers %>%
ts_to_tbl() %>%
select(-index)
splits <- time_series_split(
data
, date_col
, assess = 12
, skip = 3
, cumulative = TRUE
)
ts_smooth_es <- ts_auto_smooth_es(
.data = data,
.num_cores = 2,
.date_col = date_col,
.value_col = value,
.rsamp_obj = splits,
.formula = value ~ .,
.grid_size = 3,
.tune = FALSE
)
#> Warning: Column(s) have zero variance so scaling cannot be used: `date_col_day`, `date_col_hour`, `date_col_minute`, `date_col_second`, `date_col_hour12`, `date_col_am.pm`, `date_col_mday`, `date_col_mday7`, `date_col_locale_DE`, `date_col_CH_BerchtoldsDay`, `date_col_JP_BankHolidayJan2`, `date_col_JP_BankHolidayJan3`, `date_col_World_Epiphany`, `date_col_IT_Epiphany`, `date_col_JP_ComingOfAgeDay`, `date_col_JP_SeijinNoHi`, `date_col_US_MLKingsBirthday`, `date_col_US_InaugurationDay`, `date_col_World_PresentationOfLord`, `date_col_JP_KenkokuKinenNoHi`, `date_col_JP_NatFoundationDay`, `date_col_US_LincolnsBirthday`, `date_col_CA_FamilyDay`, `date_col_US_PresidentsDay`, `date_col_US_WashingtonsBirthday`, `date_col_World_Quinquagesima`, `date_col_World_AshWednesday`, `date_col_JP_VernalEquinox`, `date_col_World_Annunciation`, `date_col_World_PalmSunday`, `date_col_World_GoodFriday`, `date_col_US_GoodFriday`, `date_col_CH_Sechselaeuten`, `date_col_World_EasterMonday`, `date_col_IT_LiberationDay`, `date_col_JP_GreeneryDay`, `date_col_JP_MidoriNoHi`, `date_col_JP_ConstitutionDay`, `date_col_JP_KenpouKinenBi`, `date_col_JP_KokuminNoKyujitu`, `date_col_JP_NationHoliday`, `date_col_JP_ChildrensDay`, `date_col_JP_KodomoNoHi`, `date_col_FR_FetDeLaVictoire1945`, `date_col_World_RogationSunday`, `date_col_CA_VictoriaDay`, `date_col_World_Ascension`, `date_col_CH_Ascension`, `date_col_DE_Ascension`, `date_col_FR_Ascension`, `date_col_GB_SpringBankHoliday`, `date_col_US_DecorationMemorialDay`, `date_col_US_MemorialDay`, `date_col_World_PentecostMonday`, `date_col_World_CorpusChristi`, `date_col_DE_CorpusChristi`, `date_col_US_JuneteenthNationalIndependenceDay`, `date_col_US_IndependenceDay`, `date_col_FR_BastilleDay`, `date_col_JP_MarineDay`, `date_col_JP_UmiNoHi`, `date_col_World_TransfigurationOfLord`, `date_col_World_AssumptionOfMary`, `date_col_FR_AssumptionVirginMary`, `date_col_IT_AssumptionOfVirginMary`, `date_col_GB_SummerBankHoliday`, `date_col_World_BirthOfVirginMary`, `date_col_CH_Knabenschiessen`, `date_col_World_CelebrationOfHolyCross`, `date_col_JP_KeirouNOhi`, `date_col_JP_RespectForTheAgedDay`, `date_col_JP_AutumnalEquinox`, `date_col_JP_ShuubunNoHi`, `date_col_World_MassOfArchangels`, `date_col_DE_GermanUnity`, `date_col_CA_ThanksgivingDay`, `date_col_JP_HealthandSportsDay`, `date_col_JP_TaiikuNoHi`, `date_col_US_ColumbusDay`, `date_col_World_AllSouls`, `date_col_JP_BunkaNoHi`, `date_col_JP_NationalCultureDay`, `date_col_US_ElectionDay`, `date_col_World_CaRemembranceDay`, `date_col_FR_ArmisticeDay`, `date_col_US_VeteransDay`, `date_col_World_ChristTheKing`, `date_col_JP_EmperorsBirthday`, `date_col_JP_KinrouKanshaNoHi`, `date_col_JP_TennouTanjyouBi`, `date_col_JP_ThanksgivingDay`, `date_col_US_ThanksgivingDay`, `date_col_World_Advent2nd`, `date_col_IT_StAmrose`, `date_col_IT_ImmaculateConception`, `date_col_World_Advent3rd`, `date_col_World_Advent4th`, `date_col_World_ChristmasEve`, `date_col_DE_ChristmasEve`, `date_col_World_ChristmasDay`, `date_col_US_ChristmasDay`, `date_col_World_BoxingDay`, `date_col_DE_NewYearsEve`, `date_col_JP_BankHolidayDec31`, `date_col_GB_MilleniumDay`, `date_col_month.lbl_13` and `date_col_wday.lbl_8`. Consider using `step_zv()` to remove those columns before normalizing
#> frequency = 12 observations per 1 year
#> Warning: There were 3 warnings in `dplyr::mutate()`.
#> The first warning was:
#> ℹ In argument: `.nested.col = purrr::map2(...)`.
#> Caused by warning:
#> ! Column(s) have zero variance so scaling cannot be used: `date_col_day`, `date_col_hour`, `date_col_minute`, `date_col_second`, `date_col_hour12`, `date_col_am.pm`, `date_col_mday`, `date_col_mday7`, `date_col_locale_DE`, `date_col_CH_BerchtoldsDay`, `date_col_JP_BankHolidayJan2`, `date_col_JP_BankHolidayJan3`, `date_col_World_Epiphany`, `date_col_IT_Epiphany`, `date_col_JP_ComingOfAgeDay`, `date_col_JP_SeijinNoHi`, `date_col_US_MLKingsBirthday`, `date_col_US_InaugurationDay`, `date_col_World_PresentationOfLord`, `date_col_JP_KenkokuKinenNoHi`, `date_col_JP_NatFoundationDay`, `date_col_US_LincolnsBirthday`, `date_col_CA_FamilyDay`, `date_col_US_PresidentsDay`, `date_col_US_WashingtonsBirthday`, `date_col_World_Quinquagesima`, `date_col_World_AshWednesday`, `date_col_JP_VernalEquinox`, `date_col_World_Annunciation`, `date_col_World_PalmSunday`, `date_col_World_GoodFriday`, `date_col_US_GoodFriday`, `date_col_CH_Sechselaeuten`, `date_col_World_EasterMonday`, `date_col_IT_LiberationDay`, `date_col_JP_GreeneryDay`, `date_col_JP_MidoriNoHi`, `date_col_JP_ConstitutionDay`, `date_col_JP_KenpouKinenBi`, `date_col_JP_KokuminNoKyujitu`, `date_col_JP_NationHoliday`, `date_col_JP_ChildrensDay`, `date_col_JP_KodomoNoHi`, `date_col_FR_FetDeLaVictoire1945`, `date_col_World_RogationSunday`, `date_col_CA_VictoriaDay`, `date_col_World_Ascension`, `date_col_CH_Ascension`, `date_col_DE_Ascension`, `date_col_FR_Ascension`, `date_col_GB_SpringBankHoliday`, `date_col_US_DecorationMemorialDay`, `date_col_US_MemorialDay`, `date_col_World_PentecostMonday`, `date_col_World_CorpusChristi`, `date_col_DE_CorpusChristi`, `date_col_US_JuneteenthNationalIndependenceDay`, `date_col_US_IndependenceDay`, `date_col_FR_BastilleDay`, `date_col_JP_MarineDay`, `date_col_JP_UmiNoHi`, `date_col_World_TransfigurationOfLord`, `date_col_World_AssumptionOfMary`, `date_col_FR_AssumptionVirginMary`, `date_col_IT_AssumptionOfVirginMary`, `date_col_GB_SummerBankHoliday`, `date_col_World_BirthOfVirginMary`, `date_col_CH_Knabenschiessen`, `date_col_World_CelebrationOfHolyCross`, `date_col_JP_KeirouNOhi`, `date_col_JP_RespectForTheAgedDay`, `date_col_JP_AutumnalEquinox`, `date_col_JP_ShuubunNoHi`, `date_col_World_MassOfArchangels`, `date_col_DE_GermanUnity`, `date_col_CA_ThanksgivingDay`, `date_col_JP_HealthandSportsDay`, `date_col_JP_TaiikuNoHi`, `date_col_US_ColumbusDay`, `date_col_World_AllSouls`, `date_col_JP_BunkaNoHi`, `date_col_JP_NationalCultureDay`, `date_col_US_ElectionDay`, `date_col_World_CaRemembranceDay`, `date_col_FR_ArmisticeDay`, `date_col_US_VeteransDay`, `date_col_World_ChristTheKing`, `date_col_JP_EmperorsBirthday`, `date_col_JP_KinrouKanshaNoHi`, `date_col_JP_TennouTanjyouBi`, `date_col_JP_ThanksgivingDay`, `date_col_US_ThanksgivingDay`, `date_col_World_Advent2nd`, `date_col_IT_StAmrose`, `date_col_IT_ImmaculateConception`, `date_col_World_Advent3rd`, `date_col_World_Advent4th`, `date_col_World_ChristmasEve`, `date_col_DE_ChristmasEve`, `date_col_World_ChristmasDay`, `date_col_US_ChristmasDay`, `date_col_World_BoxingDay`, `date_col_DE_NewYearsEve`, `date_col_JP_BankHolidayDec31`, `date_col_GB_MilleniumDay`, `date_col_month.lbl_13` and `date_col_wday.lbl_8`. Consider using `step_zv()` to remove those columns before normalizing
#> ℹ Run `dplyr::last_dplyr_warnings()` to see the 2 remaining warnings.
#> Warning: There were 3 warnings in `dplyr::mutate()`.
#> The first warning was:
#> ℹ In argument: `.nested.col = purrr::map2(...)`.
#> Caused by warning:
#> ! Column(s) have zero variance so scaling cannot be used: `date_col_day`, `date_col_hour`, `date_col_minute`, `date_col_second`, `date_col_hour12`, `date_col_am.pm`, `date_col_mday`, `date_col_mday7`, `date_col_locale_DE`, `date_col_CH_BerchtoldsDay`, `date_col_JP_BankHolidayJan2`, `date_col_JP_BankHolidayJan3`, `date_col_World_Epiphany`, `date_col_IT_Epiphany`, `date_col_JP_ComingOfAgeDay`, `date_col_JP_SeijinNoHi`, `date_col_US_MLKingsBirthday`, `date_col_US_InaugurationDay`, `date_col_World_PresentationOfLord`, `date_col_JP_KenkokuKinenNoHi`, `date_col_JP_NatFoundationDay`, `date_col_US_LincolnsBirthday`, `date_col_CA_FamilyDay`, `date_col_US_PresidentsDay`, `date_col_US_WashingtonsBirthday`, `date_col_World_Quinquagesima`, `date_col_World_AshWednesday`, `date_col_JP_VernalEquinox`, `date_col_World_Annunciation`, `date_col_World_PalmSunday`, `date_col_World_GoodFriday`, `date_col_US_GoodFriday`, `date_col_CH_Sechselaeuten`, `date_col_World_EasterMonday`, `date_col_IT_LiberationDay`, `date_col_JP_GreeneryDay`, `date_col_JP_MidoriNoHi`, `date_col_JP_ConstitutionDay`, `date_col_JP_KenpouKinenBi`, `date_col_JP_KokuminNoKyujitu`, `date_col_JP_NationHoliday`, `date_col_JP_ChildrensDay`, `date_col_JP_KodomoNoHi`, `date_col_FR_FetDeLaVictoire1945`, `date_col_World_RogationSunday`, `date_col_CA_VictoriaDay`, `date_col_World_Ascension`, `date_col_CH_Ascension`, `date_col_DE_Ascension`, `date_col_FR_Ascension`, `date_col_GB_SpringBankHoliday`, `date_col_US_DecorationMemorialDay`, `date_col_US_MemorialDay`, `date_col_World_PentecostMonday`, `date_col_World_CorpusChristi`, `date_col_DE_CorpusChristi`, `date_col_US_JuneteenthNationalIndependenceDay`, `date_col_US_IndependenceDay`, `date_col_FR_BastilleDay`, `date_col_JP_MarineDay`, `date_col_JP_UmiNoHi`, `date_col_World_TransfigurationOfLord`, `date_col_World_AssumptionOfMary`, `date_col_FR_AssumptionVirginMary`, `date_col_IT_AssumptionOfVirginMary`, `date_col_GB_SummerBankHoliday`, `date_col_World_BirthOfVirginMary`, `date_col_CH_Knabenschiessen`, `date_col_World_CelebrationOfHolyCross`, `date_col_JP_KeirouNOhi`, `date_col_JP_RespectForTheAgedDay`, `date_col_JP_AutumnalEquinox`, `date_col_JP_ShuubunNoHi`, `date_col_World_MassOfArchangels`, `date_col_DE_GermanUnity`, `date_col_CA_ThanksgivingDay`, `date_col_JP_HealthandSportsDay`, `date_col_JP_TaiikuNoHi`, `date_col_US_ColumbusDay`, `date_col_World_AllSouls`, `date_col_JP_BunkaNoHi`, `date_col_JP_NationalCultureDay`, `date_col_US_ElectionDay`, `date_col_World_CaRemembranceDay`, `date_col_FR_ArmisticeDay`, `date_col_US_VeteransDay`, `date_col_World_ChristTheKing`, `date_col_JP_EmperorsBirthday`, `date_col_JP_KinrouKanshaNoHi`, `date_col_JP_TennouTanjyouBi`, `date_col_JP_ThanksgivingDay`, `date_col_US_ThanksgivingDay`, `date_col_World_Advent2nd`, `date_col_IT_StAmrose`, `date_col_IT_ImmaculateConception`, `date_col_World_Advent3rd`, `date_col_World_Advent4th`, `date_col_World_ChristmasEve`, `date_col_DE_ChristmasEve`, `date_col_World_ChristmasDay`, `date_col_US_ChristmasDay`, `date_col_World_BoxingDay`, `date_col_DE_NewYearsEve`, `date_col_JP_BankHolidayDec31`, `date_col_GB_MilleniumDay`, `date_col_month.lbl_13` and `date_col_wday.lbl_8`. Consider using `step_zv()` to remove those columns before normalizing
#> ℹ Run `dplyr::last_dplyr_warnings()` to see the 2 remaining warnings.
ts_smooth_es$recipe_info
#> $recipe_call
#> recipe(.data = data, .date_col = date_col, .value_col = value,
#> .formula = value ~ ., .rsamp_obj = splits, .tune = FALSE,
#> .grid_size = 3, .num_cores = 2)
#>
#> $recipe_syntax
#> [1] "ts_smooth_es_recipe <-"
#> [2] "\n recipe(.data = data, .date_col = date_col, .value_col = value, .formula = value ~ \n ., .rsamp_obj = splits, .tune = FALSE, .grid_size = 3, .num_cores = 2)"
#>
#> $rec_obj
#>
#> ── Recipe ──────────────────────────────────────────────────────────────────────
#>
#> ── Inputs
#> Number of variables by role
#> outcome: 1
#> predictor: 1
#>
#> ── Operations
#> • Timeseries signature features from: date_col
#> • Holiday signature features from: date_col
#> • Novel factor level assignment for: recipes::all_nominal_predictors()
#> • Variable mutation for: tidyselect::vars_select_helpers$where(is.character)
#> • Dummy variables from: recipes::all_nominal()
#> • Centering and scaling for: recipes::all_numeric_predictors(), ...
#> • Sparse, unbalanced variable filter on: recipes::all_predictors(), ...
#> • Correlation filter on: recipes::all_numeric_predictors()
#>
# }