Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

xgboost feature importance

import matplotlib.pyplot as plt
from xgboost import plot_importance, XGBClassifier # or XGBRegressor

model = XGBClassifier() # or XGBRegressor

# X and y are input and target arrays of numeric variables
model.fit(X,y)
plot_importance(model, importance_type = 'gain') # other options available
plt.show()
# if you need a dictionary 
model.get_booster().get_score(importance_type = 'gain')
 
PREVIOUS NEXT
Tagged: #xgboost #feature #importance
ADD COMMENT
Topic
Name
7+9 =