简体   繁体   English

如何加载已计算的混淆矩阵以与R中的插入符号包一起使用

[英]How to load already computed confusion matrix to be used with the caret package in R

I have trained a Random Forest classifier ( randomForest package) and it returns also the confusion matrix. 我已经训练了一个随机森林分类器( randomForest包),它也返回混淆矩阵。

I want to compute sensitivity and specificity for each class, so I decided to load the confusion matrix with the caret package. 我想计算每个班级的敏感性和特异性,因此我决定使用caret包加载混淆矩阵。 However I did not find how to load it. 但是我没有找到如何加载它。 How can I achieve it? 我该如何实现?

Thanks to Sowmya's comments, I achieve it by using the following code: 感谢Sowmya的评论,我通过使用以下代码实现了它:

library(caret)
confusionMatrix(clf$predicted, labels)

where clf is the result of the execution of randomForest() call, while labels is the lists of reference labels of the output variable. 其中clf是执行randomForest()调用的结果,而labels是输出变量的参考标签的列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM