【问题标题】:Using Classification_Report function in Sklearn在 Sklearn 中使用 Classification_Report 函数
【发布时间】:2019-08-05 18:50:36
【问题描述】:

所以我对这个函数的理解是它把一个表分成两个,然后比较值来确定预测率

假设我有一张桌子:

Column1   Column2   Column3   Column4   Column5 
3          2          2          43         0
1          2          2          23         1
5          5          2          56         1
4          3          2          13         0
6          1          2          11         1

"Column 5" is label 0 or 1

我知道前 3 行是 100% 正确的,因为我手动为其分配了标签,但第 4 行和第 5 行是使用随机森林分类器标记的。我想看看预测率是多少

我想使用分类报告(y_true,y_pred,target_names=target_names),我的“y_true”,“y_pred”会是什么?我假设 target_names = 0,1

【问题讨论】:

    标签: python scikit-learn sklearn-pandas


    【解决方案1】:

    y_true 是样本的真实标签,y_pred 是模型的预测。 target_name 允许您为类标签分配自定义名称

    classification_report 报告模型的精度、召回率、f1 分数和支持度。

    示例如sklearn所示 https://scikit-learn.org/stable/modules/generated/sklearn.metrics.classification_report.html

    from sklearn.metrics import classification_report
    y_true = [0, 1, 2, 2, 2]
    y_pred = [0, 0, 2, 2, 1]
    print(classification_report(y_true, y_pred, target_names=target_names))
    

    例如,0 类的精度是 True Positive / True positive + False Positive,即 1/2 = 0.5

    【讨论】:

      猜你喜欢
      • 2023-01-04
      • 1970-01-01
      • 2018-09-09
      • 1970-01-01
      • 2021-12-22
      • 1970-01-01
      • 2019-10-26
      • 2017-10-12
      • 2018-11-11
      相关资源
      最近更新 更多