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?
I'd suggest to report it as a bug at the XGBoost Github site: https://github.com/dmlc/xgboost/issues
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With