【发布时间】:2017-09-25 15:56:55
【问题描述】:
我想绘制 21 类分类的性能。所以我想到了绘制 EER(相等错误率)。
我已经计算了混淆矩阵,并且能够估计每个类的 FPR 和 FNR。并绘制了两个数组。但是我的情节看起来很奇怪。
这是绘制 FPR 与 FNR 以获得 EER 的正确方法吗?
我的代码:
cm = confusion_matrix(y_oos, y_oos_pred)
cm_normalized = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
FP = cm.sum(axis=0) - np.diag(cm)
FN = cm.sum(axis=1) - np.diag(cm)
TP = np.diag(cm)
TN = (len(y_oos) - (FP + FN + TP))
# False positive rate
FPR = FP/(FP+TN)
# False negative rate
FNR = FN/(TP+FN)
plt.plot(np.sort(FPR)) # Sorted in ascending order
plt.plot(np.sort(FNR)[::-1]) # Sorted in descending order
FPR array is ascending order:
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.0125 0.0125 0.0125 0.0125 0.025 0.0375]
FNR array in descending order:
[ 0.75 0.5 0.25 0.25 0.25 0.25 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
谢谢
【问题讨论】:
标签: python python-3.x visualization biometrics confusion-matrix