Scikit learn 关于正类和sklearn metric pos_label=0的混淆
我有一个用于检测AO/非AO图像的二进制分类问题,为此使用Pytork。Scikit learn 关于正类和sklearn metric pos_label=0的混淆,scikit-learn,classification,roc,confusion-matrix,auc,Scikit Learn,Classification,Roc,Confusion Matrix,Auc,我有一个用于检测AO/非AO图像的二进制分类问题,为此使用Pytork。 首先,我使用ImageFolder实用程序加载数据。 Dataset.class_to_idx中的数据集类到标签映射是{0:'AO',1:'Non-AO'} 因此,我的“积极类”AO分配了一个标签0,而我的“消极类”非AO分配了一个标签1。 然后我培训并验证模型,没有任何问题。 在进行测试时,我需要计算测试数据的一些指标。 这就是我困惑的地方。 [方法A] fpr, tpr, thresholds = roc_curve(
首先,我使用ImageFolder实用程序加载数据。
Dataset.class_to_idx
中的数据集类到标签映射是{0:'AO',1:'Non-AO'}
因此,我的“积极类”AO分配了一个标签0,而我的“消极类”非AO分配了一个标签1。
然后我培训并验证模型,没有任何问题。
在进行测试时,我需要计算测试数据的一些指标。
这就是我困惑的地方。
[方法A]
fpr, tpr, thresholds = roc_curve(y_true, y_score)
roc_auc = auc(fpr, tpr)
# because 0 is my actual 'positive' class for this problem
fpr, tpr, thresholds = roc_curve(y_true, y_score, pos_label=0)
roc_auc = auc(fpr, tpr)
[方法B]fpr, tpr, thresholds = roc_curve(y_true, y_score)
roc_auc = auc(fpr, tpr)
# because 0 is my actual 'positive' class for this problem
fpr, tpr, thresholds = roc_curve(y_true, y_score, pos_label=0)
roc_auc = auc(fpr, tpr)
现在,第二条曲线基本上是第一条曲线沿对角线的镜像,对吗?我认为,它不可能是正确的曲线,因为我通过直接比较
y_true
和y_pred
来检查模型的准确性,以获得以下精度
除此之外,我的混淆矩阵是这样的。
真阳性
或真阴性
或任何其他术语对我的混淆矩阵意味着什么?矩阵是否考虑0:AO为负和1:非AO为正(我想是的,是的)还是反之亦然?