Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are "feature_importances_" ordered in Scikit-learn's RandomForestRegressor

If I run a model (called clf in this case), I get output that looks like this. How can I tie this to the feature inputs that were used to train the classifier?

>>> clf.feature_importances_

array([ 0.01621506,  0.18275428,  0.09963659,... ])
like image 288
Krishan Gupta Avatar asked May 27 '14 22:05

Krishan Gupta


1 Answers

As mentioned in the comments, it looks like the order or feature importances is the order of the "x" input variable (which I've converted from Pandas to a Python native data structure). I use this code to generate a list of types that look like this: (feature_name, feature_importance).

zip(x.columns, clf.feature_importances_)
like image 198
Krishan Gupta Avatar answered Sep 27 '22 22:09

Krishan Gupta