Reputation: 25366
I use the following code to build a random forest model, and then I try to view the importance of each feature as following:
rf = RandomForestClassifier(n_estimators=100)
rf.fit(X, Y)
rf_feature_import = rf.feature_importances_()
but I got the error below:
rf_feature_import = rf.feature_importances_()
TypeError: 'numpy.ndarray' object is not callable
Does anyone have any idea? Thank you!
Upvotes: 0
Views: 1679
Reputation: 13747
If you get rid of the parens it should work:
rf_feature_import = rf.feature_importances_
See here: http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html
Upvotes: 3