Unverified 提交 ec2da4a8 authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Add ConfusionMatrix `normalize=True` flag (#3586)

上级 46e1fdfb
...@@ -158,11 +158,12 @@ class ConfusionMatrix: ...@@ -158,11 +158,12 @@ class ConfusionMatrix:
def matrix(self): def matrix(self):
return self.matrix return self.matrix
def plot(self, save_dir='', names=()): def plot(self, normalize=True, save_dir='', names=()):
try: try:
import seaborn as sn import seaborn as sn
array = self.matrix / (self.matrix.sum(0).reshape(1, self.nc + 1) + 1E-6) # normalize if normalize:
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)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论