from: https://zhuanlan.zhihu.com/p/368196647
多分类
from sklearn.metrics import classification_report
y_true = [0, 1, 2, 2, 2]
y_pred = [0, 0, 2, 2, 1]
target_names = ['class 0', 'class 1', 'class 2']
print(classification_report(y_true, y_pred))
多标签分类
import numpy as np
from sklearn.metrics import classification_report
y_true = np.array([ [1, 0, 1, 0, 0],
[0, 1, 0, 1, 1],
[1, 1, 1, 0, 1]])
y_pred = np.array([[1, 0, 0, 0, 1],
[0, 1, 1, 1, 0],
[1, 1, 1, 0, 0]])
print(classification_report(y_true, y_pred, digits=3))
理解多标签分类中 micro avg, precision表示所有预测1中,对的个数,所以是/8;recall表示所有样本1中,对的个数,所以是/9