簡體   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