python:如何正确调用 RandomForestClassifier 的 feature_importances_()

python: how to properly call the feature_importances_() for the RandomForestClassifier

我用下面的代码建立了一个随机森林模型,然后我尝试查看每个特征的重要性如下:

rf = RandomForestClassifier(n_estimators=100)
rf.fit(X, Y)
rf_feature_import = rf.feature_importances_()

但我收到以下错误:

    rf_feature_import = rf.feature_importances_()
TypeError: 'numpy.ndarray' object is not callable

有人知道吗?谢谢!

如果去掉括号,它应该可以工作:

rf_feature_import = rf.feature_importances_

看这里:http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html