繁体   English   中英

如何在 R 中获得混淆矩阵?

[英]How could I obtain confusion matrix in R?

我有一个带有预测pred列的表holdouTable

library(precrec)

head(holdoutTable)

enter image description here Species geometry pred 1 1 POINT (38.80153 54.88964) 0.33363164 2 1 POINT (37.83133 55.701) 0.56814105 3 1 POINT (36.48579 55.71794) 0.09608355 4 1 POINT (37.54231 55.58439) 0.10376186 5 1 POINT (37.3788 54.9587) 0.07254712 6 1 POINT (37.40738 55.00861) 0.11294458

我计算 ROC AUC 和 plot 吧,但我不知道如何得到混淆矩阵? 有人可以帮助我吗?

holdotTable$pred <- predict(mx, hddata, type = "cloglog")

precrec_hd <- evalmod(scores = holdotTable$pred, labels = holdotTable$Species)

autoplot(precrec_hd, curvetype = "ROC")

precrec_hd

Model 名称 数据集 ID 曲线类型 AUC 1 m1 1 ROC 0.8434492 2 m1 1 PRC 0.7676958

PS 以前人们让我把 output 的代码而不是我的数据截图。 我不确定我现在是否成功,因为我只是复制表单控制台并粘贴(无论如何我都放了holdoutTable的图像)。 如果您能建议我如何正确使用它,我将很高兴知道。 谢谢!

你可以这样做:

require('caret')
require('e1071')
df <- data.frame(predicted = holdotTable$pred, actual = holdotTable$Species)
#assuming pred column contains the predicted species
confusionMatrix(data = df$predicted, reference = df$actual)

暂无
暂无

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

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