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.
867 lines
77 KiB
867 lines
77 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>PyCTBN.PyCTBN.estimators package — PyCTBN 2.0 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="stylesheet" href="_static/pygments.css" 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 2.0 documentation" href="index.html"/>
|
|
<link rel="up" title="PyCTBN.PyCTBN package" href="PyCTBN.PyCTBN.html"/>
|
|
<link rel="next" title="PyCTBN.PyCTBN.optimizers package" href="PyCTBN.PyCTBN.optimizers.html"/>
|
|
<link rel="prev" title="PyCTBN.PyCTBN package" href="PyCTBN.PyCTBN.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">
|
|
|
|
|
|
|
|
<p><span class="caption-text">Contents:</span></p>
|
|
<ul class="current">
|
|
<li class="toctree-l1 current"><a class="reference internal" href="PyCTBN.PyCTBN.html">PyCTBN.PyCTBN package</a><ul class="current">
|
|
<li class="toctree-l2 current"><a class="reference internal" href="PyCTBN.PyCTBN.html#subpackages">Subpackages</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="PyCTBN.PyCTBN.html#module-PyCTBN.PyCTBN">Module contents</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a><ul>
|
|
<li class="toctree-l2"><a class="reference internal" href="examples.html#installation-usage">Installation/Usage</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="examples.html#implementing-your-own-data-importer">Implementing your own data importer</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="examples.html#parameters-estimation-example">Parameters Estimation Example</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="examples.html#structure-estimation-example">Structure Estimation Example</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</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> »</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">
|
|
<section id="pyctbn-pyctbn-estimators-package">
|
|
<h1>PyCTBN.PyCTBN.estimators package<a class="headerlink" href="#pyctbn-pyctbn-estimators-package" title="Permalink to this headline">¶</a></h1>
|
|
<section id="submodules">
|
|
<h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline">¶</a></h2>
|
|
</section>
|
|
<section id="module-PyCTBN.PyCTBN.estimators.fam_score_calculator">
|
|
<span id="pyctbn-pyctbn-estimators-fam-score-calculator-module"></span><h2>PyCTBN.PyCTBN.estimators.fam_score_calculator module<a class="headerlink" href="#module-PyCTBN.PyCTBN.estimators.fam_score_calculator" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="py class">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator">
|
|
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">PyCTBN.PyCTBN.estimators.fam_score_calculator.</span></span><span class="sig-name descname"><span class="pre">FamScoreCalculator</span></span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator" 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>
|
|
<p>Has the task of calculating the FamScore of a node by using a Bayesian score function</p>
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.get_fam_score">
|
|
<span class="sig-name descname"><span class="pre">get_fam_score</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cims</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">numpy.array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_xu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">0.1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_xu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.get_fam_score" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Calculate the FamScore value of the node</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>cims</strong> (<em>np.array</em>) – np.array with all the node’s cims</p></li>
|
|
<li><p><strong>tau_xu</strong> (<em>float</em><em>, </em><em>optional</em>) – hyperparameter over the CTBN’s q parameters, default to 0.1</p></li>
|
|
<li><p><strong>alpha_xu</strong> (<em>float</em><em>, </em><em>optional</em>) – hyperparameter over the CTBN’s q parameters, default to 1</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>the FamScore value of the node</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>float</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.marginal_likelihood_q">
|
|
<span class="sig-name descname"><span class="pre">marginal_likelihood_q</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cims</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">numpy.array</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_xu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">0.1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_xu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.marginal_likelihood_q" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Calculate the value of the marginal likelihood over q of the node identified by the label node_id</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>cims</strong> (<em>np.array</em>) – np.array with all the node’s cims</p></li>
|
|
<li><p><strong>tau_xu</strong> (<em>float</em>) – hyperparameter over the CTBN’s q parameters</p></li>
|
|
<li><p><strong>alpha_xu</strong> (<em>float</em>) – hyperparameter over the CTBN’s q parameters</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>the value of the marginal likelihood over q</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>float</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.marginal_likelihood_theta">
|
|
<span class="sig-name descname"><span class="pre">marginal_likelihood_theta</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cims</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix" title="PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix"><span class="pre">PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_xu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_xxu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.marginal_likelihood_theta" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Calculate the FamScore value of the node identified by the label node_id</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>cims</strong> (<em>np.array</em>) – np.array with all the node’s cims</p></li>
|
|
<li><p><strong>alpha_xu</strong> (<em>float</em>) – hyperparameter over the CTBN’s q parameters, default to 0.1</p></li>
|
|
<li><p><strong>alpha_xxu</strong> (<em>float</em>) – distribuited hyperparameter over the CTBN’s theta parameters</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>the value of the marginal likelihood over theta</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>float</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.single_cim_xu_marginal_likelihood_q">
|
|
<span class="sig-name descname"><span class="pre">single_cim_xu_marginal_likelihood_q</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M_xu_suff_stats</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T_xu_suff_stats</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_xu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">0.1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_xu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.single_cim_xu_marginal_likelihood_q" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Calculate the marginal likelihood on q of the node when assumes a specif value
|
|
and a specif parents’s assignment</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>M_xu_suff_stats</strong> – value of the suffucient statistic M[x|u]</p></li>
|
|
<li><p><strong>T_xu_suff_stats</strong> (<em>float</em>) – value of the suffucient statistic T[x|u]</p></li>
|
|
<li><p><strong>cim</strong> (<em>class:'ConditionalIntensityMatrix'</em>) – A conditional_intensity_matrix object with the sufficient statistics</p></li>
|
|
<li><p><strong>tau_xu</strong> (<em>float</em>) – hyperparameter over the CTBN’s q parameters</p></li>
|
|
<li><p><strong>alpha_xu</strong> (<em>float</em>) – hyperparameter over the CTBN’s q parameters</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>the value of the marginal likelihood of the node when assumes a specif value</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>float</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.single_cim_xu_marginal_likelihood_theta">
|
|
<span class="sig-name descname"><span class="pre">single_cim_xu_marginal_likelihood_theta</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cim</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix" title="PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix"><span class="pre">PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_xu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_xxu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.single_cim_xu_marginal_likelihood_theta" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Calculate the marginal likelihood on q of the node when assumes a specif value
|
|
and a specif parents’s assignment</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>cim</strong> (<em>class:'ConditionalIntensityMatrix'</em>) – A conditional_intensity_matrix object with the sufficient statistics</p></li>
|
|
<li><p><strong>alpha_xu</strong> (<em>float</em>) – hyperparameter over the CTBN’s q parameters</p></li>
|
|
<li><p><strong>alpha_xxu</strong> (<em>float</em>) – distribuited hyperparameter over the CTBN’s theta parameters</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>the value of the marginal likelihood over theta when the node assumes a specif value</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>float</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.single_internal_cim_xxu_marginal_likelihood_theta">
|
|
<span class="sig-name descname"><span class="pre">single_internal_cim_xxu_marginal_likelihood_theta</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M_xxu_suff_stats</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_xxu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.single_internal_cim_xxu_marginal_likelihood_theta" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Calculate the second part of the marginal likelihood over theta formula</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>M_xxu_suff_stats</strong> (<em>float</em>) – value of the suffucient statistic M[xx’<a href="#id1"><span class="problematic" id="id2">|</span></a>u]</p></li>
|
|
<li><p><strong>alpha_xxu</strong> (<em>float</em>) – distribuited hyperparameter over the CTBN’s theta parameters</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>the value of the marginal likelihood over theta when the node assumes a specif value</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>float</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.variable_cim_xu_marginal_likelihood_q">
|
|
<span class="sig-name descname"><span class="pre">variable_cim_xu_marginal_likelihood_q</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cim</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix" title="PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix"><span class="pre">PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_xu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">0.1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_xu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.variable_cim_xu_marginal_likelihood_q" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Calculate the value of the marginal likelihood over q given a cim</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>cim</strong> (<em>class:'ConditionalIntensityMatrix'</em>) – A conditional_intensity_matrix object with the sufficient statistics</p></li>
|
|
<li><p><strong>tau_xu</strong> (<em>float</em>) – hyperparameter over the CTBN’s q parameters</p></li>
|
|
<li><p><strong>alpha_xu</strong> (<em>float</em>) – hyperparameter over the CTBN’s q parameters</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>the value of the marginal likelihood over q</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>float</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.variable_cim_xu_marginal_likelihood_theta">
|
|
<span class="sig-name descname"><span class="pre">variable_cim_xu_marginal_likelihood_theta</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cim</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix" title="PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix"><span class="pre">PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_xu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_xxu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.fam_score_calculator.FamScoreCalculator.variable_cim_xu_marginal_likelihood_theta" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Calculate the value of the marginal likelihood over theta given a cim</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>cim</strong> (<em>class:'ConditionalIntensityMatrix'</em>) – A conditional_intensity_matrix object with the sufficient statistics</p></li>
|
|
<li><p><strong>alpha_xu</strong> (<em>float</em>) – hyperparameter over the CTBN’s q parameters, default to 0.1</p></li>
|
|
<li><p><strong>alpha_xxu</strong> (<em>float</em>) – distribuited hyperparameter over the CTBN’s theta parameters</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>the value of the marginal likelihood over theta</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>float</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
</dd></dl>
|
|
|
|
</section>
|
|
<section id="module-PyCTBN.PyCTBN.estimators.parameters_estimator">
|
|
<span id="pyctbn-pyctbn-estimators-parameters-estimator-module"></span><h2>PyCTBN.PyCTBN.estimators.parameters_estimator module<a class="headerlink" href="#module-PyCTBN.PyCTBN.estimators.parameters_estimator" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="py class">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.parameters_estimator.ParametersEstimator">
|
|
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">PyCTBN.PyCTBN.estimators.parameters_estimator.</span></span><span class="sig-name descname"><span class="pre">ParametersEstimator</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">trajectories</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.trajectory.Trajectory" title="PyCTBN.PyCTBN.structure_graph.trajectory.Trajectory"><span class="pre">PyCTBN.PyCTBN.structure_graph.trajectory.Trajectory</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">net_graph</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.network_graph.NetworkGraph" title="PyCTBN.PyCTBN.structure_graph.network_graph.NetworkGraph"><span class="pre">PyCTBN.PyCTBN.structure_graph.network_graph.NetworkGraph</span></a></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.parameters_estimator.ParametersEstimator" 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>
|
|
<p>Has the task of computing the cims of particular node given the trajectories and the net structure
|
|
in the graph <code class="docutils literal notranslate"><span class="pre">_net_graph</span></code>.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>trajectories</strong> (<a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.trajectory.Trajectory" title="PyCTBN.PyCTBN.structure_graph.trajectory.Trajectory"><em>Trajectory</em></a>) – the trajectories</p></li>
|
|
<li><p><strong>net_graph</strong> (<a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.network_graph.NetworkGraph" title="PyCTBN.PyCTBN.structure_graph.network_graph.NetworkGraph"><em>NetworkGraph</em></a>) – the net structure</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">_single_set_of_cims</dt>
|
|
<dd class="field-even"><p>the set of cims object that will hold the cims of the node</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.parameters_estimator.ParametersEstimator.compute_parameters_for_node">
|
|
<span class="sig-name descname"><span class="pre">compute_parameters_for_node</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">node_id</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> → <a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.set_of_cims.SetOfCims" title="PyCTBN.PyCTBN.structure_graph.set_of_cims.SetOfCims"><span class="pre">PyCTBN.PyCTBN.structure_graph.set_of_cims.SetOfCims</span></a><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.parameters_estimator.ParametersEstimator.compute_parameters_for_node" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Compute the CIMS of the node identified by the label <code class="docutils literal notranslate"><span class="pre">node_id</span></code>.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><p><strong>node_id</strong> (<em>string</em>) – the node label</p>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>A SetOfCims object filled with the computed CIMS</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p><a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.set_of_cims.SetOfCims" title="PyCTBN.PyCTBN.structure_graph.set_of_cims.SetOfCims">SetOfCims</a></p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.parameters_estimator.ParametersEstimator.compute_state_res_time_for_node">
|
|
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">compute_state_res_time_for_node</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">times</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">numpy.ndarray</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">trajectory</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">numpy.ndarray</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cols_filter</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">numpy.ndarray</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">scalar_indexes_struct</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">numpy.ndarray</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">numpy.ndarray</span></span></em><span class="sig-paren">)</span> → <span class="pre">None</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.parameters_estimator.ParametersEstimator.compute_state_res_time_for_node" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Compute the state residence times for a node and fill the matrix <code class="docutils literal notranslate"><span class="pre">T</span></code> with the results</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>node_indx</strong> (<em>int</em>) – the index of the node</p></li>
|
|
<li><p><strong>times</strong> (<em>numpy.array</em>) – the times deltas vector</p></li>
|
|
<li><p><strong>trajectory</strong> (<em>numpy.ndArray</em>) – the trajectory</p></li>
|
|
<li><p><strong>cols_filter</strong> (<em>numpy.array</em>) – the columns filtering structure</p></li>
|
|
<li><p><strong>scalar_indexes_struct</strong> (<em>numpy.array</em>) – the indexing structure</p></li>
|
|
<li><p><strong>T</strong> (<em>numpy.ndArray</em>) – the state residence times vectors</p></li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.parameters_estimator.ParametersEstimator.compute_state_transitions_for_a_node">
|
|
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">compute_state_transitions_for_a_node</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">node_indx</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">trajectory</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">numpy.ndarray</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cols_filter</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">numpy.ndarray</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">scalar_indexing</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">numpy.ndarray</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">M</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">numpy.ndarray</span></span></em><span class="sig-paren">)</span> → <span class="pre">None</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.parameters_estimator.ParametersEstimator.compute_state_transitions_for_a_node" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Compute the state residence times for a node and fill the matrices <code class="docutils literal notranslate"><span class="pre">M</span></code> with the results.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>node_indx</strong> (<em>int</em>) – the index of the node</p></li>
|
|
<li><p><strong>trajectory</strong> (<em>numpy.ndArray</em>) – the trajectory</p></li>
|
|
<li><p><strong>cols_filter</strong> (<em>numpy.array</em>) – the columns filtering structure</p></li>
|
|
<li><p><strong>scalar_indexing</strong> (<em>numpy.array</em>) – the indexing structure</p></li>
|
|
<li><p><strong>M</strong> (<em>numpy.ndArray</em>) – the state transitions matrices</p></li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.parameters_estimator.ParametersEstimator.fast_init">
|
|
<span class="sig-name descname"><span class="pre">fast_init</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">node_id</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> → <span class="pre">None</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.parameters_estimator.ParametersEstimator.fast_init" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Initializes all the necessary structures for the parameters estimation for the node <code class="docutils literal notranslate"><span class="pre">node_id</span></code>.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><p><strong>node_id</strong> (<em>string</em>) – the node label</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
</dd></dl>
|
|
|
|
</section>
|
|
<section id="module-PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator">
|
|
<span id="pyctbn-pyctbn-estimators-structure-constraint-based-estimator-module"></span><h2>PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator module<a class="headerlink" href="#module-PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="py class">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator">
|
|
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.</span></span><span class="sig-name descname"><span class="pre">StructureConstraintBasedEstimator</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sample_path</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath" title="PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath"><span class="pre">PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">exp_test_alfa</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">chi_test_alfa</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">known_edges</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">[]</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">thumb_threshold</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">25</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Bases: <a class="reference internal" href="#PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator" title="PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator"><code class="xref py py-class docutils literal notranslate"><span class="pre">PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator</span></code></a></p>
|
|
<p>Has the task of estimating the network structure given the trajectories in samplepath by using a constraint-based approach.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>sample_path</strong> (<a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath" title="PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath"><em>SamplePath</em></a>) – the _sample_path object containing the trajectories and the real structure</p></li>
|
|
<li><p><strong>exp_test_alfa</strong> (<em>float</em>) – the significance level for the exponential Hp test</p></li>
|
|
<li><p><strong>chi_test_alfa</strong> (<em>float</em>) – the significance level for the chi Hp test</p></li>
|
|
<li><p><strong>known_edges</strong> (<em>List</em>) – the prior known edges in the net structure if present</p></li>
|
|
<li><p><strong>thumb_threshold</strong> (<em>int</em>) – the threshold value to consider a valid independence test</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">_nodes</dt>
|
|
<dd class="field-even"><p>the nodes labels</p>
|
|
</dd>
|
|
<dt class="field-odd">_nodes_vals</dt>
|
|
<dd class="field-odd"><p>the nodes cardinalities</p>
|
|
</dd>
|
|
<dt class="field-even">_nodes_indxs</dt>
|
|
<dd class="field-even"><p>the nodes indexes</p>
|
|
</dd>
|
|
<dt class="field-odd">_complete_graph</dt>
|
|
<dd class="field-odd"><p>the complete directed graph built using the nodes labels in <code class="docutils literal notranslate"><span class="pre">_nodes</span></code></p>
|
|
</dd>
|
|
<dt class="field-even">_cache</dt>
|
|
<dd class="field-even"><p>the Cache object</p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator.complete_test">
|
|
<span class="sig-name descname"><span class="pre">complete_test</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">test_parent</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">test_child</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parent_set</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">child_states_numb</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tot_vars_count</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parent_indx</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">child_indx</span></span></em><span class="sig-paren">)</span> → <span class="pre">bool</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator.complete_test" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Performs a complete independence test on the directed graphs G1 = {test_child U parent_set}
|
|
G2 = {G1 U test_parent} (added as an additional parent of the test_child).
|
|
Generates all the necessary structures and datas to perform the tests.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>test_parent</strong> (<em>string</em>) – the node label of the test parent</p></li>
|
|
<li><p><strong>test_child</strong> (<em>string</em>) – the node label of the child</p></li>
|
|
<li><p><strong>parent_set</strong> (<em>List</em>) – the common parent set</p></li>
|
|
<li><p><strong>child_states_numb</strong> (<em>int</em>) – the cardinality of the <code class="docutils literal notranslate"><span class="pre">test_child</span></code></p></li>
|
|
<li><p><strong>tot_vars_count</strong> (<em>int</em>) – the total number of variables in the net</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>True iff test_child and test_parent are independent given the sep_set parent_set. False otherwise</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>bool</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator.compute_thumb_value">
|
|
<span class="sig-name descname"><span class="pre">compute_thumb_value</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parent_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">child_val</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parent_set_vals</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator.compute_thumb_value" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Compute the value to test against the thumb_threshold.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>parent_val</strong> (<em>int</em>) – test parent’s variable cardinality</p></li>
|
|
<li><p><strong>child_val</strong> (<em>int</em>) – test child’s variable cardinality</p></li>
|
|
<li><p><strong>parent_set_vals</strong> (<em>List</em>) – the cardinalities of the nodes in the current sep-set</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>the thumb value for the current independence test</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>int</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
|
|
<dt id="PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator.ctpc_algorithm">
|
|
<code class="sig-name descname">ctpc_algorithm</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">disable_multiprocessing</span><span class="p">:</span> <span class="n">bool</span> <span class="o">=</span> <span class="default_value">False</span></em>, <em class="sig-param"><span class="n">processes_number</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator.ctpc_algorithm" title="Permalink to this definition">¶</a></dt>
|
|
|
|
<dd><p>Compute the CTPC algorithm over the entire net.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>disable_multiprocessing</strong> (<em>Boolean</em><em>, </em><em>optional</em>) – true if you desire to disable the multiprocessing operations, default to False</p></li>
|
|
<li><p><strong>processes_number</strong> – if disable_multiprocessing is false indicates</p></li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
<p>the maximum number of process; if None it will be automatically set, default to None
|
|
:type processes_number: int, optional</p>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
|
|
<dt id="PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator.estimate_structure">
|
|
<code class="sig-name descname">estimate_structure</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">disable_multiprocessing</span><span class="p">:</span> <span class="n">bool</span> <span class="o">=</span> <span class="default_value">False</span></em>, <em class="sig-param"><span class="n">processes_number</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator.estimate_structure" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Compute the constraint-based algorithm to find the optimal structure</p>
|
|
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>disable_multiprocessing</strong> (<em>Boolean</em><em>, </em><em>optional</em>) – true if you desire to disable the multiprocessing operations, default to False</p></li>
|
|
<li><p><strong>processes_number</strong> – if disable_multiprocessing is false indicates</p></li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
<p>the maximum number of process; if None it will be automatically set, default to None
|
|
:type processes_number: int, optional</p>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator.independence_test">
|
|
<span class="sig-name descname"><span class="pre">independence_test</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">child_states_numb</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cim1</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix" title="PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix"><span class="pre">PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">cim2</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix" title="PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix"><span class="pre">PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">thumb_value</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">float</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parent_indx</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">child_indx</span></span></em><span class="sig-paren">)</span> → <span class="pre">bool</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator.independence_test" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Compute the actual independence test using two cims.
|
|
It is performed first the exponential test and if the null hypothesis is not rejected,
|
|
it is performed also the chi_test.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>child_states_numb</strong> (<em>int</em>) – the cardinality of the test child</p></li>
|
|
<li><p><strong>cim1</strong> (<a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix" title="PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix"><em>ConditionalIntensityMatrix</em></a>) – a cim belonging to the graph without test parent</p></li>
|
|
<li><p><strong>cim2</strong> (<a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix" title="PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix"><em>ConditionalIntensityMatrix</em></a>) – a cim belonging to the graph with test parent</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>True iff both tests do NOT reject the null hypothesis of independence. False otherwise.</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>bool</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator.one_iteration_of_CTPC_algorithm">
|
|
<span class="sig-name descname"><span class="pre">one_iteration_of_CTPC_algorithm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">var_id</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tot_vars_count</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> → <span class="pre">List</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_constraint_based_estimator.StructureConstraintBasedEstimator.one_iteration_of_CTPC_algorithm" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Performs an iteration of the CTPC algorithm using the node <code class="docutils literal notranslate"><span class="pre">var_id</span></code> as <code class="docutils literal notranslate"><span class="pre">test_child</span></code>.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><p><strong>var_id</strong> (<em>string</em>) – the node label of the test child</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
</dd></dl>
|
|
|
|
</section>
|
|
<section id="module-PyCTBN.PyCTBN.estimators.structure_estimator">
|
|
<span id="pyctbn-pyctbn-estimators-structure-estimator-module"></span><h2>PyCTBN.PyCTBN.estimators.structure_estimator module<a class="headerlink" href="#module-PyCTBN.PyCTBN.estimators.structure_estimator" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="py class">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator">
|
|
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">PyCTBN.PyCTBN.estimators.structure_estimator.</span></span><span class="sig-name descname"><span class="pre">StructureEstimator</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sample_path</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath" title="PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath"><span class="pre">PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">known_edges</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">List</span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator" 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>
|
|
<p>Has the task of estimating the network structure given the trajectories in <code class="docutils literal notranslate"><span class="pre">samplepath</span></code>.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>sample_path</strong> (<a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath" title="PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath"><em>SamplePath</em></a>) – the _sample_path object containing the trajectories and the real structure</p></li>
|
|
<li><p><strong>known_edges</strong> (<em>List</em>) – the prior known edges in the net structure if present</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">_nodes</dt>
|
|
<dd class="field-even"><p>the nodes labels</p>
|
|
</dd>
|
|
<dt class="field-odd">_nodes_vals</dt>
|
|
<dd class="field-odd"><p>the nodes cardinalities</p>
|
|
</dd>
|
|
<dt class="field-even">_nodes_indxs</dt>
|
|
<dd class="field-even"><p>the nodes indexes</p>
|
|
</dd>
|
|
<dt class="field-odd">_complete_graph</dt>
|
|
<dd class="field-odd"><p>the complete directed graph built using the nodes labels in <code class="docutils literal notranslate"><span class="pre">_nodes</span></code></p>
|
|
</dd>
|
|
</dl>
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.adjacency_matrix">
|
|
<span class="sig-name descname"><span class="pre">adjacency_matrix</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> → <span class="pre">numpy.ndarray</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.adjacency_matrix" title="Permalink to this definition">¶</a></dt>
|
|
<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>
|
|
</dd>
|
|
<dt class="field-even">Return type</dt>
|
|
<dd class="field-even"><p>numpy.ndArray</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.build_complete_graph">
|
|
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">build_complete_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">node_ids</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span></span></em><span class="sig-paren">)</span> → <span class="pre">networkx.classes.digraph.DiGraph</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.build_complete_graph" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Builds a complete directed graph (no self loops) given the nodes labels in the list <code class="docutils literal notranslate"><span class="pre">node_ids</span></code>:</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><p><strong>node_ids</strong> (<em>List</em>) – the list of nodes labels</p>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>a complete Digraph Object</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>networkx.DiGraph</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.build_removable_edges_matrix">
|
|
<span class="sig-name descname"><span class="pre">build_removable_edges_matrix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">known_edges</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.build_removable_edges_matrix" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Builds a boolean matrix who shows if a edge could be removed or not, based on prior knowledge given:</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><p><strong>known_edges</strong> (<em>List</em>) – the list of nodes labels</p>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>a boolean matrix</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>np.ndarray</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.estimate_structure">
|
|
<em class="property"><span class="pre">abstract</span> </em><span class="sig-name descname"><span class="pre">estimate_structure</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> → <span class="pre">List</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.estimate_structure" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Abstract method to estimate the structure</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Returns</dt>
|
|
<dd class="field-odd"><p>List of estimated edges</p>
|
|
</dd>
|
|
<dt class="field-even">Return type</dt>
|
|
<dd class="field-even"><p>Typing.List</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.generate_possible_sub_sets_of_size">
|
|
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">generate_possible_sub_sets_of_size</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">u</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">size</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parent_label</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.generate_possible_sub_sets_of_size" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Creates a list containing all possible subsets of the list <code class="docutils literal notranslate"><span class="pre">u</span></code> of size <code class="docutils literal notranslate"><span class="pre">size</span></code>,
|
|
that do not contains a the node identified by <code class="docutils literal notranslate"><span class="pre">parent_label</span></code>.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>u</strong> (<em>List</em>) – the list of nodes</p></li>
|
|
<li><p><strong>size</strong> (<em>int</em>) – the size of the subsets</p></li>
|
|
<li><p><strong>parent_label</strong> (<em>string</em>) – the node to exclude in the subsets generation</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>an Iterator Object containing a list of lists</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>Iterator</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
|
|
<dt id="PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.save_plot_estimated_structure_graph">
|
|
<code class="sig-name descname">save_plot_estimated_structure_graph</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> → None<a class="headerlink" href="#PyCTBN.PyCTBN.estimators.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, use .png extension.</p>
|
|
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><p><strong>file_path</strong> – path to save the file to</p>
|
|
</dd>
|
|
<dt class="field-even">Type</dt>
|
|
<dd class="field-even"><p>string</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.save_results">
|
|
<span class="sig-name descname"><span class="pre">save_results</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">file_path</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> → <span class="pre">None</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.save_results" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Save the estimated Structure to a .json file in file_path.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><p><strong>file_path</strong> (<em>string</em>) – the path including the file name with .json extension</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator.spurious_edges">
|
|
<span class="sig-name descname"><span class="pre">spurious_edges</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> → <span class="pre">List</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.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>
|
|
|
|
</section>
|
|
<section id="module-PyCTBN.PyCTBN.estimators.structure_score_based_estimator">
|
|
<span id="pyctbn-pyctbn-estimators-structure-score-based-estimator-module"></span><h2>PyCTBN.PyCTBN.estimators.structure_score_based_estimator module<a class="headerlink" href="#module-PyCTBN.PyCTBN.estimators.structure_score_based_estimator" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="py class">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_score_based_estimator.StructureScoreBasedEstimator">
|
|
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">PyCTBN.PyCTBN.estimators.structure_score_based_estimator.</span></span><span class="sig-name descname"><span class="pre">StructureScoreBasedEstimator</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sample_path</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath" title="PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath"><span class="pre">PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">tau_xu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">0.1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha_xu</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">known_edges</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">List</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">[]</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_score_based_estimator.StructureScoreBasedEstimator" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Bases: <a class="reference internal" href="#PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator" title="PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator"><code class="xref py py-class docutils literal notranslate"><span class="pre">PyCTBN.PyCTBN.estimators.structure_estimator.StructureEstimator</span></code></a></p>
|
|
<p>Has the task of estimating the network structure given the trajectories in samplepath by
|
|
using a score based approach and differt kinds of optimization algorithms.</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>sample_path</strong> (<a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath" title="PyCTBN.PyCTBN.structure_graph.sample_path.SamplePath"><em>SamplePath</em></a>) – the _sample_path object containing the trajectories and the real structure</p></li>
|
|
<li><p><strong>tau_xu</strong> (<em>float</em><em>, </em><em>optional</em>) – hyperparameter over the CTBN’s q parameters, default to 0.1</p></li>
|
|
<li><p><strong>alpha_xu</strong> (<em>float</em><em>, </em><em>optional</em>) – hyperparameter over the CTBN’s q parameters, default to 1</p></li>
|
|
<li><p><strong>known_edges</strong> (<em>List</em><em>, </em><em>optional</em>) – List of known edges, default to []</p></li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_score_based_estimator.StructureScoreBasedEstimator.estimate_parents">
|
|
<span class="sig-name descname"><span class="pre">estimate_parents</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">node_id</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_parents</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">iterations_number</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">40</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">patience</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tabu_length</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tabu_rules_duration</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">optimizer</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">'hill'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_score_based_estimator.StructureScoreBasedEstimator.estimate_parents" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Use the FamScore of a node in order to find the best parent nodes</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>node_id</strong> (<em>string</em>) – current node’s id</p></li>
|
|
<li><p><strong>max_parents</strong> (<em>int</em><em>, </em><em>optional</em>) – maximum number of parents for each variable. If None, disabled, default to None</p></li>
|
|
<li><p><strong>iterations_number</strong> (<em>int</em><em>, </em><em>optional</em>) – maximum number of optimization algorithm’s iteration, default to 40</p></li>
|
|
<li><p><strong>patience</strong> (<em>int</em><em>, </em><em>optional</em>) – number of iteration without any improvement before to stop the search.If None, disabled, default to None</p></li>
|
|
<li><p><strong>tabu_length</strong> (<em>int</em><em>, </em><em>optional</em>) – maximum lenght of the data structures used in the optimization process, default to None</p></li>
|
|
<li><p><strong>tabu_rules_duration</strong> (<em>int</em><em>, </em><em>optional</em>) – number of iterations in which each rule keeps its value, default to None</p></li>
|
|
<li><p><strong>optimizer</strong> (<em>string</em><em>, </em><em>optional</em>) – name of the optimizer algorithm. Possible values: ‘hill’ (Hill climbing),’tabu’ (tabu search), defualt to ‘tabu’</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>A list of the best edges for the currente node</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="PyCTBN.PyCTBN.estimators.structure_score_based_estimator.StructureScoreBasedEstimator.estimate_structure">
|
|
<code class="sig-name descname">estimate_structure</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">max_parents</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">None</span></em>, <em class="sig-param"><span class="n">iterations_number</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">40</span></em>, <em class="sig-param"><span class="n">patience</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">None</span></em>, <em class="sig-param"><span class="n">tabu_length</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">None</span></em>, <em class="sig-param"><span class="n">tabu_rules_duration</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">None</span></em>, <em class="sig-param"><span class="n">optimizer</span><span class="p">:</span> <span class="n">str</span> <span class="o">=</span> <span class="default_value">'tabu'</span></em>, <em class="sig-param"><span class="n">disable_multiprocessing</span><span class="p">:</span> <span class="n">bool</span> <span class="o">=</span> <span class="default_value">False</span></em>, <em class="sig-param"><span class="n">processes_number</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_score_based_estimator.StructureScoreBasedEstimator.estimate_structure" title="Permalink to this definition">¶</a></dt>
|
|
|
|
<dd><p>Compute the score-based algorithm to find the optimal structure</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>max_parents</strong> (<em>int</em><em>, </em><em>optional</em>) – maximum number of parents for each variable. If None, disabled, default to None</p></li>
|
|
<li><p><strong>iterations_number</strong> (<em>int</em><em>, </em><em>optional</em>) – maximum number of optimization algorithm’s iteration, default to 40</p></li>
|
|
<li><p><strong>patience</strong> (<em>int</em><em>, </em><em>optional</em>) – number of iteration without any improvement before to stop the search.If None, disabled, default to None</p></li>
|
|
<li><p><strong>tabu_length</strong> (<em>int</em><em>, </em><em>optional</em>) – maximum lenght of the data structures used in the optimization process, default to None</p></li>
|
|
<li><p><strong>tabu_rules_duration</strong> (<em>int</em><em>, </em><em>optional</em>) – number of iterations in which each rule keeps its value, default to None</p></li>
|
|
<li><p><strong>optimizer</strong> (<em>string</em><em>, </em><em>optional</em>) – name of the optimizer algorithm. Possible values: ‘hill’ (Hill climbing),’tabu’ (tabu search), defualt to ‘tabu’</p></li>
|
|
<li><p><strong>disable_multiprocessing</strong> (<em>Boolean</em><em>, </em><em>optional</em>) – true if you desire to disable the multiprocessing operations, default to False</p></li>
|
|
<li><p><strong>processes_number</strong> – if disable_multiprocessing is false indicates</p></li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
<p>the maximum number of process; if None it will be automatically set, default to None
|
|
:type processes_number: int, optional</p>
|
|
</dd></dl>
|
|
|
|
<dl class="py method">
|
|
<dt class="sig sig-object py" id="PyCTBN.PyCTBN.estimators.structure_score_based_estimator.StructureScoreBasedEstimator.get_score_from_graph">
|
|
<span class="sig-name descname"><span class="pre">get_score_from_graph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">graph</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><a class="reference internal" href="PyCTBN.PyCTBN.structure_graph.html#PyCTBN.PyCTBN.structure_graph.network_graph.NetworkGraph" title="PyCTBN.PyCTBN.structure_graph.network_graph.NetworkGraph"><span class="pre">PyCTBN.PyCTBN.structure_graph.network_graph.NetworkGraph</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">node_id</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PyCTBN.PyCTBN.estimators.structure_score_based_estimator.StructureScoreBasedEstimator.get_score_from_graph" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Get the FamScore of a node</p>
|
|
<dl class="field-list simple">
|
|
<dt class="field-odd">Parameters</dt>
|
|
<dd class="field-odd"><ul class="simple">
|
|
<li><p><strong>node_id</strong> (<em>string</em>) – current node’s id</p></li>
|
|
<li><p><strong>graph</strong> (<em>class:'NetworkGraph'</em>) – current graph to be computed</p></li>
|
|
</ul>
|
|
</dd>
|
|
<dt class="field-even">Returns</dt>
|
|
<dd class="field-even"><p>The FamSCore for this graph structure</p>
|
|
</dd>
|
|
<dt class="field-odd">Return type</dt>
|
|
<dd class="field-odd"><p>float</p>
|
|
</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
</dd></dl>
|
|
|
|
</section>
|
|
<section id="module-PyCTBN.PyCTBN.estimators">
|
|
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-PyCTBN.PyCTBN.estimators" title="Permalink to this headline">¶</a></h2>
|
|
</section>
|
|
</section>
|
|
|
|
|
|
</div>
|
|
<footer>
|
|
|
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
|
|
|
<a href="PyCTBN.PyCTBN.optimizers.html" class="btn btn-neutral float-right" title="PyCTBN.PyCTBN.optimizers package">Next <span class="fa fa-arrow-circle-right"></span></a>
|
|
|
|
|
|
<a href="PyCTBN.PyCTBN.html" class="btn btn-neutral" title="PyCTBN.PyCTBN package"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
|
|
|
</div>
|
|
|
|
|
|
<hr/>
|
|
|
|
<div role="contentinfo">
|
|
<p>
|
|
© Copyright 2021, Bregoli Alessandro, Martini Filippo, Moretti Luca.
|
|
</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:'2.0',
|
|
COLLAPSE_INDEX:false,
|
|
FILE_SUFFIX:'.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" 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 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> |