1. Learn
  2. /
  3. Courses
  4. /
  5. Fraud Detection in Python

Exercise

Plotting the Precision Recall Curve

You can also plot a Precision-Recall curve, to investigate the trade-off between the two in your model. In this curve Precision and Recall are inversely related; as Precision increases, Recall falls and vice-versa. A balance between these two needs to be achieved in your model, otherwise you might end up with many false positives, or not enough actual fraud cases caught. To achieve this and to compare performance, the precision-recall curves come in handy.

Your Random Forest Classifier is available as model, and the predictions as predicted. You can simply obtain the average precision score and the PR curve from the sklearn package. The function plot_pr_curve() plots the results for you. Let's give it a try.

Instructions 1/3

undefined XP
    1
    2
    3
  • Calculate the average precision by running the function on the actual labels y_test and your predicted labels predicted.