Feature Importance from a GridSearchCV
-
08-12-2020 - |
Pergunta
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 trainingdata are huge, 669 Attributes therefore i need the attributenames so I found this code
rf_gridsearch.best_estimator_.named_steps["step_name"].feature_importances_
But I dont know that the "named_steps["step_name"]" are.
I tried something like this
named_steps = X_train.columns
But this doesnt work. Could somebody explain me what "named_steps["step_name"]" is? Thank you and sorry for my noob questions
Solução
I think that you need just
feature_importances = rf_gridsearch.best_estimator_.feature_importances_
This provides the feature importances for all the attribures in your dataset. For more information on this as well as other options, you may also refer to Scikit-learn official documentation.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a datascience.stackexchange