Issue
from sklearn.ensemble import RandomForestClassifier
from sklearn import tree
rf = RandomForestClassifier()
rf.fit(X_train, y_train)
n_nodes = rf.tree_.node_count
Everytime I run this code, I get the following error
'RandomForestClassifier' object has no attribute 'tree_'
any ideas why
Solution
According to scikit-learn documentation, it doesn't have .tree_
attribute.
It only has: estimators_
, classes_
, n_classes_
, n_features_
, n_outputs_
, feature_importances_
, oob_score_
, and oob_decision_function_
attributes.
Answered By - joaoavf
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.