modeltime_wfs_bestmodel: Modeltime best workflow from a set of models

Description Usage Arguments Details Value Examples

View source: R/modeltime_wfs_bestmodel.R

Description

get best workflows generated from the modeltime_wfs_fit() function output.

Usage

1
2
3
4
5
6
modeltime_wfs_bestmodel(
  .wfs_results,
  .model = NULL,
  .metric = "rmse",
  .minimize = TRUE
)

Arguments

.wfs_results

a tibble generated from the modeltime_wfs_fit() function.

.model

string or number, It can be supplied as follows: “top n,” “Top n” or “tOp n”, where n is the number of best models to select; n, where n is the number of best models to select; name of the workflow or workflows to select.

.metric

metric to get best model from ('mae', 'mape','mase','smape','rmse','rsq')

.minimize

a boolean indicating whether to minimize (TRUE) or maximize (FALSE) the metric.

Details

the best model is selected based on a specific metric ('mae', 'mape','mase','smape','rmse','rsq'). The default is to minimize the metric. However, if the model is being selected based on rsq minimize should be FALSE.

Value

a tibble containing the best model based on the selected metric.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library(dplyr)
library(earth)
data <- sknifedatar::data_avellaneda %>% mutate(date=as.Date(date)) %>% filter(date<'2012-06-01')

recipe_date <- recipes::recipe(value ~ ., data = data) %>% 
  recipes::step_date(date, features = c('dow','doy','week','month','year')) 

mars <- parsnip::mars(mode = 'regression') %>%
  parsnip::set_engine('earth')

wfsets <- workflowsets::workflow_set(
  preproc = list(
    R_date = recipe_date),
  models  = list(M_mars = mars),
  cross   = TRUE)

wffits <- sknifedatar::modeltime_wfs_fit(.wfsets = wfsets, 
                                         .split_prop = 0.8, 
                                         .serie=data)

sknifedatar::modeltime_wfs_bestmodel(.wfs_results = wffits,
                                     .metric='rsq',
                                     .minimize = FALSE)
                                  

sknifedatar documentation built on June 1, 2021, 9:08 a.m.