Unverified 提交 2c56ad54 authored 作者: Ryan Avery's avatar Ryan Avery 提交者: GitHub

Confusion matrix background axis swap (#2114)

上级 ab86cec8
...@@ -147,12 +147,12 @@ class ConfusionMatrix: ...@@ -147,12 +147,12 @@ class ConfusionMatrix:
if n and sum(j) == 1: if n and sum(j) == 1:
self.matrix[gc, detection_classes[m1[j]]] += 1 # correct self.matrix[gc, detection_classes[m1[j]]] += 1 # correct
else: else:
self.matrix[gc, self.nc] += 1 # background FP self.matrix[self.nc, gc] += 1 # background FP
if n: if n:
for i, dc in enumerate(detection_classes): for i, dc in enumerate(detection_classes):
if not any(m1 == i): if not any(m1 == i):
self.matrix[self.nc, dc] += 1 # background FN self.matrix[dc, self.nc] += 1 # background FN
def matrix(self): def matrix(self):
return self.matrix return self.matrix
...@@ -168,8 +168,8 @@ class ConfusionMatrix: ...@@ -168,8 +168,8 @@ class ConfusionMatrix:
sn.set(font_scale=1.0 if self.nc < 50 else 0.8) # for label size sn.set(font_scale=1.0 if self.nc < 50 else 0.8) # for label size
labels = (0 < len(names) < 99) and len(names) == self.nc # apply names to ticklabels labels = (0 < len(names) < 99) and len(names) == self.nc # apply names to ticklabels
sn.heatmap(array, annot=self.nc < 30, annot_kws={"size": 8}, cmap='Blues', fmt='.2f', square=True, sn.heatmap(array, annot=self.nc < 30, annot_kws={"size": 8}, cmap='Blues', fmt='.2f', square=True,
xticklabels=names + ['background FN'] if labels else "auto", xticklabels=names + ['background FP'] if labels else "auto",
yticklabels=names + ['background FP'] if labels else "auto").set_facecolor((1, 1, 1)) yticklabels=names + ['background FN'] if labels else "auto").set_facecolor((1, 1, 1))
fig.axes[0].set_xlabel('True') fig.axes[0].set_xlabel('True')
fig.axes[0].set_ylabel('Predicted') fig.axes[0].set_ylabel('Predicted')
fig.savefig(Path(save_dir) / 'confusion_matrix.png', dpi=250) fig.savefig(Path(save_dir) / 'confusion_matrix.png', dpi=250)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论