随机森林分类器R:返回概率代替因子
理想情况下,下面的代码应该返回y_pred_random forest作为两个级别的因子随机森林分类器R:返回概率代替因子,r,classification,random-forest,R,Classification,Random Forest,理想情况下,下面的代码应该返回y_pred_random forest作为两个级别的因子 randomForest_classifier= randomForest(x=training_set[-y_pos],y=training_set[y_pos],ntree=10) y_pred_randomForest= predict(randomForest_classifier,newdata=test_set[-y_pos],type='class') 但它的返回概率相反 head(y_pr
randomForest_classifier= randomForest(x=training_set[-y_pos],y=training_set[y_pos],ntree=10)
y_pred_randomForest= predict(randomForest_classifier,newdata=test_set[-y_pos],type='class')
但它的返回概率相反
head(y_pred_randomForest)
1 5 14 16 18 21
0.2220672 0.3300000 0.1750000 0.7200000 0.1200000 0.2000000
谢谢,非常感谢您的帮助我认为您需要
type=“response”
,但这应该等同于type=“class”
(这是允许的,但转换为type=“response”
)。确认一下:你的结果变量是因子,而不是数字?我想问的是结果是否是因子而不是数字,我需要我的结果是两个层次的因子。但我得到了一个数字结果