Skip to content

Commit

Permalink
Deploying to gh-pages from @ bda83b7 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneCmb committed Jul 4, 2024
1 parent 86b45d5 commit 801a142
Show file tree
Hide file tree
Showing 113 changed files with 605 additions and 508 deletions.
Binary file not shown.
4 changes: 2 additions & 2 deletions _downloads/4481fca80fcd36eb6fde9d9cb4e3134c/plot_entropies.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

# list of estimators to compare
metrics = {
"GC": get_entropy("gc", biascorrect=False),
"GC": get_entropy("gc"),
"Gaussian": get_entropy("gauss"),
"KNN-3": get_entropy("knn", k=3),
"KNN-10": get_entropy("knn", k=10),
"Kernel": get_entropy("kernel"),
}

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"outputs": [],
"source": [
"# list of estimators to compare\nmetrics = {\n \"GC\": get_entropy(\"gc\", biascorrect=False),\n \"KNN-3\": get_entropy(\"knn\", k=3),\n \"KNN-10\": get_entropy(\"knn\", k=10),\n \"Kernel\": get_entropy(\"kernel\"),\n}\n\n# number of samples to simulate data\nn_samples = np.geomspace(20, 1000, 15).astype(int)\n\n# number of repetitions to estimate the percentile interval\nn_repeat = 10\n\n\n# plotting function\ndef plot(h_x, h_theoric):\n \"\"\"Plotting function.\"\"\"\n for n_m, metric_name in enumerate(h_x.keys()):\n # get the entropies\n x = h_x[metric_name]\n\n # get the color\n color = f\"C{n_m}\"\n\n # estimate lower and upper bounds of the [5, 95]th percentile interval\n x_low, x_high = np.percentile(x, [5, 95], axis=0)\n\n # plot the entropy as a function of the number of samples and interval\n plt.plot(n_samples, x.mean(0), color=color, lw=2, label=metric_name)\n plt.fill_between(n_samples, x_low, x_high, color=color, alpha=0.2)\n\n # plot the theoretical value\n plt.axhline(\n h_theoric, linestyle=\"--\", color=\"k\", label=\"Theoretical entropy\"\n )\n plt.legend()\n plt.xlabel(\"Number of samples\")\n plt.ylabel(\"Entropy [bits]\")"
"# list of estimators to compare\nmetrics = {\n \"GC\": get_entropy(\"gc\"),\n \"Gaussian\": get_entropy(\"gauss\"),\n \"KNN-3\": get_entropy(\"knn\", k=3),\n \"Kernel\": get_entropy(\"kernel\"),\n}\n\n# number of samples to simulate data\nn_samples = np.geomspace(20, 1000, 15).astype(int)\n\n# number of repetitions to estimate the percentile interval\nn_repeat = 10\n\n\n# plotting function\ndef plot(h_x, h_theoric):\n \"\"\"Plotting function.\"\"\"\n for n_m, metric_name in enumerate(h_x.keys()):\n # get the entropies\n x = h_x[metric_name]\n\n # get the color\n color = f\"C{n_m}\"\n\n # estimate lower and upper bounds of the [5, 95]th percentile interval\n x_low, x_high = np.percentile(x, [5, 95], axis=0)\n\n # plot the entropy as a function of the number of samples and interval\n plt.plot(n_samples, x.mean(0), color=color, lw=2, label=metric_name)\n plt.fill_between(n_samples, x_low, x_high, color=color, alpha=0.2)\n\n # plot the theoretical value\n plt.axhline(\n h_theoric, linestyle=\"--\", color=\"k\", label=\"Theoretical entropy\"\n )\n plt.legend()\n plt.xlabel(\"Number of samples\")\n plt.ylabel(\"Entropy [bits]\")"
]
},
{
Expand Down
Binary file modified _images/sphx_glr_plot_bootstrapping_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_bootstrapping_002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_bootstrapping_003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_bootstrapping_thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_entropies_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_entropies_002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_entropies_003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_entropies_thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_infotopo_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_infotopo_002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_infotopo_thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_inspect_results_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_ml_vs_it_003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_oinfo_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_oinfo_thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_rsi_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_rsi_thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_sim_red_syn_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_sim_red_syn_002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/sphx_glr_plot_sim_red_syn_thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion _modules/hoi/core/combinatory.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@
<li class="toctree-l2 has-children"><a class="reference internal" href="../../../api/api_core.html"><code class="docutils literal notranslate"><span class="pre">hoi.core</span></code></a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.get_entropy.html">hoi.core.get_entropy</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_gc.html">hoi.core.entropy_gc</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_gauss.html">hoi.core.entropy_gauss</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_bin.html">hoi.core.entropy_bin</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_knn.html">hoi.core.entropy_knn</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_kernel.html">hoi.core.entropy_kernel</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.copnorm_nd.html">hoi.core.copnorm_nd</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.prepare_for_it.html">hoi.core.prepare_for_it</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.get_mi.html">hoi.core.get_mi</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.combinations.html">hoi.core.combinations</a></li>
Expand Down
173 changes: 98 additions & 75 deletions _modules/hoi/core/entropies.html

Large diffs are not rendered by default.

44 changes: 37 additions & 7 deletions _modules/hoi/core/mi.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@
<li class="toctree-l2 has-children"><a class="reference internal" href="../../../api/api_core.html"><code class="docutils literal notranslate"><span class="pre">hoi.core</span></code></a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.get_entropy.html">hoi.core.get_entropy</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_gc.html">hoi.core.entropy_gc</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_gauss.html">hoi.core.entropy_gauss</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_bin.html">hoi.core.entropy_bin</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_knn.html">hoi.core.entropy_knn</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_kernel.html">hoi.core.entropy_kernel</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.copnorm_nd.html">hoi.core.copnorm_nd</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.prepare_for_it.html">hoi.core.prepare_for_it</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.get_mi.html">hoi.core.get_mi</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.combinations.html">hoi.core.combinations</a></li>
Expand Down Expand Up @@ -377,7 +377,7 @@ <h1>Source code for hoi.core.mi</h1><div class="highlight"><pre>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">jax.scipy.special</span> <span class="kn">import</span> <span class="n">digamma</span> <span class="k">as</span> <span class="n">psi</span>

<span class="kn">from</span> <span class="nn">hoi.core.entropies</span> <span class="kn">import</span> <span class="n">get_entropy</span>
<span class="kn">from</span> <span class="nn">hoi.core.entropies</span> <span class="kn">import</span> <span class="n">get_entropy</span><span class="p">,</span> <span class="n">preproc_gc_2d</span>
<span class="kn">from</span> <span class="nn">hoi.utils.logging</span> <span class="kn">import</span> <span class="n">logger</span>

<span class="c1">###############################################################################</span>
Expand Down Expand Up @@ -407,6 +407,8 @@ <h1>Source code for hoi.core.mi</h1><div class="highlight"><pre>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">&quot;gc&quot;</span><span class="p">:</span>
<span class="k">return</span> <span class="n">partial</span><span class="p">(</span><span class="n">mi_gc</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">&quot;gauss&quot;</span><span class="p">:</span>
<span class="k">return</span> <span class="n">mi_gauss</span>
<span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">&quot;knn&quot;</span><span class="p">:</span>
<span class="k">return</span> <span class="n">partial</span><span class="p">(</span><span class="n">mi_knn</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="k">elif</span> <span class="nb">callable</span><span class="p">(</span><span class="n">method</span><span class="p">):</span>
Expand Down Expand Up @@ -510,7 +512,10 @@ <h1>Source code for hoi.core.mi</h1><div class="highlight"><pre>

<span class="nd">@partial</span><span class="p">(</span><span class="n">jax</span><span class="o">.</span><span class="n">jit</span><span class="p">,</span> <span class="n">static_argnums</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="k">def</span> <span class="nf">mi_gc</span><span class="p">(</span>
<span class="n">x</span><span class="p">:</span> <span class="n">jnp</span><span class="o">.</span><span class="n">array</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">jnp</span><span class="o">.</span><span class="n">array</span><span class="p">,</span> <span class="n">biascorrect</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">demean</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span>
<span class="n">x</span><span class="p">:</span> <span class="n">jnp</span><span class="o">.</span><span class="n">array</span><span class="p">,</span>
<span class="n">y</span><span class="p">:</span> <span class="n">jnp</span><span class="o">.</span><span class="n">array</span><span class="p">,</span>
<span class="n">biascorrect</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
<span class="n">copnorm</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Mutual information (MI) between two Gaussian variables in bits.</span>

Expand All @@ -522,8 +527,8 @@ <h1>Source code for hoi.core.mi</h1><div class="highlight"><pre>
<span class="sd"> (n_features_y, n_samples)</span>
<span class="sd"> biascorrect : bool | False</span>
<span class="sd"> Specifies whether bias correction should be applied to the estimated MI</span>
<span class="sd"> demean : bool | False</span>
<span class="sd"> Specifies whether the input data have to be demeaned</span>
<span class="sd"> copnorm : bool | True</span>
<span class="sd"> Apply gaussian copula normalization</span>


<span class="sd"> Returns</span>
Expand All @@ -537,8 +542,8 @@ <h1>Source code for hoi.core.mi</h1><div class="highlight"><pre>

<span class="c1"># joint variable</span>
<span class="n">xy</span> <span class="o">=</span> <span class="n">jnp</span><span class="o">.</span><span class="n">vstack</span><span class="p">((</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">))</span>
<span class="k">if</span> <span class="n">demean</span><span class="p">:</span>
<span class="n">xy</span> <span class="o">=</span> <span class="n">xy</span> <span class="o">-</span> <span class="n">xy</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">)[:,</span> <span class="n">jnp</span><span class="o">.</span><span class="n">newaxis</span><span class="p">]</span>
<span class="k">if</span> <span class="n">copnorm</span><span class="p">:</span>
<span class="n">xy</span> <span class="o">=</span> <span class="n">preproc_gc_2d</span><span class="p">(</span><span class="n">xy</span><span class="p">)</span>
<span class="n">cxy</span> <span class="o">=</span> <span class="n">jnp</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">xy</span><span class="p">,</span> <span class="n">xy</span><span class="o">.</span><span class="n">T</span><span class="p">)</span> <span class="o">/</span> <span class="nb">float</span><span class="p">(</span><span class="n">n_samples</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
<span class="c1"># submatrices of joint covariance</span>
<span class="n">cx</span> <span class="o">=</span> <span class="n">cxy</span><span class="p">[:</span><span class="n">n_features_x</span><span class="p">,</span> <span class="p">:</span><span class="n">n_features_x</span><span class="p">]</span>
Expand Down Expand Up @@ -573,6 +578,31 @@ <h1>Source code for hoi.core.mi</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">i</span>


<span class="c1">###############################################################################</span>
<span class="c1">###############################################################################</span>
<span class="c1"># GAUSSIAN MUTUAL INFORMATION</span>
<span class="c1">###############################################################################</span>
<span class="c1">###############################################################################</span>


<span class="k">def</span> <span class="nf">mi_gauss</span><span class="p">(</span><span class="n">x</span><span class="p">:</span> <span class="n">jnp</span><span class="o">.</span><span class="n">array</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">jnp</span><span class="o">.</span><span class="n">array</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Mutual information (MI) between two Gaussian variables in bits.</span>

<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> x, y : array_like</span>
<span class="sd"> Arrays to consider for computing the Mutual Information. The two input</span>
<span class="sd"> variables x and y should have a shape of (n_features_x, n_samples) and</span>
<span class="sd"> (n_features_y, n_samples)</span>

<span class="sd"> Returns</span>
<span class="sd"> -------</span>
<span class="sd"> i : float</span>
<span class="sd"> Information shared by x and y (in bits)</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">mi_gc</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">biascorrect</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">copnorm</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>


<span class="c1">###############################################################################</span>
<span class="c1">###############################################################################</span>
<span class="c1"># KNN MUTUAL INFORMATION</span>
Expand Down
3 changes: 2 additions & 1 deletion _modules/hoi/metrics/dtc.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@
<li class="toctree-l2 has-children"><a class="reference internal" href="../../../api/api_core.html"><code class="docutils literal notranslate"><span class="pre">hoi.core</span></code></a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.get_entropy.html">hoi.core.get_entropy</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_gc.html">hoi.core.entropy_gc</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_gauss.html">hoi.core.entropy_gauss</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_bin.html">hoi.core.entropy_bin</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_knn.html">hoi.core.entropy_knn</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.entropy_kernel.html">hoi.core.entropy_kernel</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.copnorm_nd.html">hoi.core.copnorm_nd</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.prepare_for_it.html">hoi.core.prepare_for_it</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.get_mi.html">hoi.core.get_mi</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../../api/generated/hoi.core.combinations.html">hoi.core.combinations</a></li>
Expand Down Expand Up @@ -463,6 +463,7 @@ <h1>Source code for hoi.metrics.dtc</h1><div class="highlight"><pre>

<span class="sd"> * &#39;gc&#39;: gaussian copula entropy [default]. See</span>
<span class="sd"> :func:`hoi.core.entropy_gc`</span>
<span class="sd"> * &#39;gauss&#39;: gaussian entropy. See :func:`hoi.core.entropy_gauss`</span>
<span class="sd"> * &#39;binning&#39;: binning-based estimator of entropy. Note that to</span>
<span class="sd"> use this estimator, the data have be to discretized. See</span>
<span class="sd"> :func:`hoi.core.entropy_bin`</span>
Expand Down
Loading

0 comments on commit 801a142

Please sign in to comment.