eli5 icon indicating copy to clipboard operation
eli5 copied to clipboard

KeyError: 'bias' while running show_weights(clf, vec=vec) in xgboost notebook

Open SaiAparna1 opened this issue 4 years ago • 9 comments

Could anyone please help me to solve following error,

File "C:\anaconda3\lib\site-packages\xgboost\sklearn.py", line 745, in intercept_ return np.array(json.loads(b.get_dump(dump_format='json')[0])['bias'])

KeyError: 'bias'

SaiAparna1 avatar Apr 01 '20 08:04 SaiAparna1

KeyError : 'bias' is shown when we run the XGBRegressor, please help us on this error

SusmithBarigidad avatar Apr 01 '20 08:04 SusmithBarigidad

Seeing the same issue on an XGBClassifier().

sugarcrm-aorso avatar Apr 07 '20 16:04 sugarcrm-aorso

I have the same issue as well with XGBClassifier.

danielad-k avatar Apr 14 '20 14:04 danielad-k

image I just tested the XgbRegressor and could not reproduce the issue. Can one of you paste a screenshot of what you is happening? @SusmithBarigidad @sugarcrm-aorso @danielad-k

AshwinB-hat avatar Apr 26 '20 09:04 AshwinB-hat

Hi @AshwinB-hat I also meet this error.

Python Version Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information.

image

supinyu avatar Apr 27 '20 11:04 supinyu

image I just tested the XgbRegressor and could not reproduce the issue. Can one of you paste a screenshot of what you is happening? @SusmithBarigidad @sugarcrm-aorso @danielad-k

It looks like it may be related to the Classifier while you are referencing the Regressor. Let me know if you need anything more beyond what @supinyu shared.

sugarcrm-aorso avatar Apr 27 '20 12:04 sugarcrm-aorso

The bug is not on eli5 but on xgboost. The call hasattre(xgb, 'intercept_') crashes. This bug is present in the 1.0.2 release and has been fixed by commit Fix checking booster. (#5505). It will be integrated in the 1.1.0 version in preparation (1st release candidate already out).

In the mean time you can easily apply the patch yourself (just one line to change in intercept_(self) of site-packages/xgboost/sklearn.py). Replace getattr(self, 'booster', None) is not None and self.booster not in {gbtree', 'dart'}: by self.get_params()['booster'] not in {'gbtree', 'dart'}:.

JulienB-78 avatar Apr 28 '20 07:04 JulienB-78

Thank you very much JulienB-78. I update the xgboost version to 1.1.0rc1. The code will not have this error.

supinyu avatar Apr 28 '20 09:04 supinyu

Yup, using the 1.1.0 release candidate worked for me as well. Thanks @JulienB-78

sugarcrm-aorso avatar May 04 '20 17:05 sugarcrm-aorso