信用卡欺诈检测与推荐系统的机器学习探索
信用卡欺诈检测模型评估与构建
在信用卡欺诈检测领域,为了评估模型性能,我们首先定义了一些关键操作和函数。
首先是绘制ROC曲线的相关代码:
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver operating characteristic: Area under the \
curve = {0:0.2f}'.format(areaUnderROC))
plt.legend(loc="lower right")
plt.show()
if returnPreds==True:
return preds, average_precision
接着,我们定义了一个名为 precisionAnalysis 的函数,用于评估模型在特定召回率水平下的精度,具体是确定模型在捕获测试集中75%的欺诈性信用卡交易时的精度,精度越高,模型越好。代码如下:
def precisionAnalysis(df, column, threshold):
df.sort_values(by=column, ascending=False, inplace=True)
threshold_value = threshold*df.trueLabel.sum()
超级会员免费看
订阅专栏 解锁全文
23

被折叠的 条评论
为什么被折叠?



