diff --git a/python-package/xgboost/callback.py b/python-package/xgboost/callback.py index 0c4079458..149d91dc8 100644 --- a/python-package/xgboost/callback.py +++ b/python-package/xgboost/callback.py @@ -32,6 +32,9 @@ def _fmt_metric(value, show_stdv=True): def print_evaluation(period=1, show_stdv=True): """Create a callback that print evaluation result. + We print the evaluation results every ``period`` iterations + and on the first and the last iterations. + Parameters ---------- period : int @@ -50,7 +53,7 @@ def print_evaluation(period=1, show_stdv=True): if env.rank != 0 or len(env.evaluation_result_list) == 0 or period is False: return i = env.iteration - if (i % period == 0 or i + 1 == env.begin_iteration): + if (i % period == 0 or i + 1 == env.begin_iteration or i + 1 == env.end_iteration): msg = '\t'.join([_fmt_metric(x, show_stdv) for x in env.evaluation_result_list]) rabit.tracker_print('[%d]\t%s\n' % (i, msg)) return callback