Skip to content

Commit

Permalink
deploy: 1788a84
Browse files Browse the repository at this point in the history
  • Loading branch information
avantikalal committed Feb 19, 2024
0 parents commit ea44f71
Show file tree
Hide file tree
Showing 50 changed files with 21,694 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 615379cae50c477b7afb720896ec93a3
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file added .doctrees/api/modules.doctree
Binary file not shown.
Binary file added .doctrees/api/reglm.doctree
Binary file not shown.
Binary file added .doctrees/authors.doctree
Binary file not shown.
Binary file added .doctrees/environment.pickle
Binary file not shown.
Binary file added .doctrees/index.doctree
Binary file not shown.
Binary file added .doctrees/license.doctree
Binary file not shown.
Binary file added .doctrees/readme.doctree
Binary file not shown.
Empty file added .nojekyll
Empty file.
Binary file added _images/fig1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions _modules/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@

<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview: module code &#8212; regLM unknown documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />

<link rel="stylesheet" href="../_static/custom.css" type="text/css" />





</head><body>


<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">


<div class="body" role="main">

<h1>All modules for which code is available</h1>
<ul><li><a href="reglm/dataset.html">reglm.dataset</a></li>
<li><a href="reglm/evolve.html">reglm.evolve</a></li>
<li><a href="reglm/interpret.html">reglm.interpret</a></li>
<li><a href="reglm/lightning.html">reglm.lightning</a></li>
<li><a href="reglm/metrics.html">reglm.metrics</a></li>
<li><a href="reglm/regression.html">reglm.regression</a></li>
<li><a href="reglm/utils.html">reglm.utils</a></li>
</ul>

</div>

</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">regLM</a></h1>








<h3>Navigation</h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../readme.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../license.html">License</a></li>
<li class="toctree-l1"><a class="reference internal" href="../authors.html">Authors</a></li>
<li class="toctree-l1"><a class="reference internal" href="../api/modules.html">Module Reference</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="../index.html">Documentation overview</a><ul>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>








</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&#169;2023, Genentech, Inc..

|
Powered by <a href="https://www.sphinx-doc.org/">Sphinx 4.5.0</a>
&amp; <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>

</div>




</body>
</html>
255 changes: 255 additions & 0 deletions _modules/reglm/dataset.html

Large diffs are not rendered by default.

236 changes: 236 additions & 0 deletions _modules/reglm/evolve.html

Large diffs are not rendered by default.

311 changes: 311 additions & 0 deletions _modules/reglm/interpret.html

Large diffs are not rendered by default.

923 changes: 923 additions & 0 deletions _modules/reglm/lightning.html

Large diffs are not rendered by default.

157 changes: 157 additions & 0 deletions _modules/reglm/metrics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@

<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>reglm.metrics &#8212; regLM unknown documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../../_static/alabaster.css" />
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/doctools.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />

<link rel="stylesheet" href="../../_static/custom.css" type="text/css" />





</head><body>


<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">


<div class="body" role="main">

<h1>Source code for reglm.metrics</h1><div class="highlight"><pre>
<span></span><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">reglm.dataset</span> <span class="kn">import</span> <span class="n">CharDataset</span>


<div class="viewcode-block" id="compute_accuracy"><a class="viewcode-back" href="../../api/reglm.html#reglm.metrics.compute_accuracy">[docs]</a><span class="k">def</span> <span class="nf">compute_accuracy</span><span class="p">(</span><span class="n">model</span><span class="p">,</span> <span class="n">seqs</span><span class="p">,</span> <span class="n">shuffle_labels</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">batch_size</span><span class="o">=</span><span class="mi">64</span><span class="p">,</span> <span class="n">num_workers</span><span class="o">=</span><span class="mi">8</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Compute per-base accuracy of a trained regLM model on labeled sequences</span>

<span class="sd"> Args:</span>
<span class="sd"> model (pl.LightningModule): Trained regLM model</span>
<span class="sd"> seqs (pd.DataFrame): Dataframe containing sequences under &#39;Sequence&#39;</span>
<span class="sd"> and labels under &#39;label&#39;.</span>
<span class="sd"> shuffle_labels (bool): Whether to shuffle the labels among sequences</span>
<span class="sd"> before computing accuracy.</span>
<span class="sd"> batch_size (int): Batch size for inference</span>
<span class="sd"> num_workers (int): Number of workers for inference</span>

<span class="sd"> Returns:</span>
<span class="sd"> seqs (pd.DataFrame): original dataframe with added columns for per-</span>
<span class="sd"> base and average accuracy.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># Extract labels</span>
<span class="n">labels</span> <span class="o">=</span> <span class="n">seqs</span><span class="o">.</span><span class="n">label</span>

<span class="c1"># Shuffle labels if needed</span>
<span class="k">if</span> <span class="n">shuffle_labels</span><span class="p">:</span>
<span class="n">labels</span> <span class="o">=</span> <span class="n">seqs</span><span class="o">.</span><span class="n">label</span><span class="o">.</span><span class="n">sample</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">seqs</span><span class="p">))</span>

<span class="n">labels</span> <span class="o">=</span> <span class="n">labels</span><span class="o">.</span><span class="n">tolist</span><span class="p">()</span>

<span class="c1"># Create dataset</span>
<span class="n">ds</span> <span class="o">=</span> <span class="n">CharDataset</span><span class="p">(</span><span class="n">seqs</span><span class="o">=</span><span class="n">seqs</span><span class="o">.</span><span class="n">Sequence</span><span class="o">.</span><span class="n">tolist</span><span class="p">(),</span> <span class="n">labels</span><span class="o">=</span><span class="n">labels</span><span class="p">)</span>

<span class="c1"># Compute per-base accuracy</span>
<span class="n">acc</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">compute_accuracy_on_dataset</span><span class="p">(</span>
<span class="n">ds</span><span class="p">,</span> <span class="n">batch_size</span><span class="o">=</span><span class="n">batch_size</span><span class="p">,</span> <span class="n">num_workers</span><span class="o">=</span><span class="n">num_workers</span>
<span class="p">)</span>

<span class="c1"># Add results to dataframe</span>
<span class="k">if</span> <span class="n">shuffle_labels</span><span class="p">:</span>
<span class="n">seqs</span><span class="p">[</span><span class="s2">&quot;acc_shuf&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">acc</span>
<span class="n">seqs</span><span class="p">[</span><span class="s2">&quot;acc_shuf_mean&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">seqs</span><span class="p">[</span><span class="s2">&quot;acc_shuf&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">)</span>
<span class="n">avg_acc</span> <span class="o">=</span> <span class="n">seqs</span><span class="p">[</span><span class="s2">&quot;acc_shuf_mean&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">mean</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">seqs</span><span class="p">[</span><span class="s2">&quot;acc&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">acc</span>
<span class="n">seqs</span><span class="p">[</span><span class="s2">&quot;acc_mean&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">seqs</span><span class="p">[</span><span class="s2">&quot;acc&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">)</span>
<span class="n">avg_acc</span> <span class="o">=</span> <span class="n">seqs</span><span class="p">[</span><span class="s2">&quot;acc_mean&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">mean</span><span class="p">()</span>

<span class="c1"># Print overall mean</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Mean accuracy: </span><span class="si">{</span><span class="n">avg_acc</span><span class="si">:</span><span class="s2">.3f</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>

<span class="k">return</span> <span class="n">seqs</span></div>
</pre></div>

</div>

</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../../index.html">regLM</a></h1>








<h3>Navigation</h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../readme.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../license.html">License</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../authors.html">Authors</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/modules.html">Module Reference</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="../../index.html">Documentation overview</a><ul>
<li><a href="../index.html">Module code</a><ul>
</ul></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>








</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&#169;2023, Genentech, Inc..

|
Powered by <a href="https://www.sphinx-doc.org/">Sphinx 4.5.0</a>
&amp; <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>

</div>




</body>
</html>
Loading

0 comments on commit ea44f71

Please sign in to comment.