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, target_names=target_names))
precision recall f1-score support
class 0 0.50 1.00 0.67 1
**class 1 0.00 0.00 0.00 1**
class 2 1.00 0.67 0.80 3
avg / total 0.70 0.60 0.61 5
为什么 class1 在所有情况下的分数都是 0.0,即使它有支持!以及为什么它没有涉及 int 预测
答案 0 :(得分:1)
支持度是该类别中真实响应的样本数。因此,在您的 y_true
中,您有 1 个 class0、1 个 class 1 和 3 个 class 2。y_true 中出现的所有类都将出现在分类报告中。
检查准确率和召回率的定义。如果您没有正确猜出一个类别的任何值,则同一类别的准确率和召回率将等于 0,因为没有任何 True Positive。
所以输出是正确的。