Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to export classification_report to csv file by python

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "python how to output classification_report to csv file", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "python how to output classification_report to csv file" bar!

My pandas version:

Pandas 1.0.3

Code: from sklearn.metrics import classification_reportreport = classification_report (y_test, y_pred, output_dict=True) df = pd.DataFrame (report). Transpose () df.to_csv ("result.csv", index= True)

Is it very simple? here is a result that I have derived:

Supplement: sklearn classification_report output description

Svm-rbf0.606

Precision recall f1-score support0.0 0.56 0.39 0.46 4311.0 0.62 0.77 0.69 569avg / total 0.60 0.61 0.59 1000

The last line is calculated using the support weighted average, such as 0.59 = (431-0.46-569-0.69) / 1000

Thank you for your reading, the above is the content of "python how to export classification_report to csv file". After the study of this article, I believe you have a deeper understanding of how python exports classification_report to csv file, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report