Feature Importance from GridSearchCV I created a GridSearchCV for a Random Forest Regressor. Now I want to check the feature importance. I searched around and I found this:
rf_gridsearch.best_estimator_.named_steps.feature_importances_

This already works, but my training data is huge, 669 attributes. Therefore, I need the attribute names. So I found this code:
rf_gridsearch.best_estimator_.named_steps[&quot;step_name&quot;].feature_importances_

But I don't know what the &quot;named_steps[&quot;step_name&quot;]&quot; are.
I tried something like this:
named_steps = X_train.columns

But this doesn't work. Could somebody explain me what named_steps[&quot;step_name&quot;] is?
I think that you just need:
feature_importances = rf_gridsearch.best_estimator_.feature_importances_

This provides the feature importance for all the attributes in your dataset. For more information on this as well as other options, you may also refer to the Scikit-learn official documentation.