Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xgboost and its sklearn's integration feature_importances_ error

I'm using XGBoost and its sklearn's wrapper.

Whenever I try to print feature_importances_ it comes with the following error:

ValueError: invalid literal for int() with base 10

Digging into the code I found out that the feature_importances_ property is calling get_fscore method (with empty params) from original booster. This method explicitly returns a dictionary shaped like this:

{'feat_name1':5,'feat_name2':8,...,'feat_nameN':1}

So, taking into account that feature_importances_ applies an int conversion to the keys uncovers the error's message rationale.

keys = [int(k.replace('f', '')) for k in fs.keys()] #this is the conflictive line of code

So, my question here is two-folded:

1- is this a bug and therefore I should report it (or even fix it and request a pull)?

2- is there something I'm missing with the get_fscore function and its fmap param?

like image 553
Guiem Bosch Avatar asked Oct 31 '22 06:10

Guiem Bosch


1 Answers

I'd suggest to report it as a bug at the XGBoost Github site: https://github.com/dmlc/xgboost/issues

like image 144
AlexR Avatar answered Nov 15 '22 07:11

AlexR