diff --git a/python-package/xgboost/callback.py b/python-package/xgboost/callback.py index 6fa940ab9f0a..3c66ccfb8d58 100644 --- a/python-package/xgboost/callback.py +++ b/python-package/xgboost/callback.py @@ -212,7 +212,7 @@ def init(env): rabit.tracker_print(msg.format(metric_label, stopping_rounds)) state['maximize_score'] = maximize_score - + state['best_iteration'] = 0 if maximize_score: state['best_score'] = float('-inf') else: @@ -228,11 +228,9 @@ def init(env): state['best_iteration'] = int(bst.attr('best_iteration')) state['best_msg'] = bst.attr('best_msg') else: - state['best_iteration'] = 0 bst.set_attr(best_iteration=str(state['best_iteration'])) bst.set_attr(best_score=str(state['best_score'])) else: - state['best_iteration'] = 0 assert env.cvfolds is not None def callback(env):