+-
python – 从OneVsRestClassifier获取随机森林feature_importances_以进行多标签分类
我正在使用OneVsRestClassifier来解决多标签分类问题.我正在将RandomForestClassifier传递给它.

from sklearn.multiclass import OneVsRestClassifier
from sklearn.ensemble import RandomForestClassifier
clf = OneVsRestClassifier(RandomForestClassifier(random_state=0,class_weight='auto',min_samples_split=10,n_estimators=50))
clf.fit(train,dv_train)
print clf.feature_importances_
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'OneVsRestClassifier' object has no attribute 'feature_importances_'

如何在OneVsRestClassifier中获得每个随机森林的特征重要性?

最佳答案
OneVsRestClassifier具有属性estimators_:n_classes估计器列表

因此,要获得第i个RandomForest的特征重要性

print clf.estimators_[i].feature_importances_
点击查看更多相关文章

转载注明原文:python – 从OneVsRestClassifier获取随机森林feature_importances_以进行多标签分类 - 乐贴网