Skip to content

Commit

Permalink
update sphinx docs
Browse files Browse the repository at this point in the history
  • Loading branch information
erdogant committed Mar 6, 2024
1 parent 473ecac commit bbd82b0
Show file tree
Hide file tree
Showing 70 changed files with 624 additions and 512 deletions.
Binary file modified docs/pages/doctrees/Continuous Data.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Create DAG.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Documentation.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Example Datasets.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Examples.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Inference.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Installation.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Introduction.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Licence.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Parameter learning.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Plot.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Predict.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Quickstart.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Sampling.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Structure learning.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/Structure_scores.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/UseCases.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/bnlearn.bnlearn.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/bnlearn.inference.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/bnlearn.parameter_learning.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/bnlearn.structure_learning.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/dataframe conversions.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/pages/doctrees/independence_test.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/index.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/saving and loading.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/sponsor.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/topological_sort.doctree
Binary file not shown.
Binary file modified docs/pages/doctrees/whitelist_blacklist.doctree
Binary file not shown.
32 changes: 17 additions & 15 deletions docs/pages/html/Continuous Data.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<html class="writer-html5" lang="en" data-content_root="./">
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Advanced discretizing continous data &mdash; bnlearn bnlearn documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" />
<link rel="stylesheet" type="text/css" href="_static/css/custom.css?v=e0179649" />


<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->

<script src="_static/jquery.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/sphinx_highlight.js"></script>
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=441dd29d"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
Expand Down Expand Up @@ -184,7 +186,7 @@
<p>The underlying idea i that the implemented method now can perform structure learning by first discretizng the continuous
variables and simultaneously learn Bayesian network structures.</p>
<section id="advanced-discretizing-continous-data">
<h1>Advanced discretizing continous data<a class="headerlink" href="#advanced-discretizing-continous-data" title="Permalink to this heading"></a></h1>
<h1>Advanced discretizing continous data<a class="headerlink" href="#advanced-discretizing-continous-data" title="Link to this heading"></a></h1>
<p>To demonstrate the usage of parameter learning on continuous data, I will use the well known <strong>auto mpg</strong> data set.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Import</span>
<span class="kn">import</span> <span class="nn">bnlearn</span> <span class="k">as</span> <span class="nn">bn</span>
Expand Down Expand Up @@ -252,7 +254,7 @@ <h1>Advanced discretizing continous data<a class="headerlink" href="#advanced-di
discrete data frame and fit a model using <code class="docutils literal notranslate"><span class="pre">bnlearn</span></code>.</p>
</section>
<section id="structure-learning">
<h1>Structure learning<a class="headerlink" href="#structure-learning" title="Permalink to this heading"></a></h1>
<h1>Structure learning<a class="headerlink" href="#structure-learning" title="Link to this heading"></a></h1>
<p>We will learn the structure on the continuous data. Note that the data is also discretezed on a set of edges which will
likely introduce a bias in the learned structure.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Learn the structure</span>
Expand All @@ -274,7 +276,7 @@ <h1>Structure learning<a class="headerlink" href="#structure-learning" title="Pe
</figure>
<iframe src="https://erdogant.github.io/docs/d3blocks/bnlearn_continous_example_1.html" height="700px" width="750px", frameBorder="0"></iframe></section>
<section id="parameter-learning">
<h1>Parameter learning<a class="headerlink" href="#parameter-learning" title="Permalink to this heading"></a></h1>
<h1>Parameter learning<a class="headerlink" href="#parameter-learning" title="Link to this heading"></a></h1>
<p>Let’s continue with parameter learning on the continuous data set and see whether we can estimate the CPDs.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Fit model based on DAG and discretized continous columns</span>
<span class="n">model</span> <span class="o">=</span> <span class="n">bn</span><span class="o">.</span><span class="n">parameter_learning</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">DAG</span><span class="p">,</span> <span class="n">df_discrete</span><span class="p">)</span>
Expand Down Expand Up @@ -340,7 +342,7 @@ <h1>Parameter learning<a class="headerlink" href="#parameter-learning" title="Pe
</div>
</section>
<section id="inference">
<h1>Inference<a class="headerlink" href="#inference" title="Permalink to this heading"></a></h1>
<h1>Inference<a class="headerlink" href="#inference" title="Link to this heading"></a></h1>
<p>Making inferences can be perfomred using the fitted model. Note that the evidence should be discretized for which we can
use the <code class="docutils literal notranslate"><span class="pre">discretize_value</span></code> function.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">evidence</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;weight&quot;</span><span class="p">:</span> <span class="n">bn</span><span class="o">.</span><span class="n">discretize_value</span><span class="p">(</span><span class="n">df_discrete</span><span class="p">[</span><span class="s2">&quot;weight&quot;</span><span class="p">],</span> <span class="mf">3000.0</span><span class="p">)}</span>
Expand Down Expand Up @@ -378,7 +380,7 @@ <h1>Inference<a class="headerlink" href="#inference" title="Permalink to this he
</tbody>
</table>
<section id="references">
<h2>References<a class="headerlink" href="#references" title="Permalink to this heading"></a></h2>
<h2>References<a class="headerlink" href="#references" title="Link to this heading"></a></h2>
<blockquote>
<div><ol class="arabic simple">
<li><p>Yi-Chun Chen, Tim Allan Wheeler, Mykel John Kochenderfer (2015),
Expand Down
36 changes: 19 additions & 17 deletions docs/pages/html/Create DAG.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<html class="writer-html5" lang="en" data-content_root="./">
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Directed Acyclic Graphs &mdash; bnlearn bnlearn documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" />
<link rel="stylesheet" type="text/css" href="_static/css/custom.css?v=e0179649" />


<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->

<script src="_static/jquery.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/sphinx_highlight.js"></script>
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=441dd29d"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
Expand Down Expand Up @@ -179,10 +181,10 @@
<div itemprop="articleBody">

<section id="directed-acyclic-graphs">
<h1>Directed Acyclic Graphs<a class="headerlink" href="#directed-acyclic-graphs" title="Permalink to this heading"></a></h1>
<h1>Directed Acyclic Graphs<a class="headerlink" href="#directed-acyclic-graphs" title="Link to this heading"></a></h1>
<p>This example is to better understand the importance and working of a Directed Acyclic Graph. The underneath topics are going to be explained:</p>
<section id="overview">
<h2>Overview<a class="headerlink" href="#overview" title="Permalink to this heading"></a></h2>
<h2>Overview<a class="headerlink" href="#overview" title="Link to this heading"></a></h2>
<ul class="simple">
<li><p>Building a DAG</p></li>
<li><p>plotting a DAG</p></li>
Expand All @@ -192,7 +194,7 @@ <h2>Overview<a class="headerlink" href="#overview" title="Permalink to this head
</ul>
</section>
<section id="building-a-causal-dag">
<h2>Building a causal DAG<a class="headerlink" href="#building-a-causal-dag" title="Permalink to this heading"></a></h2>
<h2>Building a causal DAG<a class="headerlink" href="#building-a-causal-dag" title="Link to this heading"></a></h2>
<p>If you readily know (or you have domain knowledge) of the relationships between variables, we can setup the (causal) relationships between the variables with a directed graph (DAG).
Each node corresponds to a variable and each edge represents conditional dependencies between pairs of variables.
In bnlearn, we can graphically represent the relationships between variables. To demonstrate this I will create the simple Sprinkler example by hand.</p>
Expand Down Expand Up @@ -223,13 +225,13 @@ <h2>Building a causal DAG<a class="headerlink" href="#building-a-causal-dag" tit
<figure class="align-default" id="id1">
<span id="fig-sprinkler"></span><img alt="_images/fig_sprinkler_sl.png" src="_images/fig_sprinkler_sl.png" />
<figcaption>
<p><span class="caption-text">Causal DAG.</span><a class="headerlink" href="#id1" title="Permalink to this image"></a></p>
<p><span class="caption-text">Causal DAG.</span><a class="headerlink" href="#id1" title="Link to this image"></a></p>
</figcaption>
</figure>
<p>We call this a causal DAG because we have assumed that the edges we encoded represent our causal assumptions about the system.</p>
</section>
<section id="the-causal-dag-as-a-generative-representation-of-joint-probability">
<h2>The causal DAG as a generative representation of joint probability<a class="headerlink" href="#the-causal-dag-as-a-generative-representation-of-joint-probability" title="Permalink to this heading"></a></h2>
<h2>The causal DAG as a generative representation of joint probability<a class="headerlink" href="#the-causal-dag-as-a-generative-representation-of-joint-probability" title="Link to this heading"></a></h2>
<p>Any DAG (causal or otherwise) that we might specify for this data represents a factorization of the joint probability distribution of the variables.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">bnlearn</span><span class="o">.</span><span class="n">print_CPD</span><span class="p">(</span><span class="n">DAG</span><span class="p">)</span>

Expand All @@ -239,7 +241,7 @@ <h2>The causal DAG as a generative representation of joint probability<a class="
<p>There are no CPDs attached to the DAG yet. Therefore there is nothing to show.</p>
</section>
<section id="specifying-the-probability-distributions-on-your-own">
<h2>Specifying the probability distributions on your own<a class="headerlink" href="#specifying-the-probability-distributions-on-your-own" title="Permalink to this heading"></a></h2>
<h2>Specifying the probability distributions on your own<a class="headerlink" href="#specifying-the-probability-distributions-on-your-own" title="Link to this heading"></a></h2>
<p>Each factor is a conditional probability distribution (CPD). In the discrete case the CPD is sometimes called a conditional probability table (CPT).
Though we can factorize over any DAG and get a set of CPDs, when we factorize along a DAG we consider to be a representation of causality, we call each CPD a causal Markov kernel (CMK).
The factorization that provides a set of CMKs is the most useful factorization because CMKs correspond to independent causal mechanisms we assume to be invariant across data sets.
Expand Down Expand Up @@ -297,7 +299,7 @@ <h2>Specifying the probability distributions on your own<a class="headerlink" hr
</div>
</section>
<section id="inference-on-the-causal-generative-model">
<h2>Inference on the causal generative model<a class="headerlink" href="#inference-on-the-causal-generative-model" title="Permalink to this heading"></a></h2>
<h2>Inference on the causal generative model<a class="headerlink" href="#inference-on-the-causal-generative-model" title="Link to this heading"></a></h2>
<p>This is an great basis to make inferences or update your this model with new data (parameter learning).</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">q1</span> <span class="o">=</span> <span class="n">bnlearn</span><span class="o">.</span><span class="n">inference</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">DAG</span><span class="p">,</span> <span class="n">variables</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;Wet_Grass&#39;</span><span class="p">],</span> <span class="n">evidence</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;Rain&#39;</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;Sprinkler&#39;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span> <span class="s1">&#39;Cloudy&#39;</span><span class="p">:</span><span class="mi">1</span><span class="p">})</span>
</pre></div>
Expand Down
Loading

0 comments on commit bbd82b0

Please sign in to comment.