How to use the graphviz.Source.from_file function in graphviz

To help you get started, we’ve selected a few graphviz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DrGabrielA81 / medium / Scikit-learn-optimal-pipeline / dc4dd94d2c09.py View on Github external
# get encoded features names
onehot_attrs = classifier_gs.best_estimator_.named_steps[
    'preprocessor'].named_transformers_['cat'].named_steps[
    'onehot'].get_feature_names(input_features=cat_attrs).tolist()

# plot tree using graphviz
export_graphviz(decision_tree=classifier_gs.best_estimator_.named_steps['classifier'],
                out_file='tree.dot',
                feature_names=num_attrs + onehot_attrs,
                class_names=['non-churned', 'churned'],
                rounded=True,
                filled=True)

# convert image from dot to png
gv.Source.from_file('tree.dot', format="png")
github ucbrise / jarvis / object_model / artifact.py View on Github external
def plot(self, rankdir=None):
        # Prep globals, passed through arguments

        self.xp_state.nodes = {}
        self.xp_state.edges = []

        dot = Digraph()
        # diagram = {"dot": dot, "counter": 0, "sha": {}}

        if not util.isOrphan(self):
            # self.parent.__plotWalk__(diagram)
            vg = viz.VizGraph()
            self.parent.__plotWalk__(vg)
            # vg.bft()
            vg.to_graphViz()
            Source.from_file('output.gv').view()
        else:
            node_diagram_id = '0'
            dot.node(node_diagram_id, self.loc, shape="box")
            self.xp_state.nodes[self.loc] = node_diagram_id
            dot.format = 'png'
            if rankdir == 'LR':
                dot.attr(rankdir='LR')
            dot.render('driver.gv', view=True)
github kubeflow-kale / kale / backend / kale / converter.py View on Github external
def plot_pipeline(self):
        nx.drawing.nx_pydot.write_dot(self.pipeline, 'test.dot')
        s = Source.from_file('test.dot')
        s.view()
github kubeflow-kale / kale / kale / nbparser / parser.py View on Github external
"""
    Dump the graph to a dot file and visualize it using Graphviz

    Args:
        graph: NetworkX graph instance
        dot_path: Path to .dot file location

    """
    rm_path = False
    if dot_path is None:
        # crete temp dir to store the .dot file
        dot_path = tempfile.mkstemp()
        rm_path = True

    nx.drawing.nx_pydot.write_dot(graph, dot_path)
    s = Source.from_file(dot_path)
    s.view()

    if rm_path:
        os.remove(dot_path)