我使用 fusion_matrix 模块来可视化类预测结果与实际值的比较。
val= ... #shape (3000,1,30) dtype float32
pred = ... #shape (3000,1,30) dtype float32
cnf_matrix = confusion_matrix(val, pred) #ERROR HERE
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
回溯(最近一次调用最后一次):文件“vis.py”,第 757 行,在 cnf_matrix = fusion_matrix(y_test, y_pred) 文件“C:\Anaconda\envs\nn35\lib\site-packages\sklearn\metrics\classification. py”,第 240 行,confusion_matrix y_type, y_true, y_pred = _check_targets(y_true, y_pred) 文件“C:\Anaconda\envs\nn35\lib\site-packages\sklearn\metrics\classification.py”,第 89 行,在_check_targets raise ValueError("不支持{0}".format(y_type)) ValueError: 不支持未知
我做错了什么?
问题是真实值和预测的形状必须是 (3000,30) 而不是 (3000,1,30)。所以我用它重塑它pred= np.reshape(pred, (pred.shape[0], 30))
| 归档时间: |
|
| 查看次数: |
9142 次 |
| 最近记录: |