欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python 如何把classification_report輸出到csv文件

 更新時(shí)間:2021年05月13日 09:55:27   作者:農(nóng)民小飛俠  
這篇文章主要介紹了python 把classification_report輸出到csv文件的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

今天想把classification_report的統(tǒng)計(jì)結(jié)果輸出到文件中,我這里分享一下一個(gè)簡(jiǎn)潔的方式:

我的pandas版本:

pandas 1.0.3

代碼:

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

是不是很簡(jiǎn)單,下面是我導(dǎo)出來(lái)的一個(gè)結(jié)果:

補(bǔ)充:sklearn classification_report 輸出說(shuō)明

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)平均算出來(lái)的,如0.59 = (431*0.46+569*0.69)/ 1000

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論