Reputation: 93
I am trying to find the right prameter for a random forest regression problem using tidymodels frame work.
Follwoing is my code:
#create recepie on the preped house train data
rf_rec <-
recipe(log_sale_price ~. , data = house_train_treebased)
#give model spec
rf_mod <-
rand_forest(mtry = tune(), num.trees = tune()) %>%
set_engine("ranger")
#create Search grid
rf_grid <- expand.grid(mtry = c(1:30), num.trees = seq(from = 500, to = 1000, by = 100))
#create samples for cross validation
folds <- vfold_cv(house_train_treebased, v = 25)
#create models with grid search
rf_res <-
tune_grid(rf_rec, model = rf_mod, resamples = folds , grid = rf_grid)
I get following errors:
> rf_mod <-
+ rand_forest(mtry = tune(), num.trees = tune()) %>%
+ set_engine("ranger")
Error in rand_forest(mtry = tune(), num.trees = tune()) :
unused argument (num.trees = tune())
rf_res <-
+ tune_grid(rf_rec, model = rf_mod, resamples = folds , grid = rf_grid)
Error: Internal error: `check_installs()` should have caught an `unknown` mode.
What am I missing?
Upvotes: 0
Views: 884
Reputation: 93
I looked at the github in the following link
https://rdrr.io/github/tidymodels/tune/src/R/checks.R
check_metrics <- function(x, object) {
mode <- workflows::pull_workflow_spec(object)$mode
if (is.null(x)) {
switch(
mode,
regression = {
x <- yardstick::metric_set(rmse, rsq)
},
classification = {
x <- yardstick::metric_set(roc_auc, accuracy)
},
unknown = {
rlang::abort("Internal error: `check_installs()` should have caught an `unknown` mode.")
},
rlang::abort("Unknown `mode` for parsnip model.")
)
return(x)
}
I did not provide the mode, ie, if I want a regression or classification.
Upvotes: 1