如何使用SGD分类器loss = hinge进行交叉验证来生成ROC曲线

时间:2018-01-12 05:32:25

标签: machine-learning scikit-learn

我们希望使用具有损失=铰链的SGD分类器通过corss验证生成ROC治愈,但它不支持,因为ROC曲线需要概率。我们希望严格坚持铰链,因为它符合我们的要求,并希望使用ROC曲线验证训练的模型精度。请建议如何使用loss = hinge进行交叉验证生成ROC曲线

1 个答案:

答案 0 :(得分:2)

在这里你可以使用决策功能" loss = hinge"这让你与超平面的距离 在这里如何申请

svm_clf.fit(Xtrain, Xtarget)
score_roc = svm_clf.decision_function(Ytest)
        fpr, tpr, thresholds = metrics.roc_curve(Ytarget, score_roc)
        roc_auc = auc(fpr, tpr)
        plt.title('Receiver Operating Characteristic')
        plt.plot(fpr, tpr, 'b', label='AUC = %0.2f' % roc_auc)
        plt.legend(loc='lower right')
        plt.ylabel('True Positive Rate')
        plt.xlabel('False Positive Rate')
        plt.show()