MCPcopy Create free account
hub / github.com/SLDGroup/EMCAD / evaluate

Function evaluate

utils/misc.py:68–80  ·  view source on GitHub ↗
(predictions, gts, num_classes)

Source from the content-addressed store, hash-verified

66
67
68def evaluate(predictions, gts, num_classes):
69 hist = np.zeros((num_classes, num_classes))
70 for lp, lt in zip(predictions, gts):
71 hist += _fast_hist(lp.flatten(), lt.flatten(), num_classes)
72 # axis 0: gt, axis 1: prediction
73 acc = np.diag(hist).sum() / hist.sum()
74 acc_cls = np.diag(hist) / hist.sum(axis=1)
75 acc_cls = np.nanmean(acc_cls)
76 iu = np.diag(hist) / (hist.sum(axis=1) + hist.sum(axis=0) - np.diag(hist))
77 mean_iu = np.nanmean(iu)
78 freq = hist.sum(axis=1) / hist.sum()
79 fwavacc = (freq[freq > 0] * iu[freq > 0]).sum()
80 return acc, acc_cls, mean_iu, fwavacc
81
82
83class AverageMeter(object):

Callers

nothing calls this directly

Calls 1

_fast_histFunction · 0.85

Tested by

no test coverage detected