1
0
Fork 0

Refactor AbstractImporter constructor to accept concatenated_samples dataframe/matrix

better_develop
Filippo Martini 4 years ago
parent 4624070877
commit b54b2edf7a
  1. 0
      .nojekyll
  2. 44
      PyCTBN/classes/abstract_importer.py
  3. 13
      PyCTBN/classes/sample_path.py
  4. 3
      PyCTBN/classes/structure_estimator.py
  5. 6
      PyCTBN/classes/trajectory.py
  6. 67
      docs/classes.html
  7. 13
      docs/genindex.html
  8. BIN
      docs/objects.inv
  9. 2
      docs/searchindex.js
  10. 2
      examples/simple_cvs_importer.py
  11. 3
      setup.py
  12. BIN
      sphinx_output/_build/doctrees/classes.doctree
  13. BIN
      sphinx_output/_build/doctrees/environment.pickle
  14. 67
      sphinx_output/_build/html/classes.html
  15. 13
      sphinx_output/_build/html/genindex.html
  16. BIN
      sphinx_output/_build/html/objects.inv
  17. 2
      sphinx_output/_build/html/searchindex.js

@ -2,39 +2,43 @@
import typing
from abc import ABC, abstractmethod
import numpy as np
import pandas as pd
class AbstractImporter(ABC):
"""Abstract class that exposes all the necessary methods to process the trajectories and the net structure.
:param file_path: the file path
:param file_path: the file path, or dataset name if you import already processed data
:type file_path: str
:_concatenated_samples: Dataframe containing the concatenation of all the processed trajectories
:_df_structure: Dataframe containing the structure of the network (edges)
:_df_variables: Dataframe containing the nodes cardinalities
:_sorter: A list containing the columns header (excluding the time column) of the ``_concatenated_samples``
:param concatenated_samples: Dataframe or numpy array containing the concatenation of all the processed trajectories
:type concatenated_samples: typing.Union[pandas.DataFrame, numpy.ndarray]
:param variables: Dataframe containing the nodes labels and cardinalities
:type variables: pandas.DataFrame
:prior_net_structure: Dataframe containing the structure of the network (edges)
:type prior_net_structure: pandas.DataFrame
:_sorter: A list containing the variables labels in the SAME order as the columns in ``concatenated_samples``
.. warning::
The class members ``_df_variables`` and ``_df_structure`` HAVE to be properly constructed
The parameters ``variables`` and ``prior_net_structure`` 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]
See the tutorial on how to construct a correct ``concatenated_samples`` Dataframe/ndarray.
.. note::
If you don't have prior network structure just leave ``_df_structure`` set to None.
.. note::
See :class:``JsonImporter`` for an example implementation
"""
def __init__(self, file_path: str):
def __init__(self, file_path: str = None, concatenated_samples: typing.Union[pd.DataFrame, np.ndarray] = None,
variables: pd.DataFrame = None, prior_net_structure: pd.DataFrame = None):
"""Constructor
"""
self._file_path = file_path
self._df_variables = None
self._df_structure = None
self._concatenated_samples = None
self._concatenated_samples = concatenated_samples
self._df_variables = variables
self._df_structure = prior_net_structure
self._sorter = None
super().__init__()
@ -104,20 +108,26 @@ class AbstractImporter(ABC):
complete_header.extend(shifted_cols_header)
self._concatenated_samples = self._concatenated_samples[complete_header]
def build_list_of_samples_array(self, data_frame: pd.DataFrame) -> typing.List:
"""Builds a List containing the columns of data_frame and converts them to a numpy array.
def build_list_of_samples_array(self, concatenated_sample: typing.Union[pd.DataFrame, np.ndarray]) -> typing.List:
"""Builds a List containing the the delta times numpy array, and the complete transitions matrix
:param data_frame: the dataframe from which the columns have to be extracted and converted
:type data_frame: pandas.Dataframe
:param concatenated_sample: the dataframe/array from which the time, and transitions matrix have to be extracted
and converted
:type concatenated_sample: typing.Union[pandas.Dataframe, numpy.ndarray]
:return: the resulting list of numpy arrays
:rtype: List
"""
columns_list = [data_frame[column].to_numpy() for column in data_frame]
if isinstance(concatenated_sample, pd.DataFrame):
concatenated_array = concatenated_sample.to_numpy()
columns_list = [concatenated_array[:, 0], concatenated_array[:, 1:].astype(int)]
else:
columns_list = [concatenated_sample[:, 0], concatenated_sample[:, 1:].astype(int)]
return columns_list
def clear_concatenated_frame(self) -> None:
"""Removes all values in the dataframe concatenated_samples.
"""
if isinstance(self._concatenated_samples, pd.DataFrame):
self._concatenated_samples = self._concatenated_samples.iloc[0:0]
@abstractmethod

@ -1,4 +1,7 @@
import numpy as np
import pandas as pd
from .abstract_importer import AbstractImporter
from .structure import Structure
from .trajectory import Trajectory
@ -19,9 +22,15 @@ class SamplePath(object):
"""Constructor Method
"""
self._importer = importer
if (self._importer._df_variables is None or self._importer._concatenated_samples is None):
if self._importer._df_variables is None or self._importer._concatenated_samples is None:
raise RuntimeError('The importer object has to contain the all processed data!')
if self._importer._df_variables.empty:
raise RuntimeError('The importer object has to contain the all processed data!')
if isinstance(self._importer._concatenated_samples, pd.DataFrame):
if self._importer._concatenated_samples.empty:
raise RuntimeError('The importer object has to contain the all processed data!')
if(self._importer._df_variables.empty or self._importer._concatenated_samples.empty):
if isinstance(self._importer._concatenated_samples, np.ndarray):
if self._importer._concatenated_samples.size == 0:
raise RuntimeError('The importer object has to contain the all processed data!')
self._trajectories = None
self._structure = None

@ -259,6 +259,7 @@ class StructureEstimator(object):
graph_to_draw = nx.DiGraph()
spurious_edges = self.spurious_edges()
non_spurious_edges = list(set(self._complete_graph.edges) - set(spurious_edges))
print(non_spurious_edges)
edges_colors = ['red' if edge in spurious_edges else 'black' for edge in self._complete_graph.edges]
graph_to_draw.add_edges_from(spurious_edges)
graph_to_draw.add_edges_from(non_spurious_edges)
@ -270,7 +271,7 @@ class StructureEstimator(object):
'linewidths':2,
"with_labels":True,
"font_size":13,
'connectionstyle': 'arc3, rad = 0.',
'connectionstyle': 'arc3, rad = 0.1',
"arrowsize": 15,
"arrowstyle": '<|-',
"width": 1,

@ -19,11 +19,9 @@ class Trajectory(object):
def __init__(self, list_of_columns: typing.List, original_cols_number: int):
"""Constructor Method
"""
if type(list_of_columns[0][0]) != np.float64:
raise TypeError('The first array in the list has to be Times')
self._times = list_of_columns[0]
self._actual_trajectory = list_of_columns[1]
self._original_cols_number = original_cols_number
self._actual_trajectory = np.array(list_of_columns[1:], dtype=np.int).T
self._times = np.array(list_of_columns[0], dtype=np.float)
@property
def trajectory(self) -> np.ndarray:

@ -134,36 +134,31 @@
<span id="classes-abstract-importer-module"></span><h2>classes.abstract_importer module<a class="headerlink" href="#module-classes.abstract_importer" title="Permalink to this headline"></a></h2>
<dl class="py class">
<dt id="classes.abstract_importer.AbstractImporter">
<em class="property">class </em><code class="sig-prename descclassname">classes.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="#classes.abstract_importer.AbstractImporter" title="Permalink to this definition"></a></dt>
<em class="property">class </em><code class="sig-prename descclassname">classes.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> <span class="o">=</span> <span class="default_value">None</span></em>, <em class="sig-param"><span class="n">concatenated_samples</span><span class="p">:</span> <span class="n">Union<span class="p">[</span>pandas.core.frame.DataFrame<span class="p">, </span>numpy.ndarray<span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em>, <em class="sig-param"><span class="n">variables</span><span class="p">:</span> <span class="n">pandas.core.frame.DataFrame</span> <span class="o">=</span> <span class="default_value">None</span></em>, <em class="sig-param"><span class="n">prior_net_structure</span><span class="p">:</span> <span class="n">pandas.core.frame.DataFrame</span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span><a class="headerlink" href="#classes.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 class="field-odd"><ul class="simple">
<li><p><strong>file_path</strong> (<em>str</em>) – the file path, or dataset name if you import already processed data</p></li>
<li><p><strong>concatenated_samples</strong> (<em>typing.Union</em><em>[</em><em>pandas.DataFrame</em><em>, </em><em>numpy.ndarray</em><em>]</em>) – Dataframe or numpy array containing the concatenation of all the processed trajectories</p></li>
<li><p><strong>variables</strong> (<em>pandas.DataFrame</em>) – Dataframe containing the nodes labels and cardinalities</p></li>
</ul>
</dd>
<dt class="field-even">_df_variables</dt>
<dd class="field-even"><p>Dataframe containing the nodes cardinalities</p>
<dt class="field-even">Prior_net_structure</dt>
<dd class="field-even"><p>Dataframe containing the structure of the network (edges)</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 <code class="docutils literal notranslate"><span class="pre">_concatenated_samples</span></code></p>
<dd class="field-odd"><p>A list containing the variables labels in the SAME order as the columns in <code class="docutils literal notranslate"><span class="pre">concatenated_samples</span></code></p>
</dd>
</dl>
<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
<p>The parameters <code class="docutils literal notranslate"><span class="pre">variables</span></code> and <code class="docutils literal notranslate"><span class="pre">prior_net_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>If you don’t have prior network structure just leave <code class="docutils literal notranslate"><span class="pre">_df_structure</span></code> set to None.</p>
Header of _df_variables = [Variable_Label | Variable_Cardinality]
See the tutorial on how to construct a correct <code class="docutils literal notranslate"><span class="pre">concatenated_samples</span></code> Dataframe/ndarray.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
@ -171,11 +166,12 @@ Header of _df_variables = [Variable_Label | Variable_Cardinality]</p>
</div>
<dl class="py method">
<dt id="classes.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="#classes.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>
<code class="sig-name descname">build_list_of_samples_array</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">concatenated_sample</span><span class="p">:</span> <span class="n">Union<span class="p">[</span>pandas.core.frame.DataFrame<span class="p">, </span>numpy.ndarray<span class="p">]</span></span></em><span class="sig-paren">)</span> &#x2192; List<a class="headerlink" href="#classes.abstract_importer.AbstractImporter.build_list_of_samples_array" title="Permalink to this definition"></a></dt>
<dd><p>Builds a List containing the the delta times numpy array, and the complete transitions matrix</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 class="field-odd"><p><strong>concatenated_sample</strong> (<em>typing.Union</em><em>[</em><em>pandas.Dataframe</em><em>, </em><em>numpy.ndarray</em><em>]</em>) – the dataframe/array from which the time, and transitions matrix 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>
@ -981,6 +977,11 @@ contain the mentioned data.</p>
Clears all the unused dataframes in <code class="docutils literal notranslate"><span class="pre">_importer</span></code> Object</p>
</dd></dl>
<dl class="py method">
<dt id="classes.sample_path.SamplePath.has_prior_net_structure">
<em class="property">property </em><code class="sig-name descname">has_prior_net_structure</code><a class="headerlink" href="#classes.sample_path.SamplePath.has_prior_net_structure" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="classes.sample_path.SamplePath.structure">
<em class="property">property </em><code class="sig-name descname">structure</code><a class="headerlink" href="#classes.sample_path.SamplePath.structure" title="Permalink to this definition"></a></dt>
@ -1228,7 +1229,7 @@ The class member <code class="docutils literal notranslate"><span class="pre">_t
<dl class="py method">
<dt id="classes.structure_estimator.StructureEstimator.adjacency_matrix">
<code class="sig-name descname">adjacency_matrix</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; numpy.ndarray<a class="headerlink" href="#classes.structure_estimator.StructureEstimator.adjacency_matrix" title="Permalink to this definition"></a></dt>
<dd><p>Converts the estimated structrure <code class="docutils literal notranslate"><span class="pre">_complete_graph</span></code> to a boolean adjacency matrix representation.</p>
<dd><p>Converts the estimated structure <code class="docutils literal notranslate"><span class="pre">_complete_graph</span></code> to a boolean adjacency matrix representation.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The adjacency matrix of the graph <code class="docutils literal notranslate"><span class="pre">_complete_graph</span></code></p>
@ -1343,6 +1344,13 @@ it is performed also the chi_test.</p>
</dl>
</dd></dl>
<dl class="py method">
<dt id="classes.structure_estimator.StructureEstimator.save_plot_estimated_structure_graph">
<code class="sig-name descname">save_plot_estimated_structure_graph</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#classes.structure_estimator.StructureEstimator.save_plot_estimated_structure_graph" title="Permalink to this definition"></a></dt>
<dd><p>Plot the estimated structure in a graphical model style.
Spurious edges are colored in red.</p>
</dd></dl>
<dl class="py method">
<dt id="classes.structure_estimator.StructureEstimator.save_results">
<code class="sig-name descname">save_results</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#classes.structure_estimator.StructureEstimator.save_results" title="Permalink to this definition"></a></dt>
@ -1350,6 +1358,23 @@ it is performed also the chi_test.</p>
The file is named as the input dataset but the <cite>results_</cite> word is appended to the results file.</p>
</dd></dl>
<dl class="py method">
<dt id="classes.structure_estimator.StructureEstimator.spurious_edges">
<code class="sig-name descname">spurious_edges</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; List<a class="headerlink" href="#classes.structure_estimator.StructureEstimator.spurious_edges" title="Permalink to this definition"></a></dt>
<dd><dl class="simple">
<dt>Return the spurious edges present in the estimated structure, if a prior net structure is present in</dt><dd><p><code class="docutils literal notranslate"><span class="pre">_sample_path.structure</span></code>.</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A list containing the spurious edges</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>List</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</div>

@ -134,6 +134,7 @@
| <a href="#E"><strong>E</strong></a>
| <a href="#F"><strong>F</strong></a>
| <a href="#G"><strong>G</strong></a>
| <a href="#H"><strong>H</strong></a>
| <a href="#I"><strong>I</strong></a>
| <a href="#J"><strong>J</strong></a>
| <a href="#M"><strong>M</strong></a>
@ -406,6 +407,14 @@
</ul></td>
</tr></table>
<h2 id="H">H</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="classes.html#classes.sample_path.SamplePath.has_prior_net_structure">has_prior_net_structure() (classes.sample_path.SamplePath property)</a>
</li>
</ul></td>
</tr></table>
<h2 id="I">I</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
@ -547,6 +556,8 @@
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="classes.html#classes.sample_path.SamplePath">SamplePath (class in classes.sample_path)</a>
</li>
<li><a href="classes.html#classes.structure_estimator.StructureEstimator.save_plot_estimated_structure_graph">save_plot_estimated_structure_graph() (classes.structure_estimator.StructureEstimator method)</a>
</li>
<li><a href="classes.html#classes.structure_estimator.StructureEstimator.save_results">save_results() (classes.structure_estimator.StructureEstimator method)</a>
</li>
@ -558,6 +569,8 @@
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="classes.html#classes.structure_estimator.StructureEstimator.spurious_edges">spurious_edges() (classes.structure_estimator.StructureEstimator method)</a>
</li>
<li><a href="classes.html#classes.conditional_intensity_matrix.ConditionalIntensityMatrix.state_residence_times">state_residence_times() (classes.conditional_intensity_matrix.ConditionalIntensityMatrix property)</a>
</li>
<li><a href="classes.html#classes.conditional_intensity_matrix.ConditionalIntensityMatrix.state_transition_matrix">state_transition_matrix() (classes.conditional_intensity_matrix.ConditionalIntensityMatrix property)</a>

Binary file not shown.

File diff suppressed because one or more lines are too long

@ -44,7 +44,7 @@ class CSVImporter(AbstractImporter):
def main():
read_files = glob.glob(os.path.join('../../data', "*.csv"))
read_files = glob.glob(os.path.join('../data', "*.csv"))
print(read_files[0])
csvimp = CSVImporter(read_files[0])
csvimp.import_data()

@ -1,6 +1,5 @@
from setuptools import setup, find_packages
print(find_packages('.', exclude=['PyCTBN.tests']))
setup(name='PyCTBN',
version='1.0',
@ -12,7 +11,7 @@ setup(name='PyCTBN',
packages=find_packages('.', exclude=['PyCTBN.tests']),
#packages=['PyCTBN.classes'],
install_requires=[
'numpy', 'pandas', 'networkx', 'scipy', 'tqdm'],
'numpy', 'pandas', 'networkx', 'scipy', 'matplotlib', 'tqdm'],
dependency_links=['https://github.com/numpy/numpy', 'https://github.com/pandas-dev/pandas',
'https://github.com/networkx/networkx', 'https://github.com/scipy/scipy',
'https://github.com/tqdm/tqdm'],

@ -134,36 +134,31 @@
<span id="classes-abstract-importer-module"></span><h2>classes.abstract_importer module<a class="headerlink" href="#module-classes.abstract_importer" title="Permalink to this headline"></a></h2>
<dl class="py class">
<dt id="classes.abstract_importer.AbstractImporter">
<em class="property">class </em><code class="sig-prename descclassname">classes.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="#classes.abstract_importer.AbstractImporter" title="Permalink to this definition"></a></dt>
<em class="property">class </em><code class="sig-prename descclassname">classes.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> <span class="o">=</span> <span class="default_value">None</span></em>, <em class="sig-param"><span class="n">concatenated_samples</span><span class="p">:</span> <span class="n">Union<span class="p">[</span>pandas.core.frame.DataFrame<span class="p">, </span>numpy.ndarray<span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em>, <em class="sig-param"><span class="n">variables</span><span class="p">:</span> <span class="n">pandas.core.frame.DataFrame</span> <span class="o">=</span> <span class="default_value">None</span></em>, <em class="sig-param"><span class="n">prior_net_structure</span><span class="p">:</span> <span class="n">pandas.core.frame.DataFrame</span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span><a class="headerlink" href="#classes.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 class="field-odd"><ul class="simple">
<li><p><strong>file_path</strong> (<em>str</em>) – the file path, or dataset name if you import already processed data</p></li>
<li><p><strong>concatenated_samples</strong> (<em>typing.Union</em><em>[</em><em>pandas.DataFrame</em><em>, </em><em>numpy.ndarray</em><em>]</em>) – Dataframe or numpy array containing the concatenation of all the processed trajectories</p></li>
<li><p><strong>variables</strong> (<em>pandas.DataFrame</em>) – Dataframe containing the nodes labels and cardinalities</p></li>
</ul>
</dd>
<dt class="field-even">_df_variables</dt>
<dd class="field-even"><p>Dataframe containing the nodes cardinalities</p>
<dt class="field-even">Prior_net_structure</dt>
<dd class="field-even"><p>Dataframe containing the structure of the network (edges)</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 <code class="docutils literal notranslate"><span class="pre">_concatenated_samples</span></code></p>
<dd class="field-odd"><p>A list containing the variables labels in the SAME order as the columns in <code class="docutils literal notranslate"><span class="pre">concatenated_samples</span></code></p>
</dd>
</dl>
<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
<p>The parameters <code class="docutils literal notranslate"><span class="pre">variables</span></code> and <code class="docutils literal notranslate"><span class="pre">prior_net_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>If you don’t have prior network structure just leave <code class="docutils literal notranslate"><span class="pre">_df_structure</span></code> set to None.</p>
Header of _df_variables = [Variable_Label | Variable_Cardinality]
See the tutorial on how to construct a correct <code class="docutils literal notranslate"><span class="pre">concatenated_samples</span></code> Dataframe/ndarray.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
@ -171,11 +166,12 @@ Header of _df_variables = [Variable_Label | Variable_Cardinality]</p>
</div>
<dl class="py method">
<dt id="classes.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="#classes.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>
<code class="sig-name descname">build_list_of_samples_array</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">concatenated_sample</span><span class="p">:</span> <span class="n">Union<span class="p">[</span>pandas.core.frame.DataFrame<span class="p">, </span>numpy.ndarray<span class="p">]</span></span></em><span class="sig-paren">)</span> &#x2192; List<a class="headerlink" href="#classes.abstract_importer.AbstractImporter.build_list_of_samples_array" title="Permalink to this definition"></a></dt>
<dd><p>Builds a List containing the the delta times numpy array, and the complete transitions matrix</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 class="field-odd"><p><strong>concatenated_sample</strong> (<em>typing.Union</em><em>[</em><em>pandas.Dataframe</em><em>, </em><em>numpy.ndarray</em><em>]</em>) – the dataframe/array from which the time, and transitions matrix 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>
@ -981,6 +977,11 @@ contain the mentioned data.</p>
Clears all the unused dataframes in <code class="docutils literal notranslate"><span class="pre">_importer</span></code> Object</p>
</dd></dl>
<dl class="py method">
<dt id="classes.sample_path.SamplePath.has_prior_net_structure">
<em class="property">property </em><code class="sig-name descname">has_prior_net_structure</code><a class="headerlink" href="#classes.sample_path.SamplePath.has_prior_net_structure" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="classes.sample_path.SamplePath.structure">
<em class="property">property </em><code class="sig-name descname">structure</code><a class="headerlink" href="#classes.sample_path.SamplePath.structure" title="Permalink to this definition"></a></dt>
@ -1228,7 +1229,7 @@ The class member <code class="docutils literal notranslate"><span class="pre">_t
<dl class="py method">
<dt id="classes.structure_estimator.StructureEstimator.adjacency_matrix">
<code class="sig-name descname">adjacency_matrix</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; numpy.ndarray<a class="headerlink" href="#classes.structure_estimator.StructureEstimator.adjacency_matrix" title="Permalink to this definition"></a></dt>
<dd><p>Converts the estimated structrure <code class="docutils literal notranslate"><span class="pre">_complete_graph</span></code> to a boolean adjacency matrix representation.</p>
<dd><p>Converts the estimated structure <code class="docutils literal notranslate"><span class="pre">_complete_graph</span></code> to a boolean adjacency matrix representation.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The adjacency matrix of the graph <code class="docutils literal notranslate"><span class="pre">_complete_graph</span></code></p>
@ -1343,6 +1344,13 @@ it is performed also the chi_test.</p>
</dl>
</dd></dl>
<dl class="py method">
<dt id="classes.structure_estimator.StructureEstimator.save_plot_estimated_structure_graph">
<code class="sig-name descname">save_plot_estimated_structure_graph</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#classes.structure_estimator.StructureEstimator.save_plot_estimated_structure_graph" title="Permalink to this definition"></a></dt>
<dd><p>Plot the estimated structure in a graphical model style.
Spurious edges are colored in red.</p>
</dd></dl>
<dl class="py method">
<dt id="classes.structure_estimator.StructureEstimator.save_results">
<code class="sig-name descname">save_results</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#classes.structure_estimator.StructureEstimator.save_results" title="Permalink to this definition"></a></dt>
@ -1350,6 +1358,23 @@ it is performed also the chi_test.</p>
The file is named as the input dataset but the <cite>results_</cite> word is appended to the results file.</p>
</dd></dl>
<dl class="py method">
<dt id="classes.structure_estimator.StructureEstimator.spurious_edges">
<code class="sig-name descname">spurious_edges</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; List<a class="headerlink" href="#classes.structure_estimator.StructureEstimator.spurious_edges" title="Permalink to this definition"></a></dt>
<dd><dl class="simple">
<dt>Return the spurious edges present in the estimated structure, if a prior net structure is present in</dt><dd><p><code class="docutils literal notranslate"><span class="pre">_sample_path.structure</span></code>.</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A list containing the spurious edges</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>List</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</div>

@ -134,6 +134,7 @@
| <a href="#E"><strong>E</strong></a>
| <a href="#F"><strong>F</strong></a>
| <a href="#G"><strong>G</strong></a>
| <a href="#H"><strong>H</strong></a>
| <a href="#I"><strong>I</strong></a>
| <a href="#J"><strong>J</strong></a>
| <a href="#M"><strong>M</strong></a>
@ -406,6 +407,14 @@
</ul></td>
</tr></table>
<h2 id="H">H</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="classes.html#classes.sample_path.SamplePath.has_prior_net_structure">has_prior_net_structure() (classes.sample_path.SamplePath property)</a>
</li>
</ul></td>
</tr></table>
<h2 id="I">I</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
@ -547,6 +556,8 @@
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="classes.html#classes.sample_path.SamplePath">SamplePath (class in classes.sample_path)</a>
</li>
<li><a href="classes.html#classes.structure_estimator.StructureEstimator.save_plot_estimated_structure_graph">save_plot_estimated_structure_graph() (classes.structure_estimator.StructureEstimator method)</a>
</li>
<li><a href="classes.html#classes.structure_estimator.StructureEstimator.save_results">save_results() (classes.structure_estimator.StructureEstimator method)</a>
</li>
@ -558,6 +569,8 @@
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="classes.html#classes.structure_estimator.StructureEstimator.spurious_edges">spurious_edges() (classes.structure_estimator.StructureEstimator method)</a>
</li>
<li><a href="classes.html#classes.conditional_intensity_matrix.ConditionalIntensityMatrix.state_residence_times">state_residence_times() (classes.conditional_intensity_matrix.ConditionalIntensityMatrix property)</a>
</li>
<li><a href="classes.html#classes.conditional_intensity_matrix.ConditionalIntensityMatrix.state_transition_matrix">state_transition_matrix() (classes.conditional_intensity_matrix.ConditionalIntensityMatrix property)</a>

File diff suppressed because one or more lines are too long