'python How to visualize the decision trees in random forest?
I would like to visualize the Decision trees (10 in this example), but I am a bit confused how to do it.
I have found how to visualize each tree separately. I am looking how can I see for example 10 trees together.
thanks!
here is the code
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_iris
iris = load_iris()
X = iris.data[:,0:1]
y = iris.target
X_train, X_test, y_train, y_test = train_test_split(X, y,)
clf = RandomForestClassifier(bootstrap=True, n_estimators=10, criterion='gini', max_depth=5, max_features='sqrt', random_state=0)
clf.fit(X_train, y_train)
print(clf.score(X_test, y_test))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
