其他分享
首页 > 其他分享> > 【学习笔记】分类模型的评估

【学习笔记】分类模型的评估

作者:互联网

目录

estimator.score():一般最常见使用的是准确率,即预测结果正确的百分比

混淆矩阵

在分类任务下,预测结果(Predicted Condition)与正确标记(True Condition)之间存在四种不同的组合,构成混淆矩阵(适用于多分类)

精确率(Precision)与召回率(Recall)

sklearn分类模型评估API

sklearn.metrics.classification_report(y_true, y_pred, target_names=None)

对于【学习笔记】分类算法-朴素贝叶斯算法中20类新闻分类例子,得出其精确率和召回率:

from sklearn.metrics import classification_report

...
print("每个类别的精确率和召回率\n", classification_report(y_test, y_predict, target_names=news.target_names))

运行结果:

每个类别的精确率和召回率
                           precision    recall  f1-score   support

             alt.atheism       0.87      0.87      0.87       104
           comp.graphics       0.87      0.74      0.80       143
 comp.os.ms-windows.misc       0.89      0.84      0.87       147
comp.sys.ibm.pc.hardware       0.76      0.87      0.81       156
   comp.sys.mac.hardware       0.89      0.82      0.85       146
          comp.windows.x       0.95      0.85      0.90       149
            misc.forsale       0.91      0.75      0.82       134
               rec.autos       0.83      0.91      0.87       142
         rec.motorcycles       0.97      0.94      0.96       160
      rec.sport.baseball       0.90      0.95      0.92       132
        rec.sport.hockey       0.96      0.92      0.94       155
               sci.crypt       0.80      0.96      0.87       172
         sci.electronics       0.96      0.65      0.77       174
                 sci.med       0.95      0.86      0.90       145
               sci.space       0.84      0.98      0.90       133
  soc.religion.christian       0.46      0.99      0.63       141
      talk.politics.guns       0.80      0.97      0.87       136
   talk.politics.mideast       0.94      0.94      0.94       146
      talk.politics.misc       1.00      0.59      0.74       125
      talk.religion.misc       1.00      0.13      0.24        89

               micro avg       0.84      0.84      0.84      2829
               macro avg       0.88      0.83      0.82      2829
            weighted avg       0.87      0.84      0.84      2829

标签:comp,模型,分类,笔记,0.87,0.84,召回,0.94,评估
来源: https://www.cnblogs.com/zhangfengxian/p/10555592.html