I used lightgbm for feature importance. However, the output is a plot scores by some metric. My questions are:
- What are is the metric in the x-axis? Is that an F-score or something else?
- How can I get an output of the features where it shows me how much each feature makes up for the variance the model (similar to PCA)?
- How do I extract the Metric for all the feature of importance in a dataframe format?
This is my code:
import lightgbm as lgb
import matplotlib.pyplot as plt
lgb_params = {
'boosting_type': 'gbdt',
'objective': 'binary',
'num_leaves': 30,
'num_round': 360,
'max_depth':8,
'learning_rate': 0.01,
'feature_fraction': 0.5,
'bagging_fraction': 0.8,
'bagging_freq': 12
}
lgb_train = lgb.Dataset(X, y)
model = lgb.train(lgb_params, lgb_train)
plt.figure(figsize=(12,6))
lgb.plot_importance(model, max_num_features=30)
plt.title("Feature importances")
plt.show()
