Hi,
I am trying out the model rule fit and keep getting the error
Error: At least one parameter does not match any id's in the set: 'mtry'
Runrlang::last_error()
to see where the error occurred.
I was wondering if anyone could see where I am going wrong?
library(tidymodels)
library(tidyverse)
library(janitor)
mydf <- iris %>%
clean_names() %>%
mutate(flower_tgt = case_when(species == 'setosa' ~ 'Y',
TRUE ~ 'N')) %>%
select(-species)
# Set up the recipe and upsample based on the label
set_rec <- recipe(flower_tgt ~ ., data = mydf) %>%
themis::step_upsample(flower_tgt)
# Just check the recipe does what i think
set_rec %>% prep() %>% juice() %>% glimpse()
xrf_mod <- rule_fit(mtry = tune(),
trees = tune(),
min_n = tune(),
tree_depth = tune(),
learn_rate = tune(),
loss_reduction = tune(),
sample_size = tune(),
penalty = tune()) %>%
set_engine("xrf") %>%
set_mode("classification")
xrf_wf <- workflow() %>%
add_model(xrf_mod) %>%
add_recipe(set_rec, blueprint = hardhat::default_recipe_blueprint(allow_novel_levels = TRUE))
flwr_split <- initial_time_split(mydf)
train_data <- training(flwr_split)
test_data <- testing(flwr_split)
# We set up the cross validation of time slices and
mset <- metric_set(recall, precision, f_meas, j_index)
grid_control <- control_grid(save_workflow = TRUE,
save_pred = TRUE,
extract = extract_model)
folds <- rsample::vfold_cv(train_data, v = 10,
strata = flower_tgt)
xrf_grid <- xrf_wf %>%
parameters() %>%
update(mtry = mtry(range = c(2L, 3L))) %>%
grid_random(size = 2)
# ERROR HERE
Thanks