I am wondering if you we can get the feature importance as a list of columns instead of a plot. This is what I have

xg_reg = xgb.train(params=params, dtrain=data_dmatrix, num_boost_round=10)
import matplotlib.pyplot as plt

xgb.plot_importance(xg_reg)
plt.rcParams['figure.figsize'] = [5,5]
plt.show()

Which gives me this plot

enter image description here

I would like to instead just get a list of the top features since I have over 800 different features.

1
Snorrlaxxx 23 Juli 2020, 20:57

1 menjawab

Jawaban Terbaik

You can use xgb.get_score(). Here are a number of examples: How to get feature importance in xgboost?

1
jared_mamrot 24 Juli 2020, 10:55