det_curve#

sklearn.metrics.det_curve(y_true, y_score, pos_label=None, sample_weight=None)[源代码]#

计算不同概率阈值的错误率。

备注

该度量用于评估二元分类任务的排名和错误权衡。

阅读更多的 User Guide .

Added in version 0.24.

参数:
y_true形状的nd数组(n_samples,)

真正的二进制标签。如果标签不是{-1,1}或{0,1},则应显式给出pos_Label。

y_score形状为(n_samples,)的nd数组

目标分数可以是正类别的概率估计、置信值或决策的非阈值测量(如某些分类器上的“decision_function”返回的)。为 decision_function 分数、大于或等于零的值应表示阳性类别。

pos_labelint、float、bool或string,默认值为无

The label of the positive class. When pos_label=None, if y_true is in {-1, 1} or {0, 1}, pos_label is set to 1, otherwise an error will be raised.

sample_weight形状类似数组(n_samples,),默认=无

样本重量。

返回:
fpr形状的nd数组(n_thields,)

假阳性率(FPR),使得元素i是评分>=阈值的预测假阳性率 [i] .这有时被称为错误接受概率或后果。

fnr形状的nd数组(n_thields,)

假阴性率(FNR),使得元素i是分数>=阈值的预测的假阴性率 [i] .这有时被称为错误拒绝或未命中率。

thresholds形状的nd数组(n_thields,)

得分值下降。

参见

DetCurveDisplay.from_estimator

给定估计量和一些数据,绘制DET曲线。

DetCurveDisplay.from_predictions

给出真实和预测标签,绘制DET曲线。

DetCurveDisplay

DET曲线可视化。

roc_curve

计算接收器工作特性(ROC)曲线。

precision_recall_curve

计算准确率-召回曲线。

示例

>>> import numpy as np
>>> from sklearn.metrics import det_curve
>>> y_true = np.array([0, 0, 1, 1])
>>> y_scores = np.array([0.1, 0.4, 0.35, 0.8])
>>> fpr, fnr, thresholds = det_curve(y_true, y_scores)
>>> fpr
array([0.5, 0.5, 0. ])
>>> fnr
array([0. , 0.5, 0.5])
>>> thresholds
array([0.35, 0.4 , 0.8 ])