简体   繁体   English

混淆矩阵中的误报率

[英]False Positive Rate in Confusion Matrix

I was trying to manually calculate TPR and FPR for the given data.我试图手动计算给定数据的 TPR 和 FPR。 But unfortunately I dont have any false positive cases in my dataset and even no true positive cases.但不幸的是,我的数据集中没有任何误报案例,甚至没有真正的正面案例。 So I am getting divided by zero error in pandas.所以我被熊猫除以零错误。 So I have an intuition that fpr=1-tpr.所以我有一个直觉,fpr=1-tpr。 Please let me know my intuition is correct if not let know how to fix this issue.如果不知道如何解决此问题,请告诉我我的直觉是正确的。

Thank you谢谢

Here is the full list of things you can do, once you have obtained the confusion matrix.这是获得混淆矩阵后可以执行的操作的完整列表。

import numpy as np

print(cnf_matrix)

array([[13,  0,  0],
       [ 0, 10,  6],
       [ 0,  0,  9]])

FP = cnf_matrix.sum(axis=0) - np.diag(cnf_matrix)  
FN = cnf_matrix.sum(axis=1) - np.diag(cnf_matrix)
TP = np.diag(cnf_matrix)
TN = cnf_matrix.sum() - (FP + FN + TP)

FP = FP.astype(float)
FN = FN.astype(float)
TP = TP.astype(float)
TN = TN.astype(float)


# Sensitivity, hit rate, recall, or true positive rate
TPR = TP/(TP+FN)
# Specificity or true negative rate
TNR = TN/(TN+FP) 
# Precision or positive predictive value
PPV = TP/(TP+FP)
# Negative predictive value
NPV = TN/(TN+FN)
# Fall out or false positive rate
FPR = FP/(FP+TN)
# False negative rate
FNR = FN/(TP+FN)
# False discovery rate
FDR = FP/(TP+FP)

# Overall accuracy
ACC = (TP+TN)/(TP+FP+FN+TN)

It is possible to have FPR = 1 with TPR = 1 if your prediction is always positive no matter what your inputs are.如果无论您的输入是什么,您的预测总是积极的,那么 FPR = 1 和 TPR = 1 是可能的。

TPR = 1 means we predict correctly all the positives. TPR = 1 意味着我们正确预测了所有的积极因素。 FPR = 1 is equivalent to predicting always positively when the condition is negative. FPR = 1 相当于当条件为负时总是预测为正。

As a reminder:提醒一句:

  • FPR = 1 - TNR = [False Positives] / [Negatives] FPR = 1 - TNR = [假阳性] / [阴性]
  • TPR = 1 - FNR = [True Positives] / [Positives] TPR = 1 - FNR = [真阳性] / [阳性]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有没有办法用已知的真阳性、真阴性、假阳性和假阴性来绘制混淆矩阵? - Is there a way to draw confusion matrix with known True Positive, True Negative, False Positive and False Negative? 如何查看混淆矩阵中标记为假阳性和假阴性的行 - How to view the rows marked as False Positive and False Negative from confusion matrix 从混淆矩阵中获取假阴性、假阳性、真阳性和真阴性的相关数据集 - Getting relevant datasets of false negatives, false positives, true positive and true negative from confusion matrix 如何从多类分类的混淆矩阵中提取假阳性,假阴性 - How to extract False Positive, False Negative from a confusion matrix of multiclass classification 自定义 TensorFlow 指标:给定假阳性率下的真阳性率 - Custom TensorFlow metric: true positive rate at given false positive rate 如何计算误报率 (FPR) 和误报率百分比? - How to compute false positive rate (FPR) and False negative rate percantage? Pandas 相当于计算误报率 - Pandas equivalent to calculate False Positive Rate 如何找到plot ROC曲线的真阳性率和假阳性率? - How to find true positive rate and false positive rate to plot ROC curve? 寻找降低机器学习分类误报率的想法 - Looking for ideas to lower the false positive rate in Machine Learning Classification 如何在 tf.keras.metrics 中找到误报率 - how to find false positive rate in tf.keras.metrics
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM