2

I am using sklearn.ensemble.RandomForestClassifier to do classification. I have 14 classes (14 labels) in total. Now my code is like

clf = RandomForestClassifier(n_estimators = 50)
clf.fit(train_data, labels)
importances = clf.feature_importances_
indices = np.argsort(importances)[-20:]

by doing this I can get the indices for top 20 important features. However, since I have 14 classes (0,1,2,3,4,5,6,7,8,9,10,11,12,13) and now I want to know for each class, what its most important features are, then what should I do?

gladys0313
  • 2,569
  • 6
  • 27
  • 51
  • Possible duplicate of [Using scikit to determine contributions of each feature to a specific class prediction](https://stackoverflow.com/questions/35249760/using-scikit-to-determine-contributions-of-each-feature-to-a-specific-class-pred) – Edeki Okoh Jun 24 '19 at 18:45

0 Answers0