如何从`party :: cforest()`获得OOB混淆矩阵?

时间:2016-01-29 13:49:16

标签: r random-forest party

randomForest()包中的randomForest函数非常有用provides the confusion matrix based on out-of-bag prediction in classification

cforest()does not seem to provide this information中的party功能。在party documentation中搜索“混淆”并没有产生任何有用的东西,searching here也没有。也许我忽略了什么?

有没有办法获得party::cforest()分类模型的OOB混淆矩阵?

1 个答案:

答案 0 :(得分:3)

我从party.pdf

获取了这个

比较,OOB = TRUE和FALSE

set.seed(290875)
### honest (i.e., out-of-bag) cross-classification of
### true vs. predicted classes
data("mammoexp", package = "TH.data")
table(mammoexp$ME, predict(cforest(ME ~ ., data = mammoexp,
                                   control = cforest_unbiased(ntree = 50)),
                           OOB = TRUE))


                  Never Within a Year Over a Year
  Never           195            31           8
  Within a Year    57            46           1
  Over a Year      54            20           0

table(mammoexp$ME, predict(cforest(ME ~ ., data = mammoexp,
                                   control = cforest_unbiased(ntree = 50)),
                           OOB = FALSE))
  Never Within a Year Over a Year
  Never           212            22           0
  Within a Year    58            46           0
  Over a Year      54            17           3