gpt4 book ai didi

python - 'RandomForestClassifier' 对象没有属性 'tree_'

转载 作者:行者123 更新时间:2023-12-03 23:17:06 27 4
gpt4 key购买 nike

from sklearn.ensemble import RandomForestClassifier
from sklearn import tree

rf = RandomForestClassifier()

rf.fit(X_train, y_train)
n_nodes = rf.tree_.node_count

每次运行此代码时,都会出现以下错误

'RandomForestClassifier' object has no attribute 'tree_'



任何想法为什么

最佳答案

根据 scikit-learn documentation ,它没有 .tree_属性。

它只有:estimators_ , classes_ , n_classes_ , n_features_ , n_outputs_ , feature_importances_ , oob_score_ , 和 oob_decision_function_属性。

关于python - 'RandomForestClassifier' 对象没有属性 'tree_',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48870380/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com