根据您的编辑,听起来您只询问如何提取特征重要性并查看随机森林中使用的各个树 . 如果是这样,这两个都是您的随机森林模型的属性,分别名为“feature_importances_”和“estimators_” . 可以在下面找到说明这一点的示例:
>>> from sklearn.ensemble import RandomForestClassifier
>>> from sklearn.datasets import make_blobs
>>> X, y = make_blobs(n_samples=10000, n_features=10, centers=100,random_state=0)
>>> clf = RandomForestClassifier(n_estimators=5, max_depth=None, min_samples_split=1, random_state=0)
>>> clf.fit(X,y)
RandomForestClassifier(bootstrap=True, compute_importances=None,
criterion='gini', max_depth=None, max_features='auto',
min_density=None, min_samples_leaf=1, min_samples_split=1,
n_estimators=5, n_jobs=1, oob_score=False, random_state=0,
verbose=0)
>>>