def compute_stats(self, confm_list, train_loss): TP_list, TN_list, FP_list, FN_list = extract_stats_from_confm( confm_list) mean_accuracy = compute_accuracy(TP_list, TN_list, FP_list, FN_list) mean_precision = compute_precision(TP_list, FP_list) mean_recall = compute_recall(TP_list, FN_list) mean_f1score = compute_f1score(TP_list, FP_list, FN_list) self.stats.train.acc = np.nanmean(mean_accuracy) self.stats.train.recall = np.nanmean(mean_recall) self.stats.train.precision = np.nanmean(mean_precision) self.stats.train.f1score = np.nanmean(mean_f1score) if train_loss is not None: self.stats.train.loss = train_loss.avg
def compute_stats(self, confm_list, val_loss): TP_list, TN_list, FP_list, FN_list = extract_stats_from_confm( confm_list) mean_accuracy = compute_accuracy(TP_list, TN_list, FP_list, FN_list) mean_precision = compute_precision(TP_list, FP_list) mean_recall = compute_recall(TP_list, FN_list) mean_f1score = compute_f1score(TP_list, FP_list, FN_list) #self.stats.val.acc = np.nanmean(mean_accuracy) self.stats.val.acc = np.sum(TP_list) / (np.sum(FP_list) + np.sum(TP_list)) self.stats.val.recall = np.nanmean(mean_recall) self.stats.val.precision = np.nanmean(mean_precision) self.stats.val.f1score = np.nanmean(mean_f1score) if val_loss is not None: self.stats.val.loss = val_loss.avg