[英]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.