Skip to contents

This is a boilerplate function to create automatically the following:

  • recipe

  • model specification

  • workflow

  • tuned model (grid ect)

  • calibration tibble and plot

Usage

ts_auto_prophet_boost(
  .data,
  .date_col,
  .value_col,
  .formula,
  .rsamp_obj,
  .prefix = "ts_prophet_boost",
  .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_prophet_boost

.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.

Value

A list

Details

This uses the modeltime::prophet_boost() function with the engine set to prophet_xgboost.

Author

Steven P. Sanderson II, MPH

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_prophet_boost <- ts_auto_prophet_boost(
  .data = data,
  .num_cores = 2,
  .date_col = date_col,
  .value_col = value,
  .rsamp_obj = splits,
  .formula = value ~ .,
  .grid_size = 5
)
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 5.945
#> Warning: neighborhood radius 5.055
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 36.663
#> Warning: Chernobyl! trL>n 5
#> Warning: Chernobyl! trL>n 5
#> Warning: NaNs produced
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 51.035
#> Warning: neighborhood radius 832.97
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 6.0212e+05
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -8.5888
#> Warning: neighborhood radius 3.5919
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 13.131
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 7.865
#> Warning: neighborhood radius 10.135
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 293.61
#> Warning: Chernobyl! trL>n 5
#> Warning: Chernobyl! trL>n 5
#> Warning: NaNs produced
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -9.2437
#> Warning: neighborhood radius 5.1152
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 19.686
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 7.825
#> Warning: neighborhood radius 15.175
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 407.03
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.4674
#> Warning: neighborhood radius 1.5112
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 6.7415
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.4855
#> Warning: neighborhood radius 2.42
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 2.1777
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.3534
#> Warning: neighborhood radius 1.4506
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 8.3169
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 0.59905
#> Warning: neighborhood radius 0.15793
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 0.019765
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 2.94
#> Warning: neighborhood radius 5.06
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 49.844
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 5.945
#> Warning: neighborhood radius 5.055
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 36.663
#> Warning: Chernobyl! trL>n 5
#> Warning: Chernobyl! trL>n 5
#> Warning: NaNs produced
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 51.035
#> Warning: neighborhood radius 832.97
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 6.0212e+05
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -8.5888
#> Warning: neighborhood radius 3.5919
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 13.131
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 7.865
#> Warning: neighborhood radius 10.135
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 293.61
#> Warning: Chernobyl! trL>n 5
#> Warning: Chernobyl! trL>n 5
#> Warning: NaNs produced
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -9.2437
#> Warning: neighborhood radius 5.1152
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 19.686
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 7.825
#> Warning: neighborhood radius 15.175
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 407.03
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.4674
#> Warning: neighborhood radius 1.5112
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 6.7415
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.4855
#> Warning: neighborhood radius 2.42
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 2.1777
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.3534
#> Warning: neighborhood radius 1.4506
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 8.3169
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 0.59905
#> Warning: neighborhood radius 0.15793
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 0.019765
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 2.94
#> Warning: neighborhood radius 5.06
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 49.844
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 5.945
#> Warning: neighborhood radius 5.055
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 36.663
#> Warning: Chernobyl! trL>n 5
#> Warning: Chernobyl! trL>n 5
#> Warning: NaNs produced
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 51.035
#> Warning: neighborhood radius 832.97
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 6.0212e+05
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -8.5888
#> Warning: neighborhood radius 3.5919
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 13.131
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 7.865
#> Warning: neighborhood radius 10.135
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 293.61
#> Warning: Chernobyl! trL>n 5
#> Warning: Chernobyl! trL>n 5
#> Warning: NaNs produced
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -9.2437
#> Warning: neighborhood radius 5.1152
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 19.686
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 7.825
#> Warning: neighborhood radius 15.175
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 407.03
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.4674
#> Warning: neighborhood radius 1.5112
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 6.7415
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.4855
#> Warning: neighborhood radius 2.42
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 2.1777
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.3534
#> Warning: neighborhood radius 1.4506
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 8.3169
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 0.59905
#> Warning: neighborhood radius 0.15793
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 0.019765
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 2.94
#> Warning: neighborhood radius 5.06
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 49.844
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 5.945
#> Warning: neighborhood radius 5.055
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 36.663
#> Warning: Chernobyl! trL>n 5
#> Warning: Chernobyl! trL>n 5
#> Warning: NaNs produced
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 51.035
#> Warning: neighborhood radius 832.97
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 6.0212e+05
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -8.5888
#> Warning: neighborhood radius 3.5919
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 13.131
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 7.865
#> Warning: neighborhood radius 10.135
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 293.61
#> Warning: Chernobyl! trL>n 5
#> Warning: Chernobyl! trL>n 5
#> Warning: NaNs produced
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -9.2437
#> Warning: neighborhood radius 5.1152
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 19.686
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 7.825
#> Warning: neighborhood radius 15.175
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 407.03
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.4674
#> Warning: neighborhood radius 1.5112
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 6.7415
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.4855
#> Warning: neighborhood radius 2.42
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 2.1777
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.3534
#> Warning: neighborhood radius 1.4506
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 8.3169
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 0.59905
#> Warning: neighborhood radius 0.15793
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 0.019765
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 2.94
#> Warning: neighborhood radius 5.06
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 49.844
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 5.945
#> Warning: neighborhood radius 5.055
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 36.663
#> Warning: Chernobyl! trL>n 5
#> Warning: Chernobyl! trL>n 5
#> Warning: NaNs produced
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 51.035
#> Warning: neighborhood radius 832.97
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 6.0212e+05
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -8.5888
#> Warning: neighborhood radius 3.5919
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 13.131
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 7.865
#> Warning: neighborhood radius 10.135
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 293.61
#> Warning: Chernobyl! trL>n 5
#> Warning: Chernobyl! trL>n 5
#> Warning: NaNs produced
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -9.2437
#> Warning: neighborhood radius 5.1152
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 19.686
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 7.825
#> Warning: neighborhood radius 15.175
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 407.03
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.4674
#> Warning: neighborhood radius 1.5112
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 6.7415
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.4855
#> Warning: neighborhood radius 2.42
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 2.1777
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.3534
#> Warning: neighborhood radius 1.4506
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 8.3169
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 0.59905
#> Warning: neighborhood radius 0.15793
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 0.019765
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 2.94
#> Warning: neighborhood radius 5.06
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 49.844
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 5.945
#> Warning: neighborhood radius 5.055
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 36.663
#> Warning: Chernobyl! trL>n 5
#> Warning: Chernobyl! trL>n 5
#> Warning: NaNs produced
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 51.035
#> Warning: neighborhood radius 832.97
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 6.0212e+05
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -8.5888
#> Warning: neighborhood radius 3.5919
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 13.131
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 7.865
#> Warning: neighborhood radius 10.135
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 293.61
#> Warning: Chernobyl! trL>n 5
#> Warning: Chernobyl! trL>n 5
#> Warning: NaNs produced
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -9.2437
#> Warning: neighborhood radius 5.1152
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 19.686
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 7.825
#> Warning: neighborhood radius 15.175
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 407.03
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.4674
#> Warning: neighborhood radius 1.5112
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 6.7415
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.4855
#> Warning: neighborhood radius 2.42
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 2.1777
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at -2.3534
#> Warning: neighborhood radius 1.4506
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 8.3169
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 0.59905
#> Warning: neighborhood radius 0.15793
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 0.019765
#> Warning: span too small.   fewer data values than degrees of freedom.
#> Warning: pseudoinverse used at 2.94
#> Warning: neighborhood radius 5.06
#> Warning: reciprocal condition number  0
#> Warning: There are other near singularities as well. 49.844

ts_prophet_boost$recipe_info
#> $recipe_call
#> recipe(.data = data, .date_col = date_col, .value_col = value, 
#>     .formula = value ~ ., .rsamp_obj = splits, .grid_size = 5, 
#>     .num_cores = 2)
#> 
#> $recipe_syntax
#> [1] "ts_prophet_boost_recipe <-"                                                                                                                         
#> [2] "\n  recipe(.data = data, .date_col = date_col, .value_col = value, .formula = value ~ \n    ., .rsamp_obj = splits, .grid_size = 5, .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()
#>  Zero variance filter on: recipes::all_predictors(), -date_col_index.num
#>  Centering and scaling for: recipes::all_numeric_predictors()
#> 
# }