Plot trees for a Random Forest in Python with Scikit-Learn
<p>I want to plot a decision tree of a random forest. So, i create the following code:</p>
<pre><code>clf = RandomForestClassifier(n_estimators=100)
import pydotplus
import six
from sklearn import tree
dotfile = six.StringIO()
i_tree = 0
for tree_in_forest in clf.estimators_:
if (i_tree &lt;1):        
    tree.export_graphviz(tree_in_forest, out_file=dotfile)
    pydotplus.graph_from_dot_data(dotfile.getvalue()).write_png('dtree'+ str(i_tree) +'.png')
    i_tree = i_tree + 1
</code></pre>
<p>But it doesn't generate anything..
Have you an idea how to plot a decision tree from random forest?</p>