python - 为什么要减小 text_label 形状?
问题描述
我已经拍摄了 160 张数据图像进行测试,在训练我的图像数据集和打印 test_label 形状和预测形状之后,
print("Test Label shape: ",test_labels.shape)
print("Predictions shape: ",predictions.shape)
Test Label shape: (160,)
Predictions shape: (10, 2)
从预测形状和测试标签形状我应该减少 test_label 形状否则它会显示错误所以我使用下面的代码来获取混淆矩阵,
cm = confusion_matrix(test_labels[:-150], predictions.argmax(axis=1))
在使用下面的代码后,它会打印出矩阵,
import itertools
cm_plot_labels = ['disease_leaf','fresh_leaf']
plot_confusion_matrix(cm, cm_plot_labels, title='Confusion Mtrix')
在矩阵下方, [[10, 0] [ 0, 0]]
注意: 现在我对矩阵感到困惑并有一些疑问,请分享一下谁知道为什么需要减小 test_label 形状的意见?
是否可以在不减小 test_label 形状的情况下打印混淆矩阵。因为为了减小形状,混淆矩阵提供了 10 个之间的混淆矩阵,但我认为它应该提供 160 个之间的混淆矩阵。
解决方案
推荐阅读
- c - 在 C 中重定向标准错误
- node.js - 发送过多电子邮件时超出 Gmail API 配额限制
- python - cv2.imshow() 函数显示正确的图像,但在使用 cv2.imwrite() 函数保存时,它保存了所有黑色像素图像?
- statistics - 计算 ctr 时如何标准化印象偏差?
- swift - 如何扩展一个数组,其中元素是具有符合协议的元素的数组
- python - 动态调用参数大小未知的函数
- qemu - virsh 的问题 / 无法连接到 qemu
- r - R 错误 (JAGS) 无法将节点插入 alpha[1:284]。尺寸不匹配
- android - 使用 Rx 和 GIPHY 测试 ViewModel
- javascript - 使用过滤器方法从数组中提取彼此之间具有精确间隙的数字