R 从随机林结果检索实例

R 从随机林结果检索实例,r,random-forest,feature-selection,R,Random Forest,Feature Selection,我正在修改随机林模型中的特性,不知怎的,我发现大量实例被错误分类,我如何才能找到那些错误分类案例的用户ID fit1 <- cforest((b == 'three')~ affect+ certain+ negemo+ future+swear+sad +negate+ppron+sexual+death + filler+leisure + conj+ funct + i +future + past + bio + body+c

我正在修改随机林模型中的特性,不知怎的,我发现大量实例被错误分类,我如何才能找到那些错误分类案例的用户ID

  fit1 <- cforest((b == 'three')~   affect+ certain+ negemo+ future+swear+sad
            +negate+ppron+sexual+death + filler+leisure + conj+ funct + i
            +future + past + bio + body+cause + cogmech + death +
            discrep + future +incl + motion + quant + sad + tentat + excl+insight +percept +posemo
            +ppron +quant + relativ + space + article
            , data = trainset1, 
            controls=cforest_unbiased(ntree=1000, mtry= 1))

 table1 <- table(predict(fit1, OOB=TRUE, type = 'response') > 0.5, trainset1$b == 'three') 

结果显示,其他类中的821个被错误分类为“三”,如何根据userid检索这些821个案例,以便比较它们的特性。多谢各位

因此,您希望获取一些已经用于创建该表的代码,并使用它来选择要放入该表左下角的行

下面是使您的表正常工作的代码:

predict(fit1, OOB=TRUE, type = 'response') > 0.5, trainset1$b == 'three'
如果运行第一部分,将得到所有预测的向量:

p<-predict(fit1, OOB=TRUE, type = 'response')
p0.5阈值,您将得到一个表示您的预测高于或低于该阈值的真和假向量:

tf<- p>0.5
tf0.5
现在,最后一部分提供另一个真值和假值向量,trainset1$b==“三”。你想知道哪些行被归类为“三”(我认为这在tf中是真的,即p>0.5),但实际上不属于“三”(问题trainset1$b==“三”)类。要解决这个问题,您需要tf==TRUE和trainset1$b的所有行=“三”:


newdata
cforest
属于哪个包?
tf<- p>0.5
newdata<- trainset1[tf==TRUE & trainset1$b!="three",]