1

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.

Snorrlaxxx
  • 168
  • 1
  • 3
  • 18

1 Answers1

1

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

jared_mamrot
  • 22,354
  • 4
  • 21
  • 46