【问题标题】:Issue with caseweights and OOB prediction using cforest from the party package使用派对包中的 cforest 的案例权重和 OOB 预测问题
【发布时间】:2018-09-28 07:20:38
【问题描述】:

我正在使用可选参数 caseweights 拟合 cforest,它是一个双矩阵,其中 ncol(caseweights)== 我的随机森林中的树数和 nrow(caseweights)= 观察数。此外,我正在对它们进行规范化,以使 colSums 等于 1。但是,当我想将我的 OOB 预测与真实响应进行比较时,我总是会收到以下错误:

RET@prediction_weights 中的错误(newdata = newdata,mincriterion = mincriterion, : 无法计算袋外预测 观察号 1

我在 github 上查了 C 源代码,但找不到为什么它不起作用。

(如果我使用“标准”权重,即长度 == 观察次数的向量,仅用于采样,也会出现同样的错误)

我做错了什么?

这是一个可重现的例子:

install.packages('party')
require('party')
head(iris)
weights<-rep(1,nrow(iris))
weights[iris$Species=='virginica']<-2
#normalize
weights<-weights/sum(weights) 
ntree<-100
#generate double matrix of caseweights
caseweights<-matrix(rep(weights,ntree),ncol=ntree)
colSums(caseweights)
#fit forest
f <- cforest(Species ~ ., data = iris,controls = cforest_unbiased(ntree=ntree,mtry=3,trace=TRUE),weights=caseweights)
#check out of bag cross classification
table(iris$Species,Predict(f,OOB=TRUE)) #throws error

非常感谢您的帮助。

【问题讨论】:

  • 非常感谢 Torsten,我今天在拟合后提取权重时认出了它。最好的

标签: random-forest prediction party


【解决方案1】:

好吧,您的权重都不是零,因此没有袋外观察,这就是错误消息正确告诉您的内容。顺便说一句,派对不在 github 上,而是在 R-forge 上。

托尔斯滕

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2020-02-26
  • 2013-01-23
  • 2014-12-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-07
相关资源
最近更新 更多