原理
横轴一般是predict label,纵轴是ground truth label,对角线是预测正确的概率或个数
绘制
sklearn 中confusion_matrix函数的使用:
sklearn.metrics.confusion_matrix(y_true, y_pred, labels=None, sample_weight=None)
输入就是类别序号,不能是onehotlabel,如果是onehot label 用y_pred = np.argmax(y_pred,axis= -1)+1
转换
y_true : array, shape = [n_samples] Ground truth (correct) target values.
y_pred : array, shape = [n_samples] Estimated targets as returned by a classifier.
from sklearn.metrics import confusion_matrix
y_true=[2,1,0,1,2,0]
y_pred=[2,0,0,1,2,1]
C=confusion_matrix(y_true, y_pred)
纵轴是y_true, 横轴是y_pred
一 、带有acc的confusion matrix
#label参数`
label