繁体   English   中英

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

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

我想调整随机森林的深度以避免过度拟合。 我正在使用 tidymodels,这是我的 model 代码。

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

它给了我一个错误:

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

我还尝试了 dials 文档中的 tree_depth = tune() ,这给出了同样的错误。

但是当我查看 ranger 文档时,它具有 max.depth 作为参数。 想知道如何使用 tidymodels tune 调整深度。

谢谢

没有max.depth参数,所以就像在 ranger 中一样(请参阅What is equivalent of "max depth" in the 'R' package "ranger"? ),可以使用最小数量的节点来代替。 这有效:

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

这会产生一个有效的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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM