def rmse(self, tid_counts):
error = np.zeros(shape=[self.cls_nb])
err_nb = 0
self._progress('\ntid \t true_count \t obs_count \t difference',
end='\n', verbosity=VERBOSITY.VERBOSE)
for tid in tid_counts:
true_counts = self.tid_counts[tid]
obs_counts = tid_counts[tid]
diff = np.asarray(true_counts) - np.asarray(obs_counts)
err_nb += np.count_nonzero(diff)
error += diff*diff
if diff.any():
self._progress('{} \t{} \t{} \t{}'.format(tid, true_counts, obs_counts, diff),
end='\n', verbosity=VERBOSITY.VERBOSE)
error /= len(tid_counts)
rmse = np.sqrt(error).sum() / self.cls_nb
error_fraction = err_nb / (len(tid_counts)* self.cls_nb)
return rmse, error_fraction
评论列表
文章目录