python one class svm_如何在python中为一类SVM计算AUC?

在Python中使用sklearn的OneClassSVM进行AUC绘图时遇到困难,因为OneClassSVM的混淆矩阵只有真阳性(TP)和假阴性(FN),导致计算AUC时出现ValueError。解决方案是由于OneClassSVM不支持转化为概率得分,所以不能直接用于ROC曲线。可以计算决定函数的最大值(MAX),然后用MAX减去每个观测值的决定函数结果作为预测得分。这样可以用来估算非阈值得分,如平均精度召回率。但要注意,对于严重不平衡的OneClassSVM情况,ROC曲线可能无法准确反映对少数类别的成功度。
摘要由CSDN通过智能技术生成

I have difficulty in plotting OneClassSVM's AUC plot in python (I am using sklearn which generates confusion matrix like [[tp, fp],[fn,tn]] with fn=tn=0.

from sklearn.metrics import roc_curve, auc

fpr, tpr, thresholds = roc_curve(y_test, y_nb_predicted)

roc_auc = auc(fpr, tpr) # this generates ValueError[1]

print "Area under the ROC curve : %f" % roc_auc

plt.plot(fpr, tpr, label='ROC curve (area = %0.2f)' % roc_auc)

I want to handle error [1] and plot AUC for OneClassSVM.

[1] ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

解决方案

Please see my answer on a similar question. The gist is:

OneClassSVM fundamentally doesn't support converting a decision into a probability score, so you cannot pass the necessary scores into functions t

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值