Hi there,
I'm getting the same error when I try to tune both the recipe and the model. Perhaps a github issue with full reprex? Here is mine (sorry for not rendering, I'm getting an error trying to run the reprex locally )
library(modeldata)
data("stackoverflow")
library(tidyverse)
library(tidymodels)
set.seed(100) # Important!
# make smaller to save time
so_split <- initial_split(sample_n(stackoverflow, size = 300), strata = Remote)
so_train <- training(so_split)
so_test <- testing(so_split)
# again, simpler so runs faster
so_folds <- vfold_cv(so_train, v = 2, strata = Remote)
so_rec <- recipe(Remote ~ .,
data = so_train) %>%
step_dummy(all_nominal(), -all_outcomes()) %>%
step_lincomb(all_predictors()) %>%
step_downsample(Remote)
tune_rec <- recipe(Remote ~ .,
data = so_train) %>%
step_dummy(all_nominal(), -all_outcomes()) %>%
step_lincomb(all_predictors()) %>%
step_downsample(Remote, under_ratio = tune())
# no tuning
rf_spec <-
rand_forest() %>%
set_engine("ranger") %>%
set_mode("classification")
# add tuning
tune_spec <-
rand_forest(mtry = tune(),
min_n = tune()) %>%
set_engine("ranger") %>%
set_mode("classification")
# define 3 workflows
tuneboth_wf <-
workflow() %>%
add_recipe(tune_rec) %>%
add_model(tune_spec)
tunerec_wf <-
workflow() %>%
add_recipe(tune_rec) %>%
add_model(rf_spec)
tunemod_wf <-
workflow() %>%
add_recipe(so_rec) %>%
add_model(tune_spec)
# this won't work
tuneboth_wf %>%
tune_grid(resamples = so_folds)
# works
tunerec_wf %>%
tune_grid(resamples = so_folds)
# works
tunemod_wf %>%
tune_grid(resamples = so_folds)