sklearn.metrics.auc?
sklearn.metrics.auc(x, y)
使用梯形法則計算曲線下面積(AUC)
給定曲線上的點,這是一項常規功能。要計算ROC曲線下的面積,請參閱roc_auc_score
。 有關匯總精確調用曲線的另一種方法,請參見average_precision_score
。
參數 | 說明 |
---|---|
x | array, shape = [n] x坐標。這些必須是單調遞增或單調遞減。 |
y | array, shape = [n] y坐標。 |
返回值 | 說明 |
---|---|
auc | float |
另見
計算ROC曲線下的面積
根據預測分數計算平均精度
計算不同概率閾值的精確召回對
示例
>>> import numpy as np
>>> from sklearn import metrics
>>> y = np.array([1, 1, 2, 2])
>>> pred = np.array([0.1, 0.4, 0.35, 0.8])
>>> fpr, tpr, thresholds = metrics.roc_curve(y, pred, pos_label=2)
>>> metrics.auc(fpr, tpr)
0.75