Hi,
I am currently trying to tune a model using the new tidymodels
package
This is basically a learning exercise for me
All my models fail with the error message:
.notes
<chr>
1 "recipe 1/4: Error: could not find function \"all_numeric\""
2 "recipe 2/4: Error: could not find function \"all_numeric\""
3 "recipe 3/4: Error: could not find function \"all_numeric\""
4 "recipe 4/4: Error: could not find function \"all_numeric\""
This isn't something I could find when i googled around.
I am able to get this to run on an old laptop but not when i move it to my work PC
I have re-installed both the tidyverse
and tidymodels
.
Does anyone have any suggestions?
Thank you for your time
library(tidyverse)
library(tidymodels)
mydf <- iris %>%
mutate(tgt_setosa = ifelse(.$Species == 'setosa', 'Y', 'N')) %>%
select(-Species)
# Higlight what we have created for the top ten rows
glimpse(mydf, 10)
# CREATE A MODELLING WORKFLOW ---------------------------------------------
flower_rec <- recipe(tgt_setosa ~ ., data = mydf) %>%
step_nzv(all_numeric(), -all_outcomes()) %>%
step_normalize(all_numeric(), -all_outcomes()) %>%
step_center(all_numeric(), -all_outcomes()) %>%
step_upsample(tgt_setosa, over_ratio = tune()) %>%
step_corr(all_numeric(), -all_outcomes(), threshold = tune())
# Create the specification
tree_spec <- decision_tree(cost_complexity = tune(), tree_depth = tune()) %>%
set_engine("rpart") %>%
set_mode("classification")
# Set up the cross validation for this
cv_splits <- vfold_cv(mydf, strata = "tgt_setosa", repeats = 1)
# Set up the grid
mygrid <- grid_regular(
over_ratio(),
threshold(),
cost_complexity(),
tree_depth(),
levels = 2
)
# Fit the models
tree_results <- tune_grid(
object = flower_rec,
model = tree_spec,
resamples = cv_splits,
grid = mygrid,
metrics = metric_set(roc_auc, sens, spec)
)
tree_results$.notes[[1]]