From 3a2b8332a6c921cd3fdd69ecff1529a2a0bababe Mon Sep 17 00:00:00 2001 From: Liam Huang Date: Fri, 17 Mar 2017 01:36:39 +0800 Subject: [PATCH] bugfix: when metric's name contains `-` (#2090) When metric's name contains `-`, Python will complain about insufficient arguments to unpack. --- python-package/xgboost/callback.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python-package/xgboost/callback.py b/python-package/xgboost/callback.py index 149d91dc8..e8720d621 100644 --- a/python-package/xgboost/callback.py +++ b/python-package/xgboost/callback.py @@ -79,7 +79,9 @@ def record_evaluation(eval_result): def init(env): """internal function""" for k, _ in env.evaluation_result_list: - key, metric = k.split('-') + pos = k.index('-') + key = k[:pos] + metric = k[pos + 1:] if key not in eval_result: eval_result[key] = {} if metric not in eval_result[key]: @@ -90,7 +92,9 @@ def record_evaluation(eval_result): if len(eval_result) == 0: init(env) for k, v in env.evaluation_result_list: - key, metric = k.split('-') + pos = k.index('-') + key = k[:pos] + metric = k[pos + 1:] eval_result[key][metric].append(v) return callback