开始使用免费开始使用

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.

本练习是课程的一部分

Fraud Detection in Python

查看课程

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Calculate average precision and the PR curve
average_precision = ____(____, ____)
编辑并运行代码