ConfusionMatrix normalize=True fix (#3587)
This commit is contained in:
1 parent
ec2da4a82c
commit
e8c5237403
1 file changed
+2
-3
+2
-3
@@ -162,8 +162,7 @@ class ConfusionMatrix:
|
|||||||
try:
|
try:
|
||||||
import seaborn as sn
|
import seaborn as sn
|
||||||
|
|
||||||
if normalize:
|
array = self.matrix / ((self.matrix.sum(0).reshape(1, -1) + 1E-6) if normalize else 1) # normalize columns
|
||||||
array = self.matrix / (self.matrix.sum(0).reshape(1, self.nc + 1) + 1E-6) # normalize columns
|
|
||||||
array[array < 0.005] = np.nan # don't annotate (would appear as 0.00)
|
array[array < 0.005] = np.nan # don't annotate (would appear as 0.00)
|
||||||
|
|
||||||
fig = plt.figure(figsize=(12, 9), tight_layout=True)
|
fig = plt.figure(figsize=(12, 9), tight_layout=True)
|
||||||
@@ -178,7 +177,7 @@ class ConfusionMatrix:
|
|||||||
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)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
print(f'WARNING: ConfusionMatrix plot failure: {e}')
|
||||||
|
|
||||||
def print(self):
|
def print(self):
|
||||||
for i in range(self.nc + 1):
|
for i in range(self.nc + 1):
|
||||||
|
|||||||
Reference in new issue
Block a user