【问题标题】:classification report in machine learning sklearn [closed]机器学习 sklearn 中的分类报告 [关闭]
【发布时间】:2021-04-28 23:13:12
【问题描述】:
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 预测

【问题讨论】:

  • 你读过this吗?

标签: python machine-learning scikit-learn text-classification


【解决方案1】:

支持度是该类中真实响应的样本数。因此,在您的y_true 中,您有 1 个 class0、1 个 class 1 和 3 个 class 2。出现在您 y_true 中的所有类都将出现在分类报告中。

检查精度和召回率的定义。如果您没有正确猜出某个类的任何值,则该类的准确率和召回率将等于 0,因为没有任何真阳性。

所以输出是正确的。

【讨论】:

  • class 1 0.00 0.00 0.00 1,对未来的预测有影响吗?如果假设,我的模型精度 0.67 并且它包含该类,它对未来的预测有什么影响
  • 有了这个输出,你可以说你可能(这取决于未来的数据)在分类 class1 时会遇到问题。您必须了解什么是准确率和召回率。
猜你喜欢
  • 2019-01-27
  • 2018-11-27
  • 1970-01-01
  • 1970-01-01
  • 2016-01-03
  • 2019-06-13
  • 2016-09-19
  • 2017-12-25
  • 2017-12-25
相关资源
最近更新 更多