Ejemplo n.º 1
0
 def to_json(self, f):
     perf = {}
     if self.auc:
         perf['auc'] = {
             'mean': to_percentage(self.auc_mean),
             'std': trunc(self.auc_std)
         }
     if self.probabilist:
         perf['thresholds'] = [{} for x in self.thresholds]
         for t in self.thresholds:
             summary = self.perf_threshold_summary[t]
             for v in summary.index:
                 perf['thresholds'][t][v] = {}
                 perf['thresholds'][t][v]['mean'] = to_percentage(
                     summary.loc[v, 'mean'])
                 perf['thresholds'][t][v]['std'] = trunc(summary.loc[v,
                                                                     'std'])
     else:
         for v in self.perf_threshold_summary.index:
             perf[v] = {}
             perf[v]['mean'] = to_percentage(
                 self.perf_threshold_summary.loc[v, 'mean'])
             perf[v]['std'] = trunc(self.perf_threshold_summary.loc[v,
                                                                    'std'])
     json.dump(perf, f, indent=2)
Ejemplo n.º 2
0
 def to_json(self, f):
     perf = {}
     perf['accuracy'] = {
         'mean': to_percentage(self.accuracy_mean),
         'std': trunc(self.accuracy_std)
     }
     perf['f1_micro'] = {
         'mean': to_percentage(self.f1_micro_mean),
         'std': trunc(self.f1_micro_std)
     }
     perf['f1_macro'] = {
         'mean': to_percentage(self.f1_macro_mean),
         'std': trunc(self.f1_macro_std)
     }
     json.dump(perf, f, indent=2)