Beispiel #1
0
    def test_new_logged_exp_to_csv(self):
        """
        Test writing the full experiment df (including old one)
        :return:
        :rtype:
        """
        experiment = Configuration(csv_file='results.csv')
        experiment.to_csv('results.csv')

        old_df = pd.read_csv('results_old.csv')
        meta_df, config_df, results_df = self.df_to_exp_attribs(old_df)
        exp_meta = meta_df.iloc[-1].to_dict()
        exp_config = config_df.iloc[-1].to_dict()
        exp_results = results_df.iloc[-1].to_dict()

        experiment = Configuration(csv_file='results_old.csv')
        experiment.log(meta_data=exp_meta,
                       params=exp_config,
                       performance=exp_results,
                       yaml_file=None)
        self.assertFalse(experiment.df.empty)
        #config_df = old_df.iloc[-1]#pd.concat([meta_df.iloc[-1], config_df.iloc[-1], exp_results], axis=1)
        exp_df = pd.concat([
            pd.DataFrame([exp_meta]),
            pd.DataFrame([exp_config]),
            pd.DataFrame([exp_results])
        ],
                           axis=1)
        df = pd.concat([old_df, exp_df], axis=0, ignore_index=True, sort=False)
        self.assertTrue(df.equals(experiment.df))

        experiment.to_csv('results.csv')
        df = pd.read_csv('results.csv')
        self.assertTrue(df.equals(experiment.df))
Beispiel #2
0
 def test_to_csv(self):
     """
     Test writing the full experiment df (including old one)
     :return:
     :rtype:
     """
     experiment = Configuration(csv_file='results.csv')
     experiment.to_csv('results.csv')
     df = pd.read_csv('results.csv')
     self.assertTrue(df.equals(experiment.df))