房地产调研报告混淆矩阵的两种计算⽅法import numpy as np
朝鲜闵妃ics import classification_report
ics import confusion_matrix
def fast_hist(label_pred, label_true, num_class):
mask =(label_true >=0)&(label_true < num_class)
青春的味道作文hist = np.bincount(
num_class * label_true[mask].astype(int)+
label_pred[mask], minlength=num_class **2).reshape(num_class, num_class)
return hist
label_pred = np.array([np.arange(3, dtype='int32')]*3)
label_true = np.array([np.ones(3, dtype='int32')]*3)20000大写
# 第⼀种⽅式
关于友谊的名言num_class =3
hist = fast_hist(label_pred, label_true, num_class)
print(hist)
# 第⼆种⽅式
label_pred = shape(1,-1)[0]
label_true = shape(1,-1)[0]
print(classification_report(label_true, label_pred))
print(confusion_matrix(label_true, label_pred))
金牛座男明星
[[0 0 0]
[3 3 3]
[0 0 0]]
'recall', 'true', average, warn_for)
precision recall f1-score support
工作总结简短
0 0.00 0.00 0.00 0
1 1.00 0.33 0.50 9
2 0.00 0.00 0.00 0
micro avg 0.33 0.33 0.33 9
macro avg 0.33 0.11 0.17 9
蘑菇的英文weighted avg 1.00 0.33 0.50 9
[[0 0 0]
[3 3 3]
[0 0 0]]