Advitya17 commented on a change in pull request #518: URL: https://github.com/apache/madlib/pull/518#discussion_r495189361
########## File path: src/ports/postgres/modules/deep_learning/madlib_keras_automl.py_in ########## @@ -291,9 +338,100 @@ class KerasAutoML(): (self.metrics_compute_frequency >= 1 and \ self.metrics_compute_frequency <= num_iterations) + def print_best_so_far(self): + """ + Prints mst keys with best train/val losses at a given point. + """ + best_so_far = '\n' + best_so_far += self.print_best_helper('training') + if self.validation_table: + best_so_far += self.print_best_helper('validation') + plpy.info(best_so_far) + + def print_best_helper(self, keyword): + """ + Helper function to Prints mst keys with best train/val losses at a given point. + :param keyword: column prefix ('training' or 'validation') + :return: + """ + metrics_word, loss_word = keyword + '_metrics_final', keyword + '_loss_final' + + res_str = 'Best {keyword} loss so far:\n'.format(keyword=keyword) + best_value = plpy.execute("SELECT {ModelSelectionSchema.MST_KEY}, {metrics_word}, " \ + "{loss_word} FROM {self.model_info_table} ORDER BY " \ + "{loss_word} LIMIT 1".format(self=self, ModelSelectionSchema=ModelSelectionSchema, + metrics_word=metrics_word, loss_word=loss_word))[0] + mst_key_value, metric_value, loss_value = best_value[ModelSelectionSchema.MST_KEY], \ + best_value[metrics_word], best_value[loss_word] + res_str += ModelSelectionSchema.MST_KEY + '=' + str(mst_key_value) + ': metric=' + str(metric_value) + \ + ', loss=' + str(loss_value) + '\n' + return res_str + + def get_current_timestamp(self): + """for start and end times for the chosen AutoML algorithm. Showcased in the output summary table""" + return datetime.fromtimestamp(time()).strftime('%Y-%m-%d %H:%M:%S') + + def remove_temp_tables(self, model_training): Review comment: I reverted back to my function as I was unfortunately facing pipeline issues with the utility function. I've still commented out the related lines in case anyone wants to experiment with it. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org