confusion_matrix,ValueError:传递的值的形状为(3,3),索引表示(2,2)

时间:2019-01-23 20:56:56

标签: python pandas scikit-learn confusion-matrix

我使用下面的代码来可视化python中的混淆矩阵,它引发了一个异常:

  

ValueError:传递的值的形状为(3,3),索引表示为(2,2)

if_cm=confusion_matrix(y_test, preds)
import seaborn as sns
df_cm = pd.DataFrame(if_cm, ['True Normal','True Anomaly'],['Pred Normal','Pred Anomaly'])
pyplot.figure(figsize = (8,4))
sns.set(font_scale=1.4)#for label size
sns.heatmap(df_cm, annot=True,annot_kws={"size": 16},fmt='g')# font size
pyplot.show()

0 个答案:

没有答案