def after_valid(self, logs=None): """Call after_valid of the managed callbacks.""" self.model = self.trainer.model feature_interaction_score = self.model.get_feature_interaction_score() print('get feature_interaction_score', feature_interaction_score) feature_interaction = [] for feature in feature_interaction_score: if abs(feature_interaction_score[feature]) > 0: feature_interaction.append(feature) print('get feature_interaction', feature_interaction) curr_auc = float(self.trainer.valid_metrics.results['auc']) if curr_auc > self.best_score: best_config = { 'score': curr_auc, 'feature_interaction': feature_interaction } logging.info("BEST CONFIG IS\n{}".format(best_config)) pickle_result_file = FileOps.join_path( self.trainer.local_output_path, 'best_config.pickle') logging.info("Saved to {}".format(pickle_result_file)) FileOps.dump_pickle(best_config, pickle_result_file) self.best_score = curr_auc
def _save_performance(self, results): """Save performance into performance.pkl and save checkpoint to output_dir. :param results: performance results :type sr: dict """ logging.info("performance=%s", str(results)) performance_dir = os.path.join(self.worker_path, 'performance') FileOps.make_dir(performance_dir) FileOps.dump_pickle(results, os.path.join(performance_dir, 'performance.pkl')) logging.info("performance save to %s", performance_dir) # copy pth to output dir output_dir = os.path.join(self.output_path, str(self._worker_id)) FileOps.make_dir(output_dir) shutil.copy(os.path.join(self.worker_path, 'latest.pth'), os.path.join(output_dir, results['arch'].split('_')[1] + '.pth')) logging.info("Latest checkpoint save to %s", output_dir)