Rで学ぶ不正検知
Bart Baesens
Professor Data Science at KU Leuven



詐欺とは、まれに発生し、周到に計画され、巧みに隠蔽された、時間とともに変化する、しばしば組織的な犯罪であり、多様な形態をとる。









大規模な嵐の後、保険会社は多くの請求を受理
データ内の不正割合は以下の関数で確認可能
table() および prop.table()prop.table(table(...)) で不正の割合を算出
prop.table(table(fraud_label))
0 1
0.9911 0.0089
labels <- c("no fraud", "fraud")
labels <- paste(labels, round(100 * prop.table(table(fraud_label)), 2), "%")
pie(table(fraud_label), labels, col = c("blue", "red"),
main = "Pie chart of storm claims")

不正検知モデルの評価に使用:

predictions <- rep.int(0, times = nrow(claims))
predictions <- factor(predictions, levels = c("no fraud", "fraud"))
caret パッケージの confusionMatrix() 関数:library(caret)
confusionMatrix(data = predictions, reference = fraud_label)
Reference
Prediction 0 1
0 614 14
1 0 0
Accuracy : 0.9777
> total_cost <- sum(claim_amount[fraud_label == "fraud"])
> print(total_cost)
2301508
Rで学ぶ不正検知