文章詳情頁
python 如何把classification_report輸出到csv文件
瀏覽:2日期:2022-06-19 18:39:48
今天想把classification_report的統計結果輸出到文件中,我這里分享一下一個簡潔的方式:
我的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)
是不是很簡單,下面是我導出來的一個結果:
補充: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 加權平均算出來的,如0.59 = (431*0.46+569*0.69)/ 1000
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持好吧啦網。
相關文章:
排行榜