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.
Este ejercicio forma parte del curso
Fraud Detection in R
Instrucciones del ejercicio
- Use
rep.int()to create a vector calledpredictionsin 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 thecaretpackage to compute the confusion matrix ofpredictionsand thefraud_flagcolumn fromtransfers. - Compute the total cost of not detecting fraud as the sum of fraudulent transferred amounts.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# 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)