Confusion Matrix: [[ 84 0 0 0] [ 0 138 0 6] [ 0 0 139 2] [ 0 2 0 1069]],计算准确率、精确率、召回率、f1值
时间: 2023-06-19 08:10:30 浏览: 65
给定混淆矩阵可以找到二类或多类指标,例如精度、召回率、F1 分数附matlab代码.zip
5星 · 资源好评率100%
根据混淆矩阵,我们可以计算出以下结果:
- 正确预测的样本数为 84+138+139+1069=1430
- 总样本数为 84+0+0+0+138+6+0+0+139+2+0+2+0+1069=1440
因此,准确率为:
```
accuracy = (TP + TN) / (TP + FP + TN + FN)
= (84 + 138 + 139 + 1069) / 1440
= 0.9931
```
精确率为:
```
precision = TP / (TP + FP)
= 84 / (84 + 0 + 0 + 0)
= 1.0000 (类别1)
= 138 / (0 + 138 + 0 + 6)
= 0.9583 (类别2)
= 139 / (0 + 0 + 139 + 2)
= 0.9857 (类别3)
= 1069 / (0 + 2 + 0 + 1069)
= 0.9981 (类别4)
```
召回率为:
```
recall = TP / (TP + FN)
= 84 / (84 + 0 + 0 + 0)
= 1.0000 (类别1)
= 138 / (138 + 2 + 0 + 0)
= 0.9857 (类别2)
= 139 / (0 + 0 + 139 + 0)
= 1.0000 (类别3)
= 1069 / (0 + 138 + 0 + 1069)
= 0.8856 (类别4)
```
F1 值为:
```
F1 = 2 * (precision * recall) / (precision + recall)
= 2 * (1.0000 * 1.0000) / (1.0000 + 1.0000)
= 1.0000 (类别1)
= 2 * (0.9583 * 0.9857) / (0.9583 + 0.9857)
= 0.9718 (类别2)
= 2 * (0.9857 * 1.0000) / (0.9857 + 1.0000)
= 0.9928 (类别3)
= 2 * (0.9981 * 0.8856) / (0.9981 + 0.8856)
= 0.9386 (类别4)
```
阅读全文