Benzle
Benzle

Reputation: 373

Order of importance for each level of a feature in Random Forest

After fitting a model using SciKitLearn's Random Forest Classifier I get the feature importance list, but can I get the importance of level of a feature.

For example, if I get the series below for feature importance, how can I see which day_of_week is most important?

online_users            0.107735
number_of_post          0.051478
day_of_week             0.042552
total_votes             0.131286
polarity                0.033352

Upvotes: 1

Views: 180

Answers (1)

Amardeep Flora
Amardeep Flora

Reputation: 1380

I think you can create a dummy variable for the day_of_week and then run the feature importance on the new feature set after merging the dummies and dropping day_of_week.

pd.get_dummies(df['day_of_week'])

Upvotes: 4

Related Questions