|
-
-
- <!DOCTYPE html>
- <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
- <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
- <head>
- <meta charset="utf-8">
-
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
-
- <title>pygraph.utils package — py-graph documentation</title>
-
-
-
-
-
-
-
-
- <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
-
-
- <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
- <script type="text/javascript" src="_static/jquery.js"></script>
- <script type="text/javascript" src="_static/underscore.js"></script>
- <script type="text/javascript" src="_static/doctools.js"></script>
- <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
-
- <script type="text/javascript" src="_static/js/theme.js"></script>
-
-
-
-
- <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
- <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
- <link rel="index" title="Index" href="genindex.html" />
- <link rel="search" title="Search" href="search.html" />
- </head>
-
- <body class="wy-body-for-nav">
-
-
- <div class="wy-grid-for-nav">
-
- <nav data-toggle="wy-nav-shift" class="wy-nav-side">
- <div class="wy-side-scroll">
- <div class="wy-side-nav-search" >
-
-
-
- <a href="index.html" class="icon icon-home"> py-graph
-
-
-
- </a>
-
-
-
-
- <div class="version">
- 1.0
- </div>
-
-
-
-
- <div role="search">
- <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
- <input type="text" name="q" placeholder="Search docs" />
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- </div>
-
-
- </div>
-
- <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
-
-
-
-
-
-
- <!-- Local TOC -->
- <div class="local-toc"><ul>
- <li><a class="reference internal" href="#">pygraph.utils package</a><ul>
- <li><a class="reference internal" href="#submodules">Submodules</a></li>
- <li><a class="reference internal" href="#module-pygraph.utils.graphdataset">pygraph.utils.graphdataset module</a></li>
- <li><a class="reference internal" href="#module-pygraph.utils.graphfiles">pygraph.utils.graphfiles module</a></li>
- <li><a class="reference internal" href="#pygraph-utils-ipython-log-module">pygraph.utils.ipython_log module</a></li>
- <li><a class="reference internal" href="#module-pygraph.utils.isNotebook">pygraph.utils.isNotebook module</a></li>
- <li><a class="reference internal" href="#module-pygraph.utils.kernels">pygraph.utils.kernels module</a></li>
- <li><a class="reference internal" href="#module-pygraph.utils.logger2file">pygraph.utils.logger2file module</a></li>
- <li><a class="reference internal" href="#module-pygraph.utils.model_selection_precomputed">pygraph.utils.model_selection_precomputed module</a></li>
- <li><a class="reference internal" href="#module-pygraph.utils.parallel">pygraph.utils.parallel module</a></li>
- <li><a class="reference internal" href="#module-pygraph.utils.trie">pygraph.utils.trie module</a></li>
- <li><a class="reference internal" href="#module-pygraph.utils.utils">pygraph.utils.utils module</a></li>
- <li><a class="reference internal" href="#module-pygraph.utils">Module contents</a></li>
- </ul>
- </li>
- </ul>
- </div>
-
-
- </div>
- </div>
- </nav>
-
- <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
-
-
- <nav class="wy-nav-top" aria-label="top navigation">
-
- <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
- <a href="index.html">py-graph</a>
-
- </nav>
-
-
- <div class="wy-nav-content">
-
- <div class="rst-content">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <div role="navigation" aria-label="breadcrumbs navigation">
-
- <ul class="wy-breadcrumbs">
-
- <li><a href="index.html">Docs</a> »</li>
-
- <li>pygraph.utils package</li>
-
-
- <li class="wy-breadcrumbs-aside">
-
-
- <a href="_sources/pygraph.utils.rst.txt" rel="nofollow"> View page source</a>
-
-
- </li>
-
- </ul>
-
-
- <hr/>
- </div>
- <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
- <div itemprop="articleBody">
-
- <div class="section" id="pygraph-utils-package">
- <h1>pygraph.utils package<a class="headerlink" href="#pygraph-utils-package" title="Permalink to this headline">¶</a></h1>
- <div class="section" id="submodules">
- <h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline">¶</a></h2>
- </div>
- <div class="section" id="module-pygraph.utils.graphdataset">
- <span id="pygraph-utils-graphdataset-module"></span><h2>pygraph.utils.graphdataset module<a class="headerlink" href="#module-pygraph.utils.graphdataset" title="Permalink to this headline">¶</a></h2>
- <p>Obtain all kinds of attributes of a graph dataset.</p>
- <dl class="function">
- <dt id="pygraph.utils.graphdataset.get_dataset_attributes">
- <code class="descclassname">pygraph.utils.graphdataset.</code><code class="descname">get_dataset_attributes</code><span class="sig-paren">(</span><em>Gn</em>, <em>target=None</em>, <em>attr_names=[]</em>, <em>node_label=None</em>, <em>edge_label=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphdataset.html#get_dataset_attributes"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphdataset.get_dataset_attributes" title="Permalink to this definition">¶</a></dt>
- <dd><p>Returns the structure and property information of the graph dataset Gn.</p>
- <dl class="docutils">
- <dt>Gn <span class="classifier-delimiter">:</span> <span class="classifier">List of NetworkX graph</span></dt>
- <dd>List of graphs whose information will be returned.</dd>
- <dt>target <span class="classifier-delimiter">:</span> <span class="classifier">list</span></dt>
- <dd>The list of classification targets corresponding to Gn. Only works for
- classification problems.</dd>
- <dt>attr_names <span class="classifier-delimiter">:</span> <span class="classifier">list</span></dt>
- <dd><p class="first">List of strings which indicate which informations will be returned. The
- possible choices includes:
- ‘substructures’: sub-structures Gn contains, including ‘linear’, ‘non</p>
- <blockquote>
- <div>linear’ and ‘cyclic’.</div></blockquote>
- <p>‘node_labeled’: whether vertices have symbolic labels.
- ‘edge_labeled’: whether egdes have symbolic labels.
- ‘is_directed’: whether graphs in Gn are directed.
- ‘dataset_size’: number of graphs in Gn.
- ‘ave_node_num’: average number of vertices of graphs in Gn.
- ‘min_node_num’: minimum number of vertices of graphs in Gn.
- ‘max_node_num’: maximum number of vertices of graphs in Gn.
- ‘ave_edge_num’: average number of edges of graphs in Gn.
- ‘min_edge_num’: minimum number of edges of graphs in Gn.
- ‘max_edge_num’: maximum number of edges of graphs in Gn.
- ‘ave_node_degree’: average vertex degree of graphs in Gn.
- ‘min_node_degree’: minimum vertex degree of graphs in Gn.
- ‘max_node_degree’: maximum vertex degree of graphs in Gn.
- ‘ave_fill_factor’: average fill factor (number_of_edges /</p>
- <blockquote>
- <div>(number_of_nodes ** 2)) of graphs in Gn.</div></blockquote>
- <p>‘min_fill_factor’: minimum fill factor of graphs in Gn.
- ‘max_fill_factor’: maximum fill factor of graphs in Gn.
- ‘node_label_num’: number of symbolic vertex labels.
- ‘edge_label_num’: number of symbolic edge labels.
- ‘node_attr_dim’: number of dimensions of non-symbolic vertex labels.</p>
- <blockquote>
- <div>Extracted from the ‘attributes’ attribute of graph nodes.</div></blockquote>
- <dl class="last docutils">
- <dt>‘edge_attr_dim’: number of dimensions of non-symbolic edge labels.</dt>
- <dd>Extracted from the ‘attributes’ attribute of graph edges.</dd>
- <dt>‘class_number’: number of classes. Only available for classification </dt>
- <dd>problems.</dd>
- </dl>
- </dd>
- <dt>node_label <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>Node attribute used as label. The default node label is atom. Mandatory
- when ‘node_labeled’ or ‘node_label_num’ is required.</dd>
- <dt>edge_label <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>Edge attribute used as label. The default edge label is bond_type.
- Mandatory when ‘edge_labeled’ or ‘edge_label_num’ is required.</dd>
- </dl>
- <dl class="docutils">
- <dt>attrs <span class="classifier-delimiter">:</span> <span class="classifier">dict</span></dt>
- <dd>Value for each property.</dd>
- </dl>
- </dd></dl>
-
- </div>
- <div class="section" id="module-pygraph.utils.graphfiles">
- <span id="pygraph-utils-graphfiles-module"></span><h2>pygraph.utils.graphfiles module<a class="headerlink" href="#module-pygraph.utils.graphfiles" title="Permalink to this headline">¶</a></h2>
- <p>Utilities function to manage graph files</p>
- <dl class="function">
- <dt id="pygraph.utils.graphfiles.loadCT">
- <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadCT</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadCT"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadCT" title="Permalink to this definition">¶</a></dt>
- <dd><p>load data from a Chemical Table (.ct) file.</p>
- <p>a typical example of data in .ct is like this:</p>
- <blockquote>
- <div><dl class="docutils">
- <dt>3 2 <- number of nodes and edges</dt>
- <dd><blockquote class="first">
- <div>0.0000 0.0000 0.0000 C <- each line describes a node (x,y,z + label)
- 0.0000 0.0000 0.0000 C
- 0.0000 0.0000 0.0000 O</div></blockquote>
- <p class="last">1 3 1 1 <- each line describes an edge : to, from, bond type, bond stereo
- 2 3 1 1</p>
- </dd>
- </dl>
- </div></blockquote>
- <p>Check <a class="reference external" href="https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=10&ved=2ahUKEwivhaSdjsTlAhVhx4UKHczHA8gQFjAJegQIARAC&url=https%3A%2F%2Fwww.daylight.com%2Fmeetings%2Fmug05%2FKappler%2Fctfile.pdf&usg=AOvVaw1cDNrrmMClkFPqodlF2inS">https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=10&ved=2ahUKEwivhaSdjsTlAhVhx4UKHczHA8gQFjAJegQIARAC&url=https%3A%2F%2Fwww.daylight.com%2Fmeetings%2Fmug05%2FKappler%2Fctfile.pdf&usg=AOvVaw1cDNrrmMClkFPqodlF2inS</a>
- for detailed format discription.</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.graphfiles.loadDataset">
- <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadDataset</code><span class="sig-paren">(</span><em>filename</em>, <em>filename_y=None</em>, <em>extra_params=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadDataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadDataset" title="Permalink to this definition">¶</a></dt>
- <dd><p>Read graph data from filename and load them as NetworkX graphs.</p>
- <dl class="docutils">
- <dt>filename <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>The name of the file from where the dataset is read.</dd>
- <dt>filename_y <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>The name of file of the targets corresponding to graphs.</dd>
- <dt>extra_params <span class="classifier-delimiter">:</span> <span class="classifier">dict</span></dt>
- <dd>Extra parameters only designated to ‘.mat’ format.</dd>
- </dl>
- <p>data : List of NetworkX graph.
- y : List</p>
- <blockquote>
- <div>Targets corresponding to graphs.</div></blockquote>
- <p>This function supports following graph dataset formats:
- ‘ds’: load data from .ds file. See comments of function loadFromDS for a example.
- ‘cxl’: load data from Graph eXchange Language file (.cxl file). See</p>
- <blockquote>
- <div><a class="reference external" href="http://www.gupro.de/GXL/Introduction/background.html">http://www.gupro.de/GXL/Introduction/background.html</a>, 2019 for detail.</div></blockquote>
- <dl class="docutils">
- <dt>‘sdf’: load data from structured data file (.sdf file). See </dt>
- <dd><a class="reference external" href="http://www.nonlinear.com/progenesis/sdf-studio/v0.9/faq/sdf-file-format-guidance.aspx">http://www.nonlinear.com/progenesis/sdf-studio/v0.9/faq/sdf-file-format-guidance.aspx</a>,
- 2018 for details.</dd>
- <dt>‘mat’: Load graph data from a MATLAB (up to version 7.1) .mat file. See</dt>
- <dd>README in downloadable file in <a class="reference external" href="http://mlcb.is.tuebingen.mpg.de/Mitarbeiter/Nino/WL/">http://mlcb.is.tuebingen.mpg.de/Mitarbeiter/Nino/WL/</a>,
- 2018 for details.</dd>
- <dt>‘txt’: Load graph data from a special .txt file. See</dt>
- <dd><a class="reference external" href="https://ls11-www.cs.tu-dortmund.de/staff/morris/graphkerneldatasets">https://ls11-www.cs.tu-dortmund.de/staff/morris/graphkerneldatasets</a>,
- 2019 for details. Note here filename is the name of either .txt file in
- the dataset directory.</dd>
- </dl>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.graphfiles.loadFromDS">
- <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadFromDS</code><span class="sig-paren">(</span><em>filename</em>, <em>filename_y</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadFromDS"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadFromDS" title="Permalink to this definition">¶</a></dt>
- <dd><p>Load data from .ds file.
- Possible graph formats include:</p>
- <blockquote>
- <div>‘.ct’: see function loadCT for detail.
- ‘.gxl’: see dunction loadGXL for detail.</div></blockquote>
- <p>Note these graph formats are checked automatically by the extensions of
- graph files.</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.graphfiles.loadFromXML">
- <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadFromXML</code><span class="sig-paren">(</span><em>filename</em>, <em>extra_params</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadFromXML"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadFromXML" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.graphfiles.loadGXL">
- <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadGXL</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadGXL"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadGXL" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.graphfiles.loadMAT">
- <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadMAT</code><span class="sig-paren">(</span><em>filename</em>, <em>extra_params</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadMAT"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadMAT" title="Permalink to this definition">¶</a></dt>
- <dd><p>Load graph data from a MATLAB (up to version 7.1) .mat file.</p>
- <p>A MAT file contains a struct array containing graphs, and a column vector lx containing a class label for each graph.
- Check README in downloadable file in <a class="reference external" href="http://mlcb.is.tuebingen.mpg.de/Mitarbeiter/Nino/WL/">http://mlcb.is.tuebingen.mpg.de/Mitarbeiter/Nino/WL/</a>, 2018 for detailed structure.</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.graphfiles.loadSDF">
- <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadSDF</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadSDF"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadSDF" title="Permalink to this definition">¶</a></dt>
- <dd><p>load data from structured data file (.sdf file).</p>
- <p>A SDF file contains a group of molecules, represented in the similar way as in MOL format.
- Check <a class="reference external" href="http://www.nonlinear.com/progenesis/sdf-studio/v0.9/faq/sdf-file-format-guidance.aspx">http://www.nonlinear.com/progenesis/sdf-studio/v0.9/faq/sdf-file-format-guidance.aspx</a>, 2018 for detailed structure.</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.graphfiles.loadTXT">
- <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">loadTXT</code><span class="sig-paren">(</span><em>dirname_dataset</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#loadTXT"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.loadTXT" title="Permalink to this definition">¶</a></dt>
- <dd><p>Load graph data from a .txt file.</p>
- <p>The graph data is loaded from separate files.
- Check README in downloadable file <a class="reference external" href="http://tiny.cc/PK_MLJ_data">http://tiny.cc/PK_MLJ_data</a>, 2018 for detailed structure.</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.graphfiles.saveDataset">
- <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">saveDataset</code><span class="sig-paren">(</span><em>Gn</em>, <em>y</em>, <em>gformat='gxl'</em>, <em>group=None</em>, <em>filename='gfile'</em>, <em>xparams=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#saveDataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.saveDataset" title="Permalink to this definition">¶</a></dt>
- <dd><p>Save list of graphs.</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.graphfiles.saveGXL">
- <code class="descclassname">pygraph.utils.graphfiles.</code><code class="descname">saveGXL</code><span class="sig-paren">(</span><em>graph</em>, <em>filename</em>, <em>method='benoit'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/graphfiles.html#saveGXL"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.graphfiles.saveGXL" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- </div>
- <div class="section" id="pygraph-utils-ipython-log-module">
- <h2>pygraph.utils.ipython_log module<a class="headerlink" href="#pygraph-utils-ipython-log-module" title="Permalink to this headline">¶</a></h2>
- </div>
- <div class="section" id="module-pygraph.utils.isNotebook">
- <span id="pygraph-utils-isnotebook-module"></span><h2>pygraph.utils.isNotebook module<a class="headerlink" href="#module-pygraph.utils.isNotebook" title="Permalink to this headline">¶</a></h2>
- <p>Functions for python system.</p>
- <dl class="function">
- <dt id="pygraph.utils.isNotebook.isNotebook">
- <code class="descclassname">pygraph.utils.isNotebook.</code><code class="descname">isNotebook</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/isNotebook.html#isNotebook"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.isNotebook.isNotebook" title="Permalink to this definition">¶</a></dt>
- <dd><p>check if code is executed in the IPython notebook.</p>
- </dd></dl>
-
- </div>
- <div class="section" id="module-pygraph.utils.kernels">
- <span id="pygraph-utils-kernels-module"></span><h2>pygraph.utils.kernels module<a class="headerlink" href="#module-pygraph.utils.kernels" title="Permalink to this headline">¶</a></h2>
- <p>Those who are not graph kernels. We can be kernels for nodes or edges!
- These kernels are defined between pairs of vectors.</p>
- <dl class="function">
- <dt id="pygraph.utils.kernels.deltakernel">
- <code class="descclassname">pygraph.utils.kernels.</code><code class="descname">deltakernel</code><span class="sig-paren">(</span><em>x</em>, <em>y</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/kernels.html#deltakernel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.kernels.deltakernel" title="Permalink to this definition">¶</a></dt>
- <dd><p>Delta kernel. Return 1 if x == y, 0 otherwise.</p>
- <dl class="docutils">
- <dt>x, y <span class="classifier-delimiter">:</span> <span class="classifier">any</span></dt>
- <dd>Two parts to compare.</dd>
- </dl>
- <dl class="docutils">
- <dt>kernel <span class="classifier-delimiter">:</span> <span class="classifier">integer</span></dt>
- <dd>Delta kernel.</dd>
- </dl>
- <p>[1] H. Kashima, K. Tsuda, and A. Inokuchi. Marginalized kernels between
- labeled graphs. In Proceedings of the 20th International Conference on
- Machine Learning, Washington, DC, United States, 2003.</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.kernels.gaussiankernel">
- <code class="descclassname">pygraph.utils.kernels.</code><code class="descname">gaussiankernel</code><span class="sig-paren">(</span><em>x</em>, <em>y</em>, <em>gamma=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/kernels.html#gaussiankernel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.kernels.gaussiankernel" title="Permalink to this definition">¶</a></dt>
- <dd><p>Gaussian kernel.
- Compute the rbf (gaussian) kernel between x and y:</p>
- <blockquote>
- <div>K(x, y) = exp(-gamma ||x-y||^2).</div></blockquote>
- <p>Read more in the <span class="xref std std-ref">User Guide</span>.</p>
- <p>x, y : array</p>
- <dl class="docutils">
- <dt>gamma <span class="classifier-delimiter">:</span> <span class="classifier">float, default None</span></dt>
- <dd>If None, defaults to 1.0 / n_features</dd>
- </dl>
- <p>kernel : float</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.kernels.kernelproduct">
- <code class="descclassname">pygraph.utils.kernels.</code><code class="descname">kernelproduct</code><span class="sig-paren">(</span><em>k1</em>, <em>k2</em>, <em>d11</em>, <em>d12</em>, <em>d21=None</em>, <em>d22=None</em>, <em>lamda=1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/kernels.html#kernelproduct"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.kernels.kernelproduct" title="Permalink to this definition">¶</a></dt>
- <dd><p>Product of a pair of kernels.</p>
- <p>k = lamda * k1(d11, d12) * k2(d21, d22)</p>
- <dl class="docutils">
- <dt>k1, k2 <span class="classifier-delimiter">:</span> <span class="classifier">function</span></dt>
- <dd>A pair of kernel functions.</dd>
- <dt>d11, d12:</dt>
- <dd>Inputs of k1. If d21 or d22 is None, apply d11, d12 to both k1 and k2.</dd>
- <dt>d21, d22:</dt>
- <dd>Inputs of k2.</dd>
- <dt>lamda: float</dt>
- <dd>Coefficient of the product.</dd>
- </dl>
- <p>kernel : integer</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.kernels.kernelsum">
- <code class="descclassname">pygraph.utils.kernels.</code><code class="descname">kernelsum</code><span class="sig-paren">(</span><em>k1</em>, <em>k2</em>, <em>d11</em>, <em>d12</em>, <em>d21=None</em>, <em>d22=None</em>, <em>lamda1=1</em>, <em>lamda2=1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/kernels.html#kernelsum"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.kernels.kernelsum" title="Permalink to this definition">¶</a></dt>
- <dd><p>Sum of a pair of kernels.</p>
- <p>k = lamda1 * k1(d11, d12) + lamda2 * k2(d21, d22)</p>
- <dl class="docutils">
- <dt>k1, k2 <span class="classifier-delimiter">:</span> <span class="classifier">function</span></dt>
- <dd>A pair of kernel functions.</dd>
- <dt>d11, d12:</dt>
- <dd>Inputs of k1. If d21 or d22 is None, apply d11, d12 to both k1 and k2.</dd>
- <dt>d21, d22:</dt>
- <dd>Inputs of k2.</dd>
- <dt>lamda1, lamda2: float</dt>
- <dd>Coefficients of the product.</dd>
- </dl>
- <p>kernel : integer</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.kernels.linearkernel">
- <code class="descclassname">pygraph.utils.kernels.</code><code class="descname">linearkernel</code><span class="sig-paren">(</span><em>x</em>, <em>y</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/kernels.html#linearkernel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.kernels.linearkernel" title="Permalink to this definition">¶</a></dt>
- <dd><p>Polynomial kernel.
- Compute the polynomial kernel between x and y:</p>
- <blockquote>
- <div>K(x, y) = <x, y>.</div></blockquote>
- <p>x, y : array</p>
- <p>d : integer, default 1</p>
- <p>c : float, default 0</p>
- <p>kernel : float</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.kernels.polynomialkernel">
- <code class="descclassname">pygraph.utils.kernels.</code><code class="descname">polynomialkernel</code><span class="sig-paren">(</span><em>x</em>, <em>y</em>, <em>d=1</em>, <em>c=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/kernels.html#polynomialkernel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.kernels.polynomialkernel" title="Permalink to this definition">¶</a></dt>
- <dd><p>Polynomial kernel.
- Compute the polynomial kernel between x and y:</p>
- <blockquote>
- <div>K(x, y) = <x, y> ^d + c.</div></blockquote>
- <p>x, y : array</p>
- <p>d : integer, default 1</p>
- <p>c : float, default 0</p>
- <p>kernel : float</p>
- </dd></dl>
-
- </div>
- <div class="section" id="module-pygraph.utils.logger2file">
- <span id="pygraph-utils-logger2file-module"></span><h2>pygraph.utils.logger2file module<a class="headerlink" href="#module-pygraph.utils.logger2file" title="Permalink to this headline">¶</a></h2>
- <p>Created on Fri Nov 8 14:21:25 2019</p>
- <p>@author: ljia</p>
- <dl class="class">
- <dt id="pygraph.utils.logger2file.Logger">
- <em class="property">class </em><code class="descclassname">pygraph.utils.logger2file.</code><code class="descname">Logger</code><a class="reference internal" href="_modules/pygraph/utils/logger2file.html#Logger"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.logger2file.Logger" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
- <dl class="method">
- <dt id="pygraph.utils.logger2file.Logger.flush">
- <code class="descname">flush</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/logger2file.html#Logger.flush"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.logger2file.Logger.flush" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="method">
- <dt id="pygraph.utils.logger2file.Logger.write">
- <code class="descname">write</code><span class="sig-paren">(</span><em>message</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/logger2file.html#Logger.write"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.logger2file.Logger.write" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- </dd></dl>
-
- </div>
- <div class="section" id="module-pygraph.utils.model_selection_precomputed">
- <span id="pygraph-utils-model-selection-precomputed-module"></span><h2>pygraph.utils.model_selection_precomputed module<a class="headerlink" href="#module-pygraph.utils.model_selection_precomputed" title="Permalink to this headline">¶</a></h2>
- <dl class="function">
- <dt id="pygraph.utils.model_selection_precomputed.compute_gram_matrices">
- <code class="descclassname">pygraph.utils.model_selection_precomputed.</code><code class="descname">compute_gram_matrices</code><span class="sig-paren">(</span><em>dataset</em>, <em>y</em>, <em>estimator</em>, <em>param_list_precomputed</em>, <em>results_dir</em>, <em>ds_name</em>, <em>n_jobs=1</em>, <em>str_fw=''</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/model_selection_precomputed.html#compute_gram_matrices"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.model_selection_precomputed.compute_gram_matrices" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.model_selection_precomputed.model_selection_for_precomputed_kernel">
- <code class="descclassname">pygraph.utils.model_selection_precomputed.</code><code class="descname">model_selection_for_precomputed_kernel</code><span class="sig-paren">(</span><em>datafile</em>, <em>estimator</em>, <em>param_grid_precomputed</em>, <em>param_grid</em>, <em>model_type</em>, <em>NUM_TRIALS=30</em>, <em>datafile_y=None</em>, <em>extra_params=None</em>, <em>ds_name='ds-unknown'</em>, <em>n_jobs=1</em>, <em>read_gm_from_file=False</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/model_selection_precomputed.html#model_selection_for_precomputed_kernel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.model_selection_precomputed.model_selection_for_precomputed_kernel" title="Permalink to this definition">¶</a></dt>
- <dd><p>Perform model selection, fitting and testing for precomputed kernels
- using nested CV. Print out neccessary data during the process then finally
- the results.</p>
- <dl class="docutils">
- <dt>datafile <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>Path of dataset file.</dd>
- <dt>estimator <span class="classifier-delimiter">:</span> <span class="classifier">function</span></dt>
- <dd>kernel function used to estimate. This function needs to return a gram matrix.</dd>
- <dt>param_grid_precomputed <span class="classifier-delimiter">:</span> <span class="classifier">dictionary</span></dt>
- <dd>Dictionary with names (string) of parameters used to calculate gram
- matrices as keys and lists of parameter settings to try as values. This
- enables searching over any sequence of parameter settings. Params with
- length 1 will be omitted.</dd>
- <dt>param_grid <span class="classifier-delimiter">:</span> <span class="classifier">dictionary</span></dt>
- <dd>Dictionary with names (string) of parameters used as penelties as keys
- and lists of parameter settings to try as values. This enables
- searching over any sequence of parameter settings. Params with length 1
- will be omitted.</dd>
- <dt>model_type <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>Type of the problem, can be ‘regression’ or ‘classification’.</dd>
- <dt>NUM_TRIALS <span class="classifier-delimiter">:</span> <span class="classifier">integer</span></dt>
- <dd>Number of random trials of outer cv loop. The default is 30.</dd>
- <dt>datafile_y <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>Path of file storing y data. This parameter is optional depending on
- the given dataset file.</dd>
- <dt>extra_params <span class="classifier-delimiter">:</span> <span class="classifier">dict</span></dt>
- <dd>Extra parameters for loading dataset. See function pygraph.utils.
- graphfiles.loadDataset for detail.</dd>
- <dt>ds_name <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>Name of the dataset.</dd>
- <dt>n_jobs <span class="classifier-delimiter">:</span> <span class="classifier">int</span></dt>
- <dd>Number of jobs for parallelization.</dd>
- <dt>read_gm_from_file <span class="classifier-delimiter">:</span> <span class="classifier">boolean</span></dt>
- <dd>Whether gram matrices are loaded from a file.</dd>
- </dl>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>>>> import numpy as np
- >>> import sys
- >>> sys.path.insert(0, "../")
- >>> from pygraph.utils.model_selection_precomputed import model_selection_for_precomputed_kernel
- >>> from pygraph.kernels.untilHPathKernel import untilhpathkernel
- >>>
- >>> datafile = '../datasets/MUTAG/MUTAG_A.txt'
- >>> estimator = untilhpathkernel
- >>> param_grid_precomputed = {’depth’: np.linspace(1, 10, 10), ’k_func’:
- [’MinMax’, ’tanimoto’], ’compute_method’: [’trie’]}
- >>> # ’C’ for classification problems and ’alpha’ for regression problems.
- >>> param_grid = [{’C’: np.logspace(-10, 10, num=41, base=10)}, {’alpha’:
- np.logspace(-10, 10, num=41, base=10)}]
- >>>
- >>> model_selection_for_precomputed_kernel(datafile, estimator,
- param_grid_precomputed, param_grid[0], 'classification', ds_name=’MUTAG’)
- </pre></div>
- </div>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.model_selection_precomputed.parallel_trial_do">
- <code class="descclassname">pygraph.utils.model_selection_precomputed.</code><code class="descname">parallel_trial_do</code><span class="sig-paren">(</span><em>param_list_pre_revised</em>, <em>param_list</em>, <em>y</em>, <em>model_type</em>, <em>trial</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/model_selection_precomputed.html#parallel_trial_do"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.model_selection_precomputed.parallel_trial_do" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.model_selection_precomputed.printResultsInTable">
- <code class="descclassname">pygraph.utils.model_selection_precomputed.</code><code class="descname">printResultsInTable</code><span class="sig-paren">(</span><em>param_list</em>, <em>param_list_pre_revised</em>, <em>average_val_scores</em>, <em>std_val_scores</em>, <em>average_perf_scores</em>, <em>std_perf_scores</em>, <em>average_train_scores</em>, <em>std_train_scores</em>, <em>gram_matrix_time</em>, <em>model_type</em>, <em>verbose</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/model_selection_precomputed.html#printResultsInTable"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.model_selection_precomputed.printResultsInTable" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.model_selection_precomputed.read_gram_matrices_from_file">
- <code class="descclassname">pygraph.utils.model_selection_precomputed.</code><code class="descname">read_gram_matrices_from_file</code><span class="sig-paren">(</span><em>results_dir</em>, <em>ds_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/model_selection_precomputed.html#read_gram_matrices_from_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.model_selection_precomputed.read_gram_matrices_from_file" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.model_selection_precomputed.trial_do">
- <code class="descclassname">pygraph.utils.model_selection_precomputed.</code><code class="descname">trial_do</code><span class="sig-paren">(</span><em>param_list_pre_revised</em>, <em>param_list</em>, <em>gram_matrices</em>, <em>y</em>, <em>model_type</em>, <em>trial</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/model_selection_precomputed.html#trial_do"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.model_selection_precomputed.trial_do" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- </div>
- <div class="section" id="module-pygraph.utils.parallel">
- <span id="pygraph-utils-parallel-module"></span><h2>pygraph.utils.parallel module<a class="headerlink" href="#module-pygraph.utils.parallel" title="Permalink to this headline">¶</a></h2>
- <p>Created on Tue Dec 11 11:39:46 2018
- Parallel aid functions.
- @author: ljia</p>
- <dl class="function">
- <dt id="pygraph.utils.parallel.parallel_gm">
- <code class="descclassname">pygraph.utils.parallel.</code><code class="descname">parallel_gm</code><span class="sig-paren">(</span><em>func</em>, <em>Kmatrix</em>, <em>Gn</em>, <em>init_worker=None</em>, <em>glbv=None</em>, <em>method='imap_unordered'</em>, <em>n_jobs=None</em>, <em>chunksize=None</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/parallel.html#parallel_gm"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.parallel.parallel_gm" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.parallel.parallel_me">
- <code class="descclassname">pygraph.utils.parallel.</code><code class="descname">parallel_me</code><span class="sig-paren">(</span><em>func</em>, <em>func_assign</em>, <em>var_to_assign</em>, <em>itr</em>, <em>len_itr=None</em>, <em>init_worker=None</em>, <em>glbv=None</em>, <em>method=None</em>, <em>n_jobs=None</em>, <em>chunksize=None</em>, <em>itr_desc=''</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/parallel.html#parallel_me"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.parallel.parallel_me" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- </div>
- <div class="section" id="module-pygraph.utils.trie">
- <span id="pygraph-utils-trie-module"></span><h2>pygraph.utils.trie module<a class="headerlink" href="#module-pygraph.utils.trie" title="Permalink to this headline">¶</a></h2>
- <p>Created on Wed Jan 30 10:48:49 2019</p>
- <p>Trie (prefix tree)
- @author: ljia
- @references:</p>
- <blockquote>
- <div><a class="reference external" href="https://viblo.asia/p/nlp-build-a-trie-data-structure-from-scratch-with-python-3P0lPzroKox">https://viblo.asia/p/nlp-build-a-trie-data-structure-from-scratch-with-python-3P0lPzroKox</a>, 2019.1</div></blockquote>
- <dl class="class">
- <dt id="pygraph.utils.trie.Trie">
- <em class="property">class </em><code class="descclassname">pygraph.utils.trie.</code><code class="descname">Trie</code><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
- <dl class="method">
- <dt id="pygraph.utils.trie.Trie.deleteWord">
- <code class="descname">deleteWord</code><span class="sig-paren">(</span><em>word</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.deleteWord"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.deleteWord" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="method">
- <dt id="pygraph.utils.trie.Trie.getNode">
- <code class="descname">getNode</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.getNode"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.getNode" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="method">
- <dt id="pygraph.utils.trie.Trie.insertWord">
- <code class="descname">insertWord</code><span class="sig-paren">(</span><em>word</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.insertWord"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.insertWord" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="method">
- <dt id="pygraph.utils.trie.Trie.load_from_json">
- <code class="descname">load_from_json</code><span class="sig-paren">(</span><em>file_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.load_from_json"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.load_from_json" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="method">
- <dt id="pygraph.utils.trie.Trie.load_from_pickle">
- <code class="descname">load_from_pickle</code><span class="sig-paren">(</span><em>file_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.load_from_pickle"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.load_from_pickle" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="method">
- <dt id="pygraph.utils.trie.Trie.save_to_json">
- <code class="descname">save_to_json</code><span class="sig-paren">(</span><em>file_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.save_to_json"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.save_to_json" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="method">
- <dt id="pygraph.utils.trie.Trie.save_to_pickle">
- <code class="descname">save_to_pickle</code><span class="sig-paren">(</span><em>file_name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.save_to_pickle"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.save_to_pickle" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="method">
- <dt id="pygraph.utils.trie.Trie.searchWord">
- <code class="descname">searchWord</code><span class="sig-paren">(</span><em>word</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.searchWord"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.searchWord" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="method">
- <dt id="pygraph.utils.trie.Trie.searchWordPrefix">
- <code class="descname">searchWordPrefix</code><span class="sig-paren">(</span><em>word</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.searchWordPrefix"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.searchWordPrefix" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="method">
- <dt id="pygraph.utils.trie.Trie.to_json">
- <code class="descname">to_json</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/trie.html#Trie.to_json"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.trie.Trie.to_json" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- </dd></dl>
-
- </div>
- <div class="section" id="module-pygraph.utils.utils">
- <span id="pygraph-utils-utils-module"></span><h2>pygraph.utils.utils module<a class="headerlink" href="#module-pygraph.utils.utils" title="Permalink to this headline">¶</a></h2>
- <dl class="function">
- <dt id="pygraph.utils.utils.direct_product">
- <code class="descclassname">pygraph.utils.utils.</code><code class="descname">direct_product</code><span class="sig-paren">(</span><em>G1</em>, <em>G2</em>, <em>node_label</em>, <em>edge_label</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#direct_product"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.direct_product" title="Permalink to this definition">¶</a></dt>
- <dd><p>Return the direct/tensor product of directed graphs G1 and G2.</p>
- <dl class="docutils">
- <dt>G1, G2 <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
- <dd>The original graphs.</dd>
- <dt>node_label <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>node attribute used as label. The default node label is ‘atom’.</dd>
- <dt>edge_label <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>edge attribute used as label. The default edge label is ‘bond_type’.</dd>
- </dl>
- <dl class="docutils">
- <dt>gt <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
- <dd>The direct product graph of G1 and G2.</dd>
- </dl>
- <p>This method differs from networkx.tensor_product in that this method only adds nodes and edges in G1 and G2 that have the same labels to the direct product graph.</p>
- <p>[1] Thomas Gärtner, Peter Flach, and Stefan Wrobel. On graph kernels: Hardness results and efficient alternatives. Learning Theory and Kernel Machines, pages 129–143, 2003.</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.utils.floydTransformation">
- <code class="descclassname">pygraph.utils.utils.</code><code class="descname">floydTransformation</code><span class="sig-paren">(</span><em>G</em>, <em>edge_weight=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#floydTransformation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.floydTransformation" title="Permalink to this definition">¶</a></dt>
- <dd><p>Transform graph G to its corresponding shortest-paths graph using Floyd-transformation.</p>
- <dl class="docutils">
- <dt>G <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
- <dd>The graph to be tramsformed.</dd>
- <dt>edge_weight <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>edge attribute corresponding to the edge weight. The default edge weight is bond_type.</dd>
- </dl>
- <dl class="docutils">
- <dt>S <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
- <dd>The shortest-paths graph corresponding to G.</dd>
- </dl>
- <p>[1] Borgwardt KM, Kriegel HP. Shortest-path kernels on graphs. InData Mining, Fifth IEEE International Conference on 2005 Nov 27 (pp. 8-pp). IEEE.</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.utils.getSPGraph">
- <code class="descclassname">pygraph.utils.utils.</code><code class="descname">getSPGraph</code><span class="sig-paren">(</span><em>G</em>, <em>edge_weight=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#getSPGraph"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.getSPGraph" title="Permalink to this definition">¶</a></dt>
- <dd><p>Transform graph G to its corresponding shortest-paths graph.</p>
- <dl class="docutils">
- <dt>G <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
- <dd>The graph to be tramsformed.</dd>
- <dt>edge_weight <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>edge attribute corresponding to the edge weight.</dd>
- </dl>
- <dl class="docutils">
- <dt>S <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
- <dd>The shortest-paths graph corresponding to G.</dd>
- </dl>
- <p>For an input graph G, its corresponding shortest-paths graph S contains the same set of nodes as G, while there exists an edge between all nodes in S which are connected by a walk in G. Every edge in S between two nodes is labeled by the shortest distance between these two nodes.</p>
- <p>[1] Borgwardt KM, Kriegel HP. Shortest-path kernels on graphs. InData Mining, Fifth IEEE International Conference on 2005 Nov 27 (pp. 8-pp). IEEE.</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.utils.getSPLengths">
- <code class="descclassname">pygraph.utils.utils.</code><code class="descname">getSPLengths</code><span class="sig-paren">(</span><em>G1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#getSPLengths"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.getSPLengths" title="Permalink to this definition">¶</a></dt>
- <dd></dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.utils.get_edge_labels">
- <code class="descclassname">pygraph.utils.utils.</code><code class="descname">get_edge_labels</code><span class="sig-paren">(</span><em>Gn</em>, <em>edge_label</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#get_edge_labels"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.get_edge_labels" title="Permalink to this definition">¶</a></dt>
- <dd><p>Get edge labels of dataset Gn.</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.utils.get_node_labels">
- <code class="descclassname">pygraph.utils.utils.</code><code class="descname">get_node_labels</code><span class="sig-paren">(</span><em>Gn</em>, <em>node_label</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#get_node_labels"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.get_node_labels" title="Permalink to this definition">¶</a></dt>
- <dd><p>Get node labels of dataset Gn.</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.utils.graph_deepcopy">
- <code class="descclassname">pygraph.utils.utils.</code><code class="descname">graph_deepcopy</code><span class="sig-paren">(</span><em>G</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#graph_deepcopy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.graph_deepcopy" title="Permalink to this definition">¶</a></dt>
- <dd><p>Deep copy a graph, including deep copy of all nodes, edges and
- attributes of the graph, nodes and edges.</p>
- <p>It is the same as the NetworkX function graph.copy(), as far as I know.</p>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.utils.graph_isIdentical">
- <code class="descclassname">pygraph.utils.utils.</code><code class="descname">graph_isIdentical</code><span class="sig-paren">(</span><em>G1</em>, <em>G2</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#graph_isIdentical"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.graph_isIdentical" title="Permalink to this definition">¶</a></dt>
- <dd><p>Check if two graphs are identical, including: same nodes, edges, node
- labels/attributes, edge labels/attributes.</p>
- <ol class="arabic simple">
- <li>The type of graphs has to be the same.</li>
- <li>Global/Graph attributes are neglected as they may contain names for graphs.</li>
- </ol>
- </dd></dl>
-
- <dl class="function">
- <dt id="pygraph.utils.utils.untotterTransformation">
- <code class="descclassname">pygraph.utils.utils.</code><code class="descname">untotterTransformation</code><span class="sig-paren">(</span><em>G</em>, <em>node_label</em>, <em>edge_label</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pygraph/utils/utils.html#untotterTransformation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pygraph.utils.utils.untotterTransformation" title="Permalink to this definition">¶</a></dt>
- <dd><p>Transform graph G according to Mahé et al.’s work to filter out tottering patterns of marginalized kernel and tree pattern kernel.</p>
- <dl class="docutils">
- <dt>G <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
- <dd>The graph to be tramsformed.</dd>
- <dt>node_label <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>node attribute used as label. The default node label is ‘atom’.</dd>
- <dt>edge_label <span class="classifier-delimiter">:</span> <span class="classifier">string</span></dt>
- <dd>edge attribute used as label. The default edge label is ‘bond_type’.</dd>
- </dl>
- <dl class="docutils">
- <dt>gt <span class="classifier-delimiter">:</span> <span class="classifier">NetworkX graph</span></dt>
- <dd>The transformed graph corresponding to G.</dd>
- </dl>
- <p>[1] Pierre Mahé, Nobuhisa Ueda, Tatsuya Akutsu, Jean-Luc Perret, and Jean-Philippe Vert. Extensions of marginalized graph kernels. In Proceedings of the twenty-first international conference on Machine learning, page 70. ACM, 2004.</p>
- </dd></dl>
-
- </div>
- <div class="section" id="module-pygraph.utils">
- <span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-pygraph.utils" title="Permalink to this headline">¶</a></h2>
- <p>Pygraph - utils module</p>
- <dl class="docutils">
- <dt>Implement some methods to manage graphs</dt>
- <dd>graphfiles.py : load .gxl and .ct files
- utils.py : compute some properties on networkX graphs</dd>
- </dl>
- </div>
- </div>
-
-
- </div>
-
- </div>
- <footer>
-
-
- <hr/>
-
- <div role="contentinfo">
- <p>
- © Copyright 2020, Linlin Jia
-
- </p>
- </div>
- Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
-
- </footer>
-
- </div>
- </div>
-
- </section>
-
- </div>
-
-
-
- <script type="text/javascript">
- jQuery(function () {
- SphinxRtdTheme.Navigation.enable(true);
- });
- </script>
-
-
-
-
-
-
- </body>
- </html>
|