12.12 Finalizing tuning parameters:

The update function may not be useful if a recipe is attached to a workflow that adjusts the number of columns. Instead of update() we can use the finalize() function.

updated_params <- workflow() %>% 
  add_model(rf_spec_tuned) %>% 
  add_recipe(ames_recipe) %>% 
  extract_parameter_set_dials() %>% 
  finalize(ames_train)

updated_params
## Collection of 3 parameters for tuning
## 
##  identifier                  type    object
##        mtry                  mtry nparam[+]
##       min_n                 min_n nparam[+]
##         reg regularization.factor nparam[+]

With the finalize() function, mtry was completed based on the number of predictors in the training dataset

updated_params %>%
  extract_parameter_dials("mtry")
## # Randomly Selected Predictors (quantitative)
## Range: [1, 74]