【问题标题】:properties of Random Forest in 5 fold cross validation using Caret使用 Caret 进行 5 折交叉验证中随机森林的属性
【发布时间】:2018-06-14 15:34:43
【问题描述】:

考虑使用随机森林方法在插入符号中进行 5 折交叉验证,每个折中构建的随机森林的属性是什么?例如在 iris 数据集中:

train_control <- trainControl(method="cv", number=5,savePredictions = TRUE) 
output <- train(Species~., data=iris, trControl=train_control, method="rf")
output$results$mtry
[1] 2 3 4

在交叉验证中构建了 3 个 mtry 值、3 个不同的森林是真的吗?我怎样才能了解每个折叠森林的细节,比如 mtry?

【问题讨论】:

    标签: r random-forest cross-validation r-caret


    【解决方案1】:

    默认情况下,插入符号训练函数将进行网格搜索以寻找最佳 mtry。如果没有提供网格搜索的长度,它将执行长度为 3 的搜索。

    这些默认值可以从:

    ?trainControl
    ?train
    
    tuneLength = ifelse(trControl$method == "none", 1, 3))
    search = "grid"
    

    当指定网格搜索(默认)和长度 3(默认)时,使用插入符号函数 var_seq 找到 mtry 参数。这可以从rf train method 中看出。此功能具有不同的行为,具体取决于功能的数量。由于少于 500 个功能,它选择 mtry 为:

    floor(seq(2, to = p, length = len))
    

    其中 p 是特征的数量。虹膜数据有 4 个特征,因此 len 的 3 个可用 mtry 值为 2、3 和 4。

    因此这三个 mtry 值都是在 5 倍 CV 中测试的。所以基本上制作了15个射频模型。每个 mtry 5 个。最后,根据 CV 结果选择最佳 mtry,并在整个训练数据上建立最终模型 - 第 16 个模型。

    【讨论】:

      猜你喜欢
      • 2021-06-05
      • 2018-09-03
      • 1970-01-01
      • 2021-06-17
      • 2014-04-16
      • 2015-10-16
      • 2021-02-06
      • 1970-01-01
      • 2019-08-19
      相关资源
      最近更新 更多