tidymodels finalization of tuning parameters

Hi,

I am running through a couple of really good tutorials on tidymodels below but am getting stuck with the error message. I think the problem is when I am trying to tune the underratio and threshold variables. In the blog post only one of the articles does any kind of finalizing which is described in the tidymodels documentation here

Error: Some tuning parameters require finalization but there are recipe parameters that require tuning. Please use parameters() to finalize the parameter ranges.

Blog Posts for reference

https://juliasilge.com/blog/sf-trees-random-tuning/

https://www.brodrigues.co/blog/2020-03-08-tidymodels/

Reprex

library(tidymodels)
library(tidyverse)

# Create a dataframe where we are trying to predict Setosa
mydf <- iris %>% 
  mutate(set_tgt = factor(ifelse(Species == 'setosa', 'yes', 'no'))) %>% 
  select(-Species)

# Try tune the correlation before removal and the sampling ratio
flower_rec <- recipe(set_tgt ~ ., data = mydf) %>%
  step_downsample(uv_confirmed, under_ratio = tune()) %>% 
  step_corr(recipes::all_numeric(), -recipes::all_outcomes(), threshold = tune())

# Set up the cross validation for this
cv_splits <- vfold_cv(mydf, strata = "set_tgt")

# Create the Random Forest Engine
rf_model <- rand_forest(mtry = tune(), trees = 5000, min_n = tune()) %>%
  set_mode("classification") %>%
  set_engine("ranger")

rf_grid <- grid_regular(
  mtry() %>% range_set(c(1, 20)),
  threshold(),
  under_ratio(),
  min_n() %>% range_set(c(2, 10)),
  levels = 5
)

rf_workflow <- workflow() %>% 
  add_recipe(flower_rec) %>% 
  add_model(rf_model)

rf_results <- tune_grid(
  rf_workflow,
  resamples = cv_splits,
  grid = rf_grid,
  metrics = metric_set(roc_auc)
)
#> Error: Some tuning parameters require finalization but there are recipe parameters that require tuning. Please use `parameters()` to finalize the parameter ranges.

Created on 2020-03-30 by the reprex package (v0.3.0)

That seems like a bug since you've given the full tuning grid. Can you submit a GH issue?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.