From 5c9f0ff9d92c64be3082272e50a8447a14e6d31b Mon Sep 17 00:00:00 2001 From: Andrew Hannigan Date: Wed, 27 Sep 2017 03:05:59 -0400 Subject: [PATCH] Check existance of seed/nthread keys before checking their value. (#2669) --- CONTRIBUTORS.md | 1 + python-package/xgboost/sklearn.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e4af03c62..7f86d2a16 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -71,3 +71,4 @@ List of Contributors - Rory is the author of the GPU plugin and also contributed the cmake build system and windows continuous integration * [Gideon Whitehead](https://github.com/gaw89) * [Yi-Lin Juang](https://github.com/frankyjuang) +* [Andrew Hannigan](https://github.com/andrewhannigan) diff --git a/python-package/xgboost/sklearn.py b/python-package/xgboost/sklearn.py index 7216f68f8..57514cc28 100644 --- a/python-package/xgboost/sklearn.py +++ b/python-package/xgboost/sklearn.py @@ -195,14 +195,14 @@ class XGBModel(XGBModelBase): """Get xgboost type parameters.""" xgb_params = self.get_params() random_state = xgb_params.pop('random_state') - if xgb_params['seed'] is not None: + if 'seed' in xgb_params and xgb_params['seed'] is not None: warnings.warn('The seed parameter is deprecated as of version .6.' 'Please use random_state instead.' 'seed is deprecated.', DeprecationWarning) else: xgb_params['seed'] = random_state n_jobs = xgb_params.pop('n_jobs') - if xgb_params['nthread'] is not None: + if 'nthread' in xgb_params and xgb_params['nthread'] is not None: warnings.warn('The nthread parameter is deprecated as of version .6.' 'Please use n_jobs instead.' 'nthread is deprecated.', DeprecationWarning)