【问题标题】:set max depth for tuning ranger in random forest tidymodels r在随机森林 tidymodels r 中设置调整游侠的最大深度
【发布时间】:2020-10-02 15:30:31
【问题描述】:

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

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 调整深度。

谢谢

【问题讨论】:

    标签: r random-forest tidymodels r-ranger


    【解决方案1】:

    没有 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 
    

    【讨论】:

      猜你喜欢
      • 2017-03-25
      • 2016-05-02
      • 2017-03-26
      • 1970-01-01
      • 2020-05-16
      • 1970-01-01
      • 2018-05-19
      • 2021-03-23
      • 2018-03-05
      相关资源
      最近更新 更多