I have the following code:
from sklearn.metrics import roc_curve, auc
actual = [1,1,1,0,0,1]
prediction_scores = [0.9,0.9,0.9,0.1,0.1,0.1]
false_positive_rate, true_positive_rate, thresholds = roc_curve(actual, prediction_scores, pos_label=1)
roc_auc = auc(false_positive_rate, true_positive_rate)
roc_auc
# 0.875
在这个例子中,
prediction_scores
的解释很直接,即得分越高,预测结果就越可信。
现在我有另一组预测得分。它是非分数的,而且解释相反。意思是得分越低,预测结果就越可信。prediction_scores_v2 = [10.3,10.3,10.2,10.5,2000.34,2000.34]
# so this is equivalent
我的问题是:如何缩放
prediction_scores_v2
,使其具有类似于第一个的AUC得分?
换句话说,Scikit的ROC_CURVE要求y_score
为正类的概率估计值。如果我的y_score
是错误类别的概率估计值,我该如何处理这个值?