Python混淆矩阵的使用
confusion_matrix函数的使用
官方文档中给出的用法是
sklearn.metrics.confusion_matrix(y_true, y_pred, labels...是样本预测分类结果
labels:是所给出的类别,通过这个可对类别进行选择
sample_weight : 样本权重
实现代码:
Python
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)
print(C..."cat", "ant", "cat", "cat", "ant", "bird"]
y_pred = ["ant", "ant", "cat", "cat", "ant", "cat"]
C2 = confusion_matrix