How does sklearn actually calculate AUROC?

浪子不回头ぞ 提交于 2019-12-23 04:43:40

问题


I understand that the ROC curve for a model is constructed by varying the threshold (that affects TPR, FPR).

Thus my initial understanding is that, to calculate the AUROC, you need to run the model many times with different threshold to get that curve and finally calculate the area.

But it seems like you just need some probability estimate of the positive class, as in the code example in sklearn's roc_auc_score below, to calculate AUROC.

>>> import numpy as np
>>> from sklearn.metrics import roc_auc_score
>>> y_true = np.array([0, 0, 1, 1])
>>> y_scores = np.array([0.1, 0.4, 0.35, 0.8])
>>> roc_auc_score(y_true, y_scores)
0.75

How does that work? Any recommended read?

来源:https://stackoverflow.com/questions/50014078/how-does-sklearn-actually-calculate-auroc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!