Python3 使用SVM--Lasso等,训练模型,画出auc曲线

本文详细介绍了如何使用sklearn库中的roc_curve函数绘制ROC曲线。重点解释了该函数的参数设置,特别是y_true和y_score参数的具体含义及应用示例。通过不同分类器的输出,如概率估计、决策函数值等,来生成ROC曲线所需的数据。

注意:roc_curve() 这个函数

来源于:sklearn.metrics.roc_curve

roc_curve(y_true, y_score, pos_label=None, sample_weight=None, drop_intermediate=True)

注意它的参数:
Parameters:
y_true : array, shape = [n_samples]
      True binary labels in range {0, 1} or {-1, 1}. If labels are not binary, pos_label should be explicitly given.

y_score : array, shape = [n_samples]
      Target scores, can either be probability estimates of the positive class, confidence values, or non-thresholded measure of decisions (as returned by “decision_function” on some classifiers).

pos_label : int or str, default=None
       Label considered as positive and others are considered negative.
 ...

注意第二个参数是:y_score,它可以是:对正例的概率估计值,置信度值,
决策值的非阈值测量(一些分类器中用decision_function来返回)

例如:

Model = classifier.fit(TrainX, Trainy)

1.
probas_ = Model.predict_proba(TestX)
#一些分类器直接predict_proba,返回概率值
predictions = Model.predict(TestX)
#predict返回预测值

fpr, tpr, thresholds = roc_curve(Testy,probas_[:,1],pos_label=1)

2.
probas_ = Model.decision_function(TestX)
#返回
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值