使用套件
scikit-plot
https://pypi.org/project/scikit-plot/
matplotlib
https://pypi.org/project/matplotlib/
安裝方式
pip install scikit-plot
pip install matplotlib
import scikitplot as skplt
import matplotlib.pyplot as plt
y_true = # ground truth labels
y_probas = # predicted probabilities generated by sklearn classifier
skplt.metrics.plot_roc_curve(y_true, y_probas)
plt.show()
範例資料:
假設我們模型跑完的結果長這樣
把 gt_class 資料整理成 list 存到 y_true 裡面
長這樣 (label 範圍 0 ~ 6,共 7 個類別)
y_true = [2, 5, 5, 3, 2, 1, ...... ]
把 pred_prob 資料整理成二維 list 存到 prob_list 裡面
長這樣 (我的模型輸出的每一筆資料含有 7 個機率值)
prob_list = [[8.5276943e-06, 5.0007920e-06, 9.9994439e-01, 4.3...],
[5.6465615e-06 4.8560273e-06 6.0416551e-06 5.7..],
[2.5744524e-04 1.5103277e-03 3.2300744e-04 3.1...],
[2.5181988e-02 8.9589570e-04 6.6928881e-01 3.0...],
[7.5951771e-06 9.9995345e-01 8.5064212e-06 5.4...],
...
]
繪製 ROC Curve
import scikitplot as skplt
import matplotlib.pyplot as plt
skplt.metrics.plot_roc_curve(y_true,prob_list)
plt.savefig('{}_roc_curve.png'.format(model_name)) # 圖片存檔
plt.show() # 顯示出來
使用套件: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_fscore_support.html 這篇舉例說明頗清楚: https://blog.csdn.net/jmh1996/article/details/114935105 我也來舉個例子: Notations gt: ground truth
Mar 7, 2023設定 Google Drive API 去 google cloud console 上建一個專案 https://console.cloud.google.com/ 接著在專案裡面搜尋 Google Drive API  接著啟用它  去憑證 (Credentials) 點選"+建立憑證" 然後,選擇 "服務帳戶"  設定完服務帳戶 ID 後可以在下方看到一組服務帳戶ID為首的email帳號去 google sheet 表單中,將該帳號加入共用名單當中
Feb 23, 2023情境說明 我在 main.py 裡面定義了許多 argument 參數例如長這樣 然後我的 cmd.sh 長這樣 python main.py --model GaussianCopula \ --input_path data/train_raw.csv \ --output_dir data/ \ --num_rows 1000 \ --save_output \
Feb 21, 2023Melody: X:1 T: 周杰倫 - 紅顏如霜 (前奏) T: (melody) L:1/4 K: Bb {F,1G,1B,1CDFGBcdfgbc'}| d'2 z1/4B1/4F1/4G1/4 B1/4{c}d1/4c1/4B1/4| c2 z1/4{gf}d1/4c1/4d1/4 c1/4B1/4G1/4F1/4 | B2 c2 | d>{FFF}F F1/4G1/4B1/4c1/4 d1/4f1/4g1/4b1/4 | f2 z1/4B1/4F1/4G1/4 B1/4{c}d1/4c1/4B1/4| c2 z1/4{gf}d1/4c1/4d1/4 c1/4B1/4G1/4F1/4 | B2 z1/2G1/2c1 | B4 | X:1
Dec 16, 2022or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up