1
0
Fork 0
Old engine for Continuous Time Bayesian Networks. Superseded by reCTBN. 🐍 https://github.com/madlabunimib/PyCTBN
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
PyCTBN/documentation/_build/html/rst/abstract_importer.html

333 lines
16 KiB

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xml:lang="" lang="" version="-//W3C//DTD XHTML 1.1//EN" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>abstract_importer module &mdash; PyCTBN documentation</title>
<link href='https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'/>
<link rel="stylesheet" href="../_static/css/pdj.css" type="text/css" />
<link rel="index" title="Index"
href="../genindex.html"/>
<link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="PyCTBN documentation" href="../index.html"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="cache-control" content="public" />
<meta name="robots" content="follow, all" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Add jQuery library -->
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-nav-search">
<a href="../index.html" class="fa fa-home"> PyCTBN </a>
<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="#">abstract_importer module</a></li>
</ul>
</div>
</div>
&nbsp;
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" id="barra-mobile" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="#">Porão do Juca</a>
</nav>
<div class="wy-nav-content">
<div class="fundo-claro">
</div>
<div class="fundo-escuro">
</div>
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<!-- <ul class="wy-breadcrumbs"> -->
<!-- <li><a href="#">Docs</a> &raquo;</li> -->
<!-- <li>Features</li> -->
<!-- <li class="wy-breadcrumbs-aside"> -->
<!-- <a href="_sources/index.txt" rel="nofollow"> View page source</a> -->
<!-- </li> -->
<!-- </ul> -->
<!-- <hr/> -->
</div>
<div role="main" class="">
<div id="content" class="hfeed entry-container hentry">
<div class="section" id="module-abstract_importer">
<span id="abstract-importer-module"></span><h1>abstract_importer module<a class="headerlink" href="#module-abstract_importer" title="Permalink to this headline"></a></h1>
<dl class="py class">
<dt id="abstract_importer.AbstractImporter">
<em class="property">class </em><code class="sig-prename descclassname">abstract_importer.</code><code class="sig-name descname">AbstractImporter</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">file_path</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span><a class="headerlink" href="#abstract_importer.AbstractImporter" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">abc.ABC</span></code></p>
<p>Abstract class that exposes all the necessary methods to process the trajectories and the net structure.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>file_path</strong> (<em>str</em>) – the file path</p>
</dd>
<dt class="field-even">_concatenated_samples</dt>
<dd class="field-even"><p>Dataframe containing the concatenation of all the processed trajectories</p>
</dd>
<dt class="field-odd">_df_structure</dt>
<dd class="field-odd"><p>Dataframe containing the structure of the network (edges)</p>
</dd>
<dt class="field-even">_df_variables</dt>
<dd class="field-even"><p>Dataframe containing the nodes cardinalities</p>
</dd>
<dt class="field-odd">_sorter</dt>
<dd class="field-odd"><p>A list containing the columns header (excluding the time column) of the <cite>_concatenated_samples</cite></p>
</dd>
</dl>
<dl class="py method">
<dt id="abstract_importer.AbstractImporter.build_list_of_samples_array">
<code class="sig-name descname">build_list_of_samples_array</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">data_frame</span><span class="p">:</span> <span class="n">pandas.core.frame.DataFrame</span></em><span class="sig-paren">)</span> &#x2192; List<a class="headerlink" href="#abstract_importer.AbstractImporter.build_list_of_samples_array" title="Permalink to this definition"></a></dt>
<dd><p>Builds a List containing the columns of data_frame and converts them to a numpy array.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>data_frame</strong> (<em>pandas.Dataframe</em>) – the dataframe from which the columns have to be extracted and converted</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>the resulting list of numpy arrays</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>List</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="abstract_importer.AbstractImporter.build_sorter">
<em class="property">abstract </em><code class="sig-name descname">build_sorter</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">sample_frame</span><span class="p">:</span> <span class="n">pandas.core.frame.DataFrame</span></em><span class="sig-paren">)</span> &#x2192; List<a class="headerlink" href="#abstract_importer.AbstractImporter.build_sorter" title="Permalink to this definition"></a></dt>
<dd><p>Initializes the <code class="docutils literal notranslate"><span class="pre">_sorter</span></code> class member from a trajectory dataframe, exctracting the header of the frame
and keeping ONLY the variables symbolic labels, cutting out the time label in the header.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>sample_frame</strong> (<em>pandas.DataFrame</em>) – The dataframe from which extract the header</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A list containing the processed header.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>List</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="abstract_importer.AbstractImporter.clear_concatenated_frame">
<code class="sig-name descname">clear_concatenated_frame</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#abstract_importer.AbstractImporter.clear_concatenated_frame" title="Permalink to this definition"></a></dt>
<dd><p>Removes all values in the dataframe concatenated_samples.</p>
</dd></dl>
<dl class="py method">
<dt id="abstract_importer.AbstractImporter.compute_row_delta_in_all_samples_frames">
<code class="sig-name descname">compute_row_delta_in_all_samples_frames</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">df_samples_list</span><span class="p">:</span> <span class="n">List</span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#abstract_importer.AbstractImporter.compute_row_delta_in_all_samples_frames" title="Permalink to this definition"></a></dt>
<dd><p>Calls the method <code class="docutils literal notranslate"><span class="pre">compute_row_delta_sigle_samples_frame</span></code> on every dataframe present in the list
<code class="docutils literal notranslate"><span class="pre">df_samples_list</span></code>.
Concatenates the result in the dataframe <code class="docutils literal notranslate"><span class="pre">concatanated_samples</span></code></p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>df_samples_list</strong> (<em>List</em>) – the datframe’s list to be processed and concatenated</p>
</dd>
</dl>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>The Dataframe sample_frame has to follow the column structure of this header:
Header of sample_frame = [Time | Variable values]
The class member self._sorter HAS to be properly INITIALIZED (See class members definition doc)</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>After the call of this method the class member <code class="docutils literal notranslate"><span class="pre">concatanated_samples</span></code> will contain all processed
and merged trajectories</p>
</div>
</dd></dl>
<dl class="py method">
<dt id="abstract_importer.AbstractImporter.compute_row_delta_sigle_samples_frame">
<code class="sig-name descname">compute_row_delta_sigle_samples_frame</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">sample_frame</span><span class="p">:</span> <span class="n">pandas.core.frame.DataFrame</span></em>, <em class="sig-param"><span class="n">columns_header</span><span class="p">:</span> <span class="n">List</span></em>, <em class="sig-param"><span class="n">shifted_cols_header</span><span class="p">:</span> <span class="n">List</span></em><span class="sig-paren">)</span> &#x2192; pandas.core.frame.DataFrame<a class="headerlink" href="#abstract_importer.AbstractImporter.compute_row_delta_sigle_samples_frame" title="Permalink to this definition"></a></dt>
<dd><p>Computes the difference between each value present in th time column.
Copies and shift by one position up all the values present in the remaining columns.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>sample_frame</strong> (<em>pandas.Dataframe</em>) – the traj to be processed</p></li>
<li><p><strong>columns_header</strong> (<em>List</em>) – the original header of sample_frame</p></li>
<li><p><strong>shifted_cols_header</strong> (<em>List</em>) – a copy of columns_header with changed names of the contents</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The processed dataframe</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>pandas.Dataframe</p>
</dd>
</dl>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>the Dataframe <code class="docutils literal notranslate"><span class="pre">sample_frame</span></code> has to follow the column structure of this header:
Header of sample_frame = [Time | Variable values]</p>
</div>
</dd></dl>
<dl class="py method">
<dt id="abstract_importer.AbstractImporter.concatenated_samples">
<em class="property">property </em><code class="sig-name descname">concatenated_samples</code><a class="headerlink" href="#abstract_importer.AbstractImporter.concatenated_samples" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="abstract_importer.AbstractImporter.dataset_id">
<em class="property">abstract </em><code class="sig-name descname">dataset_id</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; object<a class="headerlink" href="#abstract_importer.AbstractImporter.dataset_id" title="Permalink to this definition"></a></dt>
<dd><p>If the original dataset contains multiple dataset, this method returns a unique id to identify the current
dataset</p>
</dd></dl>
<dl class="py method">
<dt id="abstract_importer.AbstractImporter.file_path">
<em class="property">property </em><code class="sig-name descname">file_path</code><a class="headerlink" href="#abstract_importer.AbstractImporter.file_path" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="abstract_importer.AbstractImporter.import_data">
<em class="property">abstract </em><code class="sig-name descname">import_data</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#abstract_importer.AbstractImporter.import_data" title="Permalink to this definition"></a></dt>
<dd><p>Imports all the trajectories, variables cardinalities, and net edges.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>The class members <code class="docutils literal notranslate"><span class="pre">_df_variables</span></code> and <code class="docutils literal notranslate"><span class="pre">_df_structure</span></code> HAVE to be properly constructed
as Pandas Dataframes with the following structure:
Header of _df_structure = [From_Node | To_Node]
Header of _df_variables = [Variable_Label | Variable_Cardinality]</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>See :class:<code class="docutils literal notranslate"><span class="pre">JsonImporter</span></code> for an example of implementation of this method.</p>
</div>
</dd></dl>
<dl class="py method">
<dt id="abstract_importer.AbstractImporter.sorter">
<em class="property">property </em><code class="sig-name descname">sorter</code><a class="headerlink" href="#abstract_importer.AbstractImporter.sorter" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="abstract_importer.AbstractImporter.structure">
<em class="property">property </em><code class="sig-name descname">structure</code><a class="headerlink" href="#abstract_importer.AbstractImporter.structure" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="abstract_importer.AbstractImporter.variables">
<em class="property">property </em><code class="sig-name descname">variables</code><a class="headerlink" href="#abstract_importer.AbstractImporter.variables" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2020, Filippo Martini.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/jucacrispim/sphinx_pdj_theme">theme</a> provided by <a href="http://poraodojuca.net">Porão do Juca</a>.
</footer>
</div>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</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 type="text/javascript" src="../_static/language_data.js">
</script>
<script type="text/javascript"
src="../_static/js/theme.js"></script>
<script type="text/javascript"
src="../_static/js/pdj.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>