如何使用R脚本查找误报预测计数

Ric*_*rez 2 r

假设"test"和"train"分别是用于测试和训练的两个数据帧,"model"是使用训练数据生成的分类器.我可以找到这样的错误分类示例的数量:

n = sum(test$class_label != predict(model, test))
Run Code Online (Sandbox Code Playgroud)

我怎样才能找到预测为负数的例子数量,但实际上是正数?(即假阳性)

注意:上面的例子假设问题是二进制分类问题,其类别是"是"(正类)和"否".另外,预测是插入包的功能.

Bac*_*lin 5

这将为您提供2x2表格,显示真阳性,误报,漏报和真阴性.

> table(Truth = test$class_label, Prediction = predict(model, test))

     Prediction
Truth yes no
  yes  32  3
  no    8 27
Run Code Online (Sandbox Code Playgroud)