SMOTE
在使用 SMOTE 對詐欺類別進行過度抽樣時,你需要決定要考慮的最近鄰個數,以及要生成多少筆合成的詐欺案例。接下來的練習會帶你一步步使用 SMOTE。
資料集 creditcard 與函式庫 smotefamily、ggplot2 已載入至你的工作環境。請記得,dup_size 參數用來回答 SMOTE 應該在現有的真實詐欺案例上迭代幾次。
本練習屬於課程
R 的詐欺偵測
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Set the number of fraud and legitimate cases, and the desired percentage of legitimate cases
n0 <- ___; n1 <- ___; r0 <- ___