简体   繁体   English

如何以百分比输出scikit学习分类报告?

[英]How to output scikit learn classification report in percent?

Is it possible to output with scikit-learn classification report in percent?. 是否可以用百分比输出scikit-learn分类报告? Let's assume I print the classification report like this: 我们假设我打印分类报告如下:

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

and I want get output in percent(*100): 我希望以百分比(* 100)获得输出:

 precision    recall  f1-score   support

class 0       67      100      80         2
class 1       0       0        0          1
class 2       100     50       67         2

avg / total 67 60 59 5

The only option in the current version (0.18.1) is to change the print precision using the digits parameter, but it will always be a ratio. 当前版本(0.18.1)中唯一的选项是使用digits参数更改打印精度,但它始终是一个比率。

You could write a function that parses the output string and converts the ratio into percent. 您可以编写一个解析输出字符串并将比率转换为百分比的函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM