【发布时间】:2014-04-19 23:33:25
【问题描述】:
我在分类问题上使用 R 中的 randomForest 包(结果是二进制的)。 我想获得每棵树的概率输出(以获得预测区间)。 我在预测中设置了 predict.all=TRUE 参数,但它给了我一个 800 列的矩阵(=我的森林中的树的数量),每一个都是 1 或 0。我如何得到概率输出而不是类?
PS:我的节点大小=1,这意味着这应该是有道理的。但是,我更改了节点大小=50,仍然得到所有 0 和 1 的无概率。
这是我正在做的事情:
#build model (node size=1)
rf<-randomForest(y~. ,data=train, ntree=800,replace=TRUE, proximilty=TRUE, keep.inbag=TRUE)
#get the predictions
#store the predictions from all the trees
all_tree_train<-predict(rf, test, type="prob", predict.all= TRUE)$individual
这给出了一个由 0 和 1 组成的矩阵,而不是概率。
【问题讨论】:
标签: r classification prediction random-forest