當前位置: 首頁>>代碼示例>>Python>>正文


Python graphviz.Source方法代碼示例

本文整理匯總了Python中graphviz.Source方法的典型用法代碼示例。如果您正苦於以下問題:Python graphviz.Source方法的具體用法?Python graphviz.Source怎麽用?Python graphviz.Source使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在graphviz的用法示例。


在下文中一共展示了graphviz.Source方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: visualize_tree

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def visualize_tree(data,clf,clf_name):
	features = data.columns
	features = features[:-1]
	class_names = list(set(data.iloc[:,-1]))
	dot_data = tree.export_graphviz(clf, out_file=None,  \
		feature_names=features,class_names=class_names,  \
		filled=True, rounded=True, special_characters=True)
	graph = graphviz.Source(dot_data)
	graph.render('dtree_render_'+clf_name,view=True)

# Function to perform training with giniIndex. 
開發者ID:Ajinkya-Sonawane,項目名稱:Python,代碼行數:13,代碼來源:23_DecisionTree.py

示例2: dump_graph

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def dump_graph(dot_string,
               show_svg=True,
               dot_file_path='',
               output_dot_string=False):
    """Output dot_string in various formats."""
    if dot_file_path:
        try:
            dot_file = open(dot_file_path, "w+")
            dot_file.write(dot_string)
            dot_file.close()
        except IOError:
            print('Cannot open file: ' + dot_file_path)
    if show_svg:
        from IPython.display import display
        from IPython.display import SVG
        src = Source(dot_string)
        display(SVG(src.pipe(format='svg')))
    if output_dot_string:
        return dot_string
    return None 
開發者ID:apache,項目名稱:incubator-tvm,代碼行數:22,代碼來源:tedd.py

示例3: graphviz

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def graphviz(expr):
    '''Plot sympy expression tree using graphviz
    Args:
        expr (sympy expression)
    '''

    return Source(dotprint(expr)) 
開發者ID:timkpaine,項目名稱:tributary,代碼行數:9,代碼來源:__init__.py

示例4: plot_tree

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def plot_tree(dot_data):
    return graphviz.Source(dot_data) 
開發者ID:hpclab,項目名稱:rankeval,代碼行數:4,代碼來源:topological.py

示例5: visualize

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def visualize(self, graph_attrs=None, node_attrs=None, **kw):
        from graphviz import Source

        g = self.build_graph(**kw)
        dot = g.to_dot(graph_attrs=graph_attrs, node_attrs=node_attrs,
                       result_chunk_keys={c.key for c in self.chunks})

        return Source(dot) 
開發者ID:mars-project,項目名稱:mars,代碼行數:10,代碼來源:tiles.py

示例6: get_svg

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def get_svg(self, dot_str):
        import graphviz as gv

        return gv.Source(dot_str, format='svg', engine=self.engine).pipe().decode('utf-8') 
開發者ID:JasonKessler,項目名稱:scattertext,代碼行數:6,代碼來源:ComponentDiGraphHTMLRenderer.py

示例7: visualize_tree

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def visualize_tree(data,clf,clf_name):
	features = data.columns
	features = features[:-1]
	class_names = list(set(data.iloc[:,-1]))
	dot_data = tree.export_graphviz(clf, out_file=None,  feature_names=features,class_names=class_names,  filled=True, rounded=True, special_characters=True)
	graph = graphviz.Source(dot_data)
	graph.render('dtree_render_'+clf_name,view=True)

# Function to perform training with giniIndex. 
開發者ID:Ajinkya-Sonawane,項目名稱:Python,代碼行數:11,代碼來源:dtree.py

示例8: load

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def load(self):
        """Load TensorFlow model into MIL program."""

        logging.info("Loading TensorFlow model '{}'".format(self.model))
        outputs = self.kwargs.get("outputs", None)
        self._graph_def = self._graph_def_from_model(outputs)

        if self._graph_def is not None and len(self._graph_def.node) == 0:
            msg = "tf.Graph should have at least 1 node, Got empty graph."
            raise ValueError(msg)

        self._tf_ssa = self._tf_ssa_from_graph_def()

        del self._graph_def
        gc.collect()

        if self.debug:
            import graphviz

            dot_string = self._tf_ssa.get_dot_string(
                annotation=True, name_and_op_style=True, highlight_debug_nodes=[]
            )
            graphviz.Source(dot_string).view(
                filename="/tmp/ssa_before_tf_passes", cleanup=True
            )

        program = self._program_from_tf_ssa()
        logging.debug("program:\n{}".format(program))
        return program

    # @abstractmethod 
開發者ID:apple,項目名稱:coremltools,代碼行數:33,代碼來源:load.py

示例9: _program_from_tf_ssa

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def _program_from_tf_ssa(self):
        """Overwrites TFLoader._mil_program_from_tf_ssa()"""
        # Applying frontend passes on TFSSA. Note that these are different from
        # passes applied to MIL in TF frontend.
        tf_passes = [
            delete_asserts,
            functionalize_loops,
            constant_propagation,
            cond_to_where,
            remove_variable_nodes,
            fuse_dilation_conv,
        ]

        if self.debug:
            for tf_pass in _tqdm(
                tf_passes, desc="Running TensorFlow Graph Passes", unit=" passes"
            ):
                try:
                    tf_pass(self._tf_ssa)
                except Exception as e:
                    logging.exception('Exception in pass "{}": {}'.format(tf_pass, e))
                    logging.info("Ignoring exception and continuing to next pass")
        else:
            for tf_pass in _tqdm(
                tf_passes, desc="Running TensorFlow Graph Passes", unit=" passes"
            ):
                tf_pass(self._tf_ssa)

        if self.debug:
            import graphviz

            dot_string = self._tf_ssa.get_dot_string(
                annotation=True, name_and_op_style=True, highlight_debug_nodes=[]
            )
            graphviz.Source(dot_string).view(
                filename="/tmp/ssa_after_tf_passes", cleanup=True
            )

        converter = TFConverter(self._tf_ssa, **self.kwargs)
        return converter.convert() 
開發者ID:apple,項目名稱:coremltools,代碼行數:42,代碼來源:load.py

示例10: draw_text_graph

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def draw_text_graph(
        words_to_machines, out_dir, fn='text', orig_machines=[]):
    graph = MachineGraph.create_from_machines(
        words_to_machines.values(), orig_machines=orig_machines)
    src_str = graph.to_dot().encode('utf-8')
    src = graphviz.Source(src_str, format='png')
    pic_path = src.render(filename=fn, directory=out_dir)
    return pic_path 
開發者ID:kornai,項目名稱:4lang,代碼行數:10,代碼來源:utils.py

示例11: draw_dep_graph

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def draw_dep_graph(deps, out_dir, fn):
    dot_str = dep_to_dot(deps)
    src = graphviz.Source(dot_str, format='png')
    pic_path = src.render(filename=fn, directory=out_dir)
    return pic_path 
開發者ID:kornai,項目名稱:4lang,代碼行數:7,代碼來源:utils.py

示例12: dot_to_img

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def dot_to_img(dot, file = 'report.png'):
    import os

    name, ext = os.path.splitext(file)

    graph = graphviz.Source(dot)
    graph.format = ext[1:]
    graph.view(name, cleanup = True) 
開發者ID:amphibian-dev,項目名稱:toad,代碼行數:10,代碼來源:tree.py

示例13: graph

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def graph(self, format='svg'):
        try:
            from graphviz import Source
        except ImportError:
            raise ImportError("You don't have graphviz package installed.\n"
                              "Please install graphviz or use write_file function to save dot file and generate the "
                              "graph manually.")
        dot = self.generate()
        graph = Source(dot)
        graph.format = format
        return graph 
開發者ID:usc-isi-i2,項目名稱:ontology-visualization,代碼行數:13,代碼來源:ontology_viz.py

示例14: plot_model

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def plot_model(model, output, fig_name, fig_format):
    """
    Plot neural network model architecture
    :param model: network model
    :param output: network output variable
    :param fig_name: figure output name
    :param format: figure format, such as "png", "pdf"
    :return: dot file string
    """
    var = make_dot(output, params=dict(model.named_parameters()))
    s = Source(var, filename=fig_name, format=fig_format)
    s.view()
    return var 
開發者ID:BangLiu,項目名稱:QANet-PyTorch,代碼行數:15,代碼來源:vis_utils.py

示例15: view_dot_graph

# 需要導入模塊: import graphviz [as 別名]
# 或者: from graphviz import Source [as 別名]
def view_dot_graph(graph, filename=None, view=False):
    """
    View the given DOT source.  If view is True, the image is rendered
    and viewed by the default application in the system.  The file path of
    the output is returned.  If view is False, a graphviz.Source object is
    returned.  If view is False and the environment is in a IPython session,
    an IPython image object is returned and can be displayed inline in the
    notebook.

    This function requires the graphviz package.

    Args
    ----
    - graph [str]: a DOT source code
    - filename [str]: optional.  if given and view is True, this specifies
                      the file path for the rendered output to write to.
    - view [bool]: if True, opens the rendered output file.

    """
    # Optionally depends on graphviz package
    import graphviz as gv

    src = gv.Source(graph)
    if view:
        # Returns the output file path
        return src.render(filename, view=view)
    else:
        # Attempts to show the graph in IPython notebook
        try:
            __IPYTHON__
        except NameError:
            return src
        else:
            import IPython.display as display
            format = 'svg'
            return display.SVG(data=src.pipe(format))


# Ctypes binding 
開發者ID:numba,項目名稱:llvmlite,代碼行數:41,代碼來源:analysis.py


注:本文中的graphviz.Source方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。