From 7d178cbd256bf11e5541c6539160918c3c7c1d5a Mon Sep 17 00:00:00 2001 From: Philip Hyunsu Cho Date: Sat, 22 Feb 2020 03:02:37 -0800 Subject: [PATCH] Fix a small typo in sklearn.py that broke multiple eval metrics (#5341) --- python-package/xgboost/training.py | 2 +- tests/python/test_with_sklearn.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/python-package/xgboost/training.py b/python-package/xgboost/training.py index ca95f46cb..759f30221 100644 --- a/python-package/xgboost/training.py +++ b/python-package/xgboost/training.py @@ -38,7 +38,7 @@ def _train_internal(params, dtrain, _params = dict(params) if isinstance(params, list) else params - if 'num_parallel_tree' in _params and params[ + if 'num_parallel_tree' in _params and _params[ 'num_parallel_tree'] is not None: num_parallel_tree = _params['num_parallel_tree'] nboost //= num_parallel_tree diff --git a/tests/python/test_with_sklearn.py b/tests/python/test_with_sklearn.py index d29de0464..0a58f3af5 100644 --- a/tests/python/test_with_sklearn.py +++ b/tests/python/test_with_sklearn.py @@ -34,7 +34,8 @@ def test_binary_classification(): kf = KFold(n_splits=2, shuffle=True, random_state=rng) for cls in (xgb.XGBClassifier, xgb.XGBRFClassifier): for train_index, test_index in kf.split(X, y): - xgb_model = cls(random_state=42).fit(X[train_index], y[train_index]) + clf = cls(random_state=42) + xgb_model = clf.fit(X[train_index], y[train_index], eval_metric=['auc', 'logloss']) preds = xgb_model.predict(X[test_index]) labels = y[test_index] err = sum(1 for i in range(len(preds))