From df64156dbfdd3cb44a9cccd9ca6f450a547bb6aa Mon Sep 17 00:00:00 2001 From: Melissa Kohl Date: Tue, 31 Mar 2020 12:30:19 -0700 Subject: [PATCH 1/2] Fix uninitialized value bug in xgboost callback --- python-package/xgboost/callback.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python-package/xgboost/callback.py b/python-package/xgboost/callback.py index b4264cd8212a..ef1234c36919 100644 --- a/python-package/xgboost/callback.py +++ b/python-package/xgboost/callback.py @@ -209,6 +209,10 @@ def init(env): state['best_score'] = float('-inf') else: state['best_score'] = float('inf') + msg = '[%d]\t%s' % ( + env.iteration, + '\t'.join([_fmt_metric(x) for x in env.evaluation_result_list])) + state['best_msg'] = msg if bst is not None: if bst.attr('best_score') is not None: From 79b956baf947010500a0a924485ff459fa557ec1 Mon Sep 17 00:00:00 2001 From: Philip Hyunsu Cho Date: Tue, 14 Apr 2020 18:37:30 -0700 Subject: [PATCH 2/2] Fix linter error --- python-package/xgboost/callback.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python-package/xgboost/callback.py b/python-package/xgboost/callback.py index ef1234c36919..14b4aef60efb 100644 --- a/python-package/xgboost/callback.py +++ b/python-package/xgboost/callback.py @@ -210,8 +210,8 @@ def init(env): else: state['best_score'] = float('inf') msg = '[%d]\t%s' % ( - env.iteration, - '\t'.join([_fmt_metric(x) for x in env.evaluation_result_list])) + env.iteration, + '\t'.join([_fmt_metric(x) for x in env.evaluation_result_list])) state['best_msg'] = msg if bst is not None: