BaşlayınÜcretsiz Başlayın

Cost of not detecting fraud

When no detection model is used, then all transactions in the transfers dataset are considered legitimate. You will determine the corresponding confusion matrix. Despite fraud being rare, the resulting financial losses can be huge. You will compute the total cost of not detecting the fraudulent transfers.

The caret package is already loaded for you to construct the confusionMatrix(). The transfers dataset is loaded in your workspace, don't hesitate to explore it in the Console.

Bu egzersiz

Fraud Detection in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Use rep.int() to create a vector called predictions in which all transfers are predicted as legitimate (class 0). Don't hesitate to look at the slides to see how this function was used in the video.
  • Use the function confusionMatrix() from the caret package to compute the confusion matrix of predictions and the fraud_flag column from transfers.
  • Compute the total cost of not detecting fraud as the sum of fraudulent transferred amounts.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create vector predictions containing 0 for every transfer
predictions <- factor(___(___, times = ___(___)), levels = c(0, 1))

# Compute confusion matrix
confusionMatrix(data = ___, reference = ___)

# Compute cost of not detecting fraud
cost <- sum(___[___ == ___])
print(cost)
Kodu Düzenle ve Çalıştır