From 94a9e3222ee40b3c06e194ef7e2cf130e096d1ae Mon Sep 17 00:00:00 2001 From: ziguang1216 Date: Wed, 19 Oct 2016 01:22:51 +0800 Subject: [PATCH] [python-package] Fix the issue #1439 (#1666) *Fix 1439 *Fix python_wrapper when eval set name contain '-' will cause early_stop maximize variable con't set to True propely Change-Id: Ib0595afd4ae7b445a84c00a3a8faeccc506c6d13 --- 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 4176f4c8d..9eeddeb75 100644 --- a/python-package/xgboost/callback.py +++ b/python-package/xgboost/callback.py @@ -163,11 +163,11 @@ def early_stop(stopping_rounds, maximize=False, verbose=True): maximize_score = maximize metric = env.evaluation_result_list[-1][0] - if any(env.evaluation_result_list[-1][0].split('-')[1].startswith(x) + if any(env.evaluation_result_list[-1][0].split('-')[-1].startswith(x) for x in maximize_at_n_metrics): maximize_score = True - if any(env.evaluation_result_list[-1][0].split('-')[1].split(":")[0] == x + if any(env.evaluation_result_list[-1][0].split('-')[-1].split(":")[0] == x for x in maximize_metrics): maximize_score = True