简体   繁体   English

在随机森林 tidymodels r 中设置调整游侠的最大深度

[英]set max depth for tuning ranger in random forest tidymodels r

I would like to tune the depth of my random forest to avoid overfitting.我想调整随机森林的深度以避免过度拟合。 I am using tidymodels and this is my model code.我正在使用 tidymodels,这是我的 model 代码。

rf_model <- rand_forest(mtry = tune(), 
                        trees = tune(),
                        max.depth = tune()) %>%
  set_mode("classification") %>%
  set_engine("ranger", importance = "impurity")

It gives me an error that:它给了我一个错误:

Error in rand_forest(mtry = tune(), trees = tune(), max.depth = tune()): unused argument (max.depth = tune())

I also tried tree_depth = tune() from dials documentation, and that gives the same error.我还尝试了 dials 文档中的 tree_depth = tune() ,这给出了同样的错误。

But when I look at ranger documentation, it has max.depth as a parameter.但是当我查看 ranger 文档时,它具有 max.depth 作为参数。 wondering how to tune depth with tidymodels tune.想知道如何使用 tidymodels tune 调整深度。

Thank you谢谢

There is no max.depth argument, so like in ranger (see What is equivalent of "max depth" in the 'R' package "ranger"? for explanation) the minimum number of nodes can be used instead.没有max.depth参数,所以就像在 ranger 中一样(请参阅What is equivalent of "max depth" in the 'R' package "ranger"? ),可以使用最小数量的节点来代替。 This works:这有效:

rf_model <- rand_forest(mtry = tune(), trees = tune(), min_n = tune()) %>%
    set_mode("classification") %>% set_engine("ranger", importance = "impurity")

Which produces a valid rf_model :这会产生一个有效的rf_model

> rf_model
Random Forest Model Specification (classification)

Main Arguments:
  mtry = tune()
  trees = tune()
  min_n = tune()

Engine-Specific Arguments:
  importance = impurity

Computational engine: ranger 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “ R”包装“游侠”中的“最大深度”是什么意思? - What is equivalent of “max depth” in the 'R' package “ranger”? R:在随机森林中调整 mtry 时出错(回归) - R: Error tuning mtry in random forest (regression) 游侠package中是否有一个R function可以组合两个随机森林Z20F35E630DAF3994DBFA8 - Is there an R function in the ranger package that can combine two random forest model? R:Tidymodels:是否可以在整洁的模型中使用 plot 随机森林 model 的树木? - R: Tidymodels: Is it possible to plot the trees for a random forest model in tidy models? 训练、调优、交叉验证和测试 Ranger(随机森林)分位数回归 Model? - Training, Tuning, Cross-Validating, and Testing Ranger (Random Forest) Quantile Regression Model? 使用 R 中的 tidymodel 框架进行随机森林超参数调整的错误 - error in random forest hyperparam tuning using tidymodel framework in R R:随机森林调优超参数的有效方法 - R: Efficient Approach for Random Forest tuning of hyper parameters 无法使用 Tidy 模型调整我的随机森林(带护林员)中的 mtry 参数 R - Cannot tune the mtry parameter in my random forest (with ranger) using Tidy models R 如何在R中为随机森林设置“分类”类型 - How to set “classification” type for a random forest in R 如何在r中为随机森林设置插入符号中的ppv? - How to set a ppv in caret for random forest in r?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM