【问题标题】:How can I export my graphviz tree graph into a jpg that saves in a folder chosen如何将我的 graphviz 树图导出为保存在所选文件夹中的 jpg
【发布时间】:2020-06-14 08:29:44
【问题描述】:

我使用 graphviz 获得了此代码,它最终会生成我的图表,但我希望将生成的图表保存在我的根文件夹中。有办法吗?

from sklearn.tree import export_graphviz
tree_data = export_graphviz(dtc, out_file=None, feature_names=features_names) 
my_tree = graphviz.Source(tree_data, format='jpg') 
#my_tree.render("/Users/EsteArell/Desktop/Python_Machine".format(jpg))
my_tree```

【问题讨论】:

    标签: python scikit-learn graphviz image-graphviz


    【解决方案1】:

    我尝试了推荐的方法,但没有成功。所以我想出了这个解决方案: 这对我有用,虽然有两行但有效。

    from sklearn.tree import export_graphviz
    tree_data = export_graphviz(dtc, out_file=None, feature_names=features_names) 
    my_tree = graphviz.Source(tree_data, directory ='...own directory') 
    my_tree.save(filename='prueba2.jpg', directory='...own directory')
    my_tree.render(filename='prueba2',directory='...own directory',view = True, format='jpg')```
    
    
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-30
      • 1970-01-01
      相关资源
      最近更新 更多