Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get feature importance from GridSearchCV

Is there a way to get feature importance from a sklearn's GridSearchCV?

For example :

from sklearn.model_selection import GridSearchCV
print("starting grid search ......")
optimized_GBM = GridSearchCV(LGBMRegressor(),
                             params,
                             cv=3,
                             n_jobs=-1)
# 
optimized_GBM.fit(tr, yvar)
preds2 = optimized_GBM.predict(te)

Is there a way I can access feature importance ?

Maybe something like

optimized_GBM.feature_importances_
like image 262
Nick M Avatar asked Jan 22 '18 08:01

Nick M


1 Answers

This one works

optimized_GBM.best_estimator_.feature_importances_
like image 72
Aptha Gowda Avatar answered Oct 10 '22 03:10

Aptha Gowda