[英]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:提醒一句:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.