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로 배우는 사기 탐지