How to get the important features from a random forest model?
You can find out the feature importance of various features using the following line of code:
How to get the important features from a random forest model?
You can find out the feature importance of various features using the following line of code:
0 comments
Article is closed for comments.
model1.feature_importances_
where the model1 is the RandomForest model which you have fitted with the train set.
But that information won't be that interpretable, so use this code:
for score, name in sorted(zip(model1.feature_importances_, X_train.columns), reverse=True):
print('Feature importance of', name, ':', score*100, '%')
This will print the feature importances in sorted order with the highest feature importance at the top and lowest at the bottom.