def toJson(self, f):
perf = {}
if self.auc:
perf['auc'] = {'mean': str(int(self.auc_mean*10000)/100) + '%',
'std': int(self.auc_std*10000)/10000}
if self.probabilist_model:
perf['thresholds'] = [{} for x in self.thresholds]
for t in self.thresholds:
for v in self.perf_threshold_summary[t].index:
perf['thresholds'][t][v] = {}
perf['thresholds'][t][v]['mean'] = str(int(self.perf_threshold_summary[t].loc[v, 'mean']*10000)/100)
perf['thresholds'][t][v]['mean'] += '%'
perf['thresholds'][t][v]['std'] = int(self.perf_threshold_summary[t].loc[v, 'std']*10000)/10000
else:
for v in self.perf_threshold_summary.index:
perf[v] = {}
perf[v]['mean'] = floats_tools.toPercentage(self.perf_threshold_summary.loc[v, 'mean'])
perf[v]['std'] = floats_tools.trunc(self.perf_threshold_summary.loc[v, 'std'])
json.dump(perf, f, indent = 2)
评论列表
文章目录