Xgboost feature importance

#1

I was trying the code of xgboost but got error on line
feat_imp = pd.Series(alg.booster().get_fscore()).sort_values(ascending=False)

TypeError: ‘str’ object is not callable

It says alg.booster().get_fscore() is not working fine. I am working on kaggle environment

0 Likes

#2

Hi,
Can you please share the complete code snippet so that the community can better understand and help you debug this?
Regards
Ankit

0 Likes

#3

you can try “alg.get_booster().get_fscore()” instead of “alg.booster().get_fscore()”. it works to me.

3 Likes

#4

Hey, sorry to bump this thread so late. Any explanation regarding why get_booster() works instead would be really appreciated. Also, what would be the reason for the error?Thanks.

0 Likes