![](/img/trans.png)
[英]Scikit-learn MemoryError with RandomForestClassifier
[英]scikit-learn RandomForestClassifier list all variables of an estimator tree?
我訓練一個RandomForestClassifier
作為
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification
X, y = make_classification()
clf = RandomForestClassifier()
clf.fit(X,y)
其中X
和y
是一些特征向量和標簽。
完成擬合后,我可以列出森林中每個估計器生長的所有樹木的深度,如下所示:
[estimator.tree_.max_depth for estimator in clf.estimators_]
現在我想找出所有其他公共變量(除了max_depth
)一個estimator
stores 中的tree_
。 所以我嘗試了:
vars(clf.estimators_[0].tree_)
但不幸的是,這不起作用並返回錯誤
TypeError: vars() argument must have __dict__ attribute
我可以使用什么語法來成功列出estimator.tree_
中的所有公共變量?
無法自動獲取此屬性,但Tree
class 的文檔為您提供了所有屬性:
了解更多: https://scikit-learn.org/stable/auto_examples/tree/plot_unveil_tree_structure.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.