| 201 | |
| 202 | |
| 203 | class StatisticsContainer(object): |
| 204 | def __init__(self, statistics_path): |
| 205 | self.statistics_path = statistics_path |
| 206 | |
| 207 | self.backup_statistics_path = "{}_{}.pkl".format( |
| 208 | os.path.splitext(self.statistics_path)[0], |
| 209 | datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S"), |
| 210 | ) |
| 211 | |
| 212 | self.statistics_dict = {"balanced_train": [], "test": []} |
| 213 | |
| 214 | def append(self, steps, statistics, split, flush=True): |
| 215 | statistics["steps"] = steps |
| 216 | self.statistics_dict[split].append(statistics) |
| 217 | |
| 218 | if flush: |
| 219 | self.flush() |
| 220 | |
| 221 | def flush(self): |
| 222 | pickle.dump(self.statistics_dict, open(self.statistics_path, "wb")) |
| 223 | pickle.dump(self.statistics_dict, open(self.backup_statistics_path, "wb")) |
| 224 | logging.info(" Dump statistics to {}".format(self.statistics_path)) |
| 225 | logging.info(" Dump statistics to {}".format(self.backup_statistics_path)) |
| 226 | |
| 227 | |
| 228 | def get_mean_sdr_from_dict(sdris_dict): |
nothing calls this directly
no outgoing calls
no test coverage detected