文章詳情頁
python 如何把classification_report輸出到csv文件
瀏覽:36日期:2022-06-19 18:39:48
今天想把classification_report的統(tǒng)計(jì)結(jié)果輸出到文件中,我這里分享一下一個(gè)簡潔的方式:
我的pandas版本:pandas 1.0.3
代碼: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)
是不是很簡單,下面是我導(dǎo)出來的一個(gè)結(jié)果:

補(bǔ)充:sklearn classification_report 輸出說明
svm-rbf 0.606 precision recall f1-score support 0.0 0.56 0.39 0.46 431 1.0 0.62 0.77 0.69 569 avg / total 0.60 0.61 0.59 1000最后一行是用support 加權(quán)平均算出來的,如0.59 = (431*0.46+569*0.69)/ 1000
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 用Spring JMS使異步消息變得簡單2. 一文帶你徹底理解Java序列化和反序列化3. PHP驗(yàn)證碼工具-Securimage4. js實(shí)現(xiàn)碰撞檢測5. 關(guān)于IDEA 2020.3 多窗口視圖丟失的問題6. JS實(shí)現(xiàn)前端動(dòng)態(tài)分頁碼代碼實(shí)例7. javascript實(shí)現(xiàn)貪吃蛇小練習(xí)8. Python 下載Bing壁紙的示例9. Python 制作查詢商品歷史價(jià)格的小工具10. ASP.NET MVC使用jQuery ui的progressbar實(shí)現(xiàn)進(jìn)度條
排行榜

網(wǎng)公網(wǎng)安備