相关疑难解决方法(0)

如何在逻辑回归中得到ROC的最优截止点作为数字

我想在逻辑回归中得到ROC的最佳截止点作为数字而不是两条交叉曲线.使用下面的代码,我可以得到将显示最佳点的图,但在某些情况下,我只需要将该点作为可用于其他计算的数字.以下是代码行:

library(Epi)
ROC( form = IsVIP ~ var1+var2+var3+var4+var5, plot="sp", data=vip_data ) 
Run Code Online (Sandbox Code Playgroud)

谢谢

r roc

7
推荐指数
1
解决办法
9121
查看次数

如何从Python中的ROC曲线获得最佳阈值?

我想使用 Python 从 ROC 曲线中获得最佳阈值。我知道如何使用 coords 函数在 R 中执行此操作,但我似乎无法在 Python 中找到类似的函数。

这是我显示 ROC 曲线的方式

def plot_roc_curve(fpr,tpr, thresholds):
    plt.figure()
    plt.plot(fpr, tpr, color='darkorange', label='ROC curve (area = %0.2f)' % metrics.auc(fpr, tpr))
    plt.plot([0, 1], [0, 1], color='navy', linestyle='--')
    plt.xlim([0.0, 1.0])
    plt.ylim([0.0, 1.05])
    plt.xlabel('False Positive Rate')
    plt.ylabel('True Positive Rate')
    plt.legend(loc="lower right")

    # create the axis of thresholds (scores)
    ax2 = plt.gca().twinx()
    ax2.plot(fpr, thresholds, markeredgecolor='r',linestyle='dashed', color='r')
    ax2.set_ylabel('Threshold',color='r')
    ax2.set_ylim([thresholds[-1],thresholds[0]])
    ax2.set_xlim([fpr[0],fpr[-1]])

    plt.savefig('roc_and_threshold.png')
    plt.close()
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

python machine-learning scikit-learn

4
推荐指数
1
解决办法
6009
查看次数

标签 统计

machine-learning ×1

python ×1

r ×1

roc ×1

scikit-learn ×1