graphviz plot too wide

2019-06-14 15:26发布

问题:

I'm doing a practice exercise of creating a decision tree using graphviz in jupyter notebook. however, the decision tree is coming too wide. here is the code:

from sklearn.tree import export_graphviz
export_graphviz(tree, out_file="tree.dot", class_names=["malignant", "benign"], 
                feature_names=cancer.feature_names, impurity=False, filled=True)
with open("tree.dot") as f:
    dot_graph = f.read()
display(graphviz.Source(dot_graph))

and I get this:

I have to scroll to see the left side of the decision tree. can I make the width smaller? how?