从精度、召回率、f1-score 计算准确率 - scikit-learn [英] Calculating accuracy from precision, recall, f1-score - scikit-learn

查看:125
本文介绍了从精度、召回率、f1-score 计算准确率 - scikit-learn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我犯了一个巨大的错误.我将 scikit-learn svm 准确度的输出打印为:

I made a huge mistake. I printed output of scikit-learn svm accuracy as:

str(metrics.classification_report(trainExpected, trainPredict, digits=6))

现在我需要根据以下输出计算准确度:

Now I need to calculate accuracy from following output:

              precision    recall  f1-score   support

1             0.000000  0.000000  0.000000      1259
2             0.500397  1.000000  0.667019      1261
avg / total   0.250397  0.500397  0.333774      2520

是否可以根据这些值计算准确度?

Is it possible to calculate accuracy from these values?

PS:我不想再花一天时间来获取模型的输出.我刚刚意识到这个错误,希望我不需要从头开始.

PS: I don't want to spend another day for getting outputs of the model. I just realized this mistake hopefully I don't need to start from the beginning.

推荐答案

无需花更多时间在上面.metrics 模块 包含您需要的一切,并且您已经计算了预测值.这是一行更改.

No need to spend more time on it. The metrics module has everything you need in it and you have already computed the predicted values. It's a one line change.

print(metrics.accuracy_score(trainExpected, trainPredict))

我建议您花一些时间阅读链接页面,以了解有关评估模型的更多信息.

I suggest that you spend some time to read the linked page to learn more about evaluating models in general.

我确实认为您手头有一个更大的问题 - 尽管具有平衡的类,但您的 1 类的预测值为零.您可能需要处理数据、建模策略或代码方面的问题.

I do think you have a bigger problem with at hand -- you have zero predicted values for your 1 class, despite having balanced classes. You likely have a problem in your data, modeling strategy, or code that you'll have to deal with.

这篇关于从精度、召回率、f1-score 计算准确率 - scikit-learn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆