Phát hiện gian lận với R
Bart Baesens
Professor Data Science at KU Leuven



Gian lận là tội phạm hiếm gặp, có tính toán kỹ, che giấu tinh vi, biến đổi theo thời gian và thường được tổ chức cẩn thận, xuất hiện dưới nhiều dạng.









Sau một cơn bão lớn, công ty bảo hiểm nhận nhiều yêu cầu bồi thường
Tỷ lệ gian lận trong dữ liệu có thể tính bằng
table() và prop.table()Dùng prop.table(table(...)) để xác định tỷ lệ gian lận
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")

Dùng để đánh giá mô hình phát hiện gian lận:

predictions <- rep.int(0, times = nrow(claims))
predictions <- factor(predictions, levels = c("no fraud", "fraud"))
confusionMatrix() từ gói caret: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
Phát hiện gian lận với R