![](/img/trans.png)
[英]Is there a way to draw confusion matrix with known True Positive, True Negative, False Positive and False Negative?
[英]False Positive Rate in Confusion Matrix
我試圖手動計算給定數據的 TPR 和 FPR。 但不幸的是,我的數據集中沒有任何誤報案例,甚至沒有真正的正面案例。 所以我被熊貓除以零錯誤。 所以我有一個直覺,fpr=1-tpr。 如果不知道如何解決此問題,請告訴我我的直覺是正確的。
謝謝
這是獲得混淆矩陣后可以執行的操作的完整列表。
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)
如果無論您的輸入是什么,您的預測總是積極的,那么 FPR = 1 和 TPR = 1 是可能的。
TPR = 1 意味着我們正確預測了所有的積極因素。 FPR = 1 相當於當條件為負時總是預測為正。
提醒一句:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.