def _log_eval_average(self, result_dct_list, configs): bresult = BenchmarkResult(result_dct_list, configs) df = bresult.get_data_frame() grouped = df.apply(pd.to_numeric, errors='ignore').groupby(bresult.get_evaluation_groups()).mean()[ self._evaluation_criteria()] self.logger.info("\n------------------- Current Evaluation Results ---------------------- \n Num. Results:{}\n {} \n \ ---------------------------------------------------------------------".format(len(result_dct_list), grouped.to_string()))
def test_extend_from_file(self): try: os.remove("./br1") os.remove("./br2") os.remove("./br3") except: pass result_num = 100 confs, result_data, histories1 = random_benchmark_conf_data(result_num, 2000000, hist_size=1500000, offset=0) br1 = BenchmarkResult(result_dict=result_data, benchmark_configs=confs, histories=histories1) br1.dump("./br1", dump_histories=True, dump_configs=True) br1_df = br1.get_data_frame().copy() result_num = 30 confs2, result_data2, histories2 = random_benchmark_conf_data(result_num, 2000000, hist_size=1500000, offset=200) br2 = BenchmarkResult(result_dict=result_data2, benchmark_configs=confs2, histories=histories2) br2.dump(filename="./br2", dump_histories=True, dump_configs=True) result_num = 10 confs3, result_data3, histories3 = random_benchmark_conf_data(result_num, 2000000, hist_size=1500000, offset=400) br3 = BenchmarkResult(result_dict=result_data3, benchmark_configs=confs3, histories=histories3) br3.dump(filename="./br3", dump_histories=True, dump_configs=True) br1.extend(benchmark_result=br2, file_level=True) br1.extend(benchmark_result=br3, file_level=True) br_loaded = BenchmarkResult.load("./br1", load_histories=True, load_configs=True) df_desired = br1_df df_desired = pd.concat([df_desired, br2.get_data_frame()]) df_desired = pd.concat([df_desired, br3.get_data_frame()]) self.assertEqual(len(br_loaded.get_data_frame().index), len(df_desired.index)) extended_confs = br_loaded.get_benchmark_configs() self.assertEqual(len(extended_confs), 140) extended_histories = br_loaded.get_histories() self.assertEqual(len(extended_histories), 140) extended_histories = histories1 extended_histories.update(histories2) extended_histories.update(histories3) for bc in extended_confs: self.assertEqual(br_loaded.get_history(bc.config_idx), extended_histories[bc.config_idx])
def _log_eval_average(self, result_dct_list, configs): bresult = BenchmarkResult(result_dct_list, configs) df = bresult.get_data_frame() for eval_group in bresult.get_evaluation_groups(): if eval_group not in df.columns: df[eval_group] = np.nan df.fillna(-1, inplace=True) grouped = df.apply(pd.to_numeric, errors='ignore').groupby(bresult.get_evaluation_groups()).mean() self.logger.info("\n------------------- Current Evaluation Results ---------------------- \n Num. Results:{}\n {} \n \ ---------------------------------------------------------------------".format(len(result_dct_list), grouped.to_string()))