12.10 Add tuning parameters:

We can add main arguments (mtry, min_n) and engine specific arguments (regularization.factor)

rf_spec_tuned <- rand_forest(mtry = tune(), trees = 2000, min_n = tune()) %>% 
  set_engine("ranger", regularization.factor = tune("reg")) %>% 
  set_mode("regression") 

tune() returns an expression. This tags the parameters for optimization within the tidymodels framework

rf_spec_tuned %>% 
  extract_parameter_set_dials()
## Collection of 3 parameters for tuning
## 
##  identifier                  type    object
##        mtry                  mtry nparam[?]
##       min_n                 min_n nparam[+]
##         reg regularization.factor nparam[+]
## 
## Model parameters needing finalization:
##    # Randomly Selected Predictors ('mtry')
## 
## See `?dials::finalize` or `?dials::update.parameters` for more information.

The notation nparam[+] indicates a complete numeric parameter, nparam[?] indicates a missing value that needs to be addressed.