0

I am working on a program to create a decision tree. The following method below should save an image of the tree:

def save_image(clf_, filename, feat_names, class_names, show=True):
    """Plot the tree and save to file."""
    plt.figure(dpi=200)
    tree.plot_tree(
        clf_, filled=True,
        feature_names=feat_names,
        class_names=class_names
    )
    plt.savefig(f'{filename}.png')
    if show:
        plt.show()

Expected:

Output image of full tree

Actual:

enter image description here

The image outputted is not what is expected. How can I trouble-shoot this problem?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Evan Gertis
  • 1,796
  • 2
  • 25
  • 59

0 Answers0