在 R 中使用随机森林预测的不同结果

Different results using Random Forest prediction in R

当我对测试数据使用 运行 随机森林模型时,相同的 数据集 + 模型 得到了不同的结果。

以下是结果,您可以在其中看到第一列的差异:

> table((predict(rfModelsL[[1]],newdata = a)) ,a$earlyR)

        FALSE TRUE
 FALSE    14    7
 TRUE     13   66

> table((predict(rfModelsL[[1]],newdata = a)) ,a$earlyR)

        FALSE TRUE
 FALSE    15    7
 TRUE     12   66

虽然差异很小,但我正在尝试了解造成这种差异的原因。我猜 predict 有 "flexible" 分类阈值,尽管我在文档中找不到它;我对吗?

提前致谢

我假设您没有在此处修改模型,而只是 predict 调用产生了这些结果。答案大概是这样的,来自?predict.randomForest:

Any ties are broken at random, so if this is undesirable, avoid it by using odd number ntree in randomForest()