Skip to content

Commit

Permalink
Merge pull request #32 from MolecularAI/3.1.3
Browse files Browse the repository at this point in the history
3.1.3 Docs
  • Loading branch information
lewismervin1 authored Sep 16, 2024
2 parents baeca20 + 10e0c63 commit b509ff4
Show file tree
Hide file tree
Showing 81 changed files with 555 additions and 293 deletions.
Binary file modified docs/sphinx-builddir/doctrees/README.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/algorithms.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/descriptors.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/index.doctree
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1055,10 +1055,10 @@
" response_type=\"regression\",\n",
" training_dataset_file=\"../tests/data/sdf/example.sdf\",\n",
" deduplication_strategy=KeepAllNoDeduplication(),\n",
" log_transform=\"True\", # flags to use a transform\n",
" log_transform=True, # flags to use a transform\n",
" log_transform_base=LogBase.LOG10, # Log10 base will be used\n",
" log_transform_negative=\"True\", # The negated log transform will be applied\n",
" log_transform_unit_conversion=6 # THe unit conversion for pXC50 values is 6\n",
" log_transform_negative=LogNegative.TRUE, # The negated log transform will be applied\n",
" log_transform_unit_conversion=6 # The unit conversion for pXC50 values is 6\n",
")\n",
"\n",
"pxc50_data = Dataset(\n",
Expand Down
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/notebooks/preprocess_data.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/optunaz.config.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/optunaz.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/optunaz.utils.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/transform.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/sphinx-builddir/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +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: b0c96d5f832cdd38d138271da4ddabf1
config: cd8105a3e394e54ace4ef41b1def0634
tags: 645f666f9bcd5a90fca523b33c5a78b7
26 changes: 9 additions & 17 deletions docs/sphinx-builddir/html/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>QSARtuna 𓆛: QSAR using Optimization for Hyperparameter Tuning (formerly Optuna AZ and QPTUNA) &mdash; QSARtuna 3.1.2 documentation</title>
<title>QSARtuna 𓆛: QSAR using Optimization for Hyperparameter Tuning (formerly Optuna AZ and QPTUNA) &mdash; QSARtuna 3.1.3 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/autodoc_pydantic.css" type="text/css" />
Expand Down Expand Up @@ -274,31 +274,28 @@ <h2>Run from Python/Jupyter Notebook<a class="headerlink" href="#run-from-python
<span class="kn">from</span> <span class="nn">qsartuna.config.optconfig</span> <span class="kn">import</span> <span class="p">(</span>
<span class="n">OptimizationConfig</span><span class="p">,</span>
<span class="n">SVR</span><span class="p">,</span>
<span class="n">RandomForest</span><span class="p">,</span>
<span class="n">RandomForestRegressor</span><span class="p">,</span>
<span class="n">Ridge</span><span class="p">,</span>
<span class="n">Lasso</span><span class="p">,</span>
<span class="n">PLS</span><span class="p">,</span>
<span class="n">XGBregressor</span><span class="p">,</span>
<span class="n">XGBRegressor</span><span class="p">,</span>
<span class="p">)</span>
<span class="kn">from</span> <span class="nn">qsartuna.datareader</span> <span class="kn">import</span> <span class="n">Dataset</span>
<span class="kn">from</span> <span class="nn">qsartuna.descriptors</span> <span class="kn">import</span> <span class="n">ECFP</span><span class="p">,</span> <span class="n">MACCS_keys</span><span class="p">,</span> <span class="n">ECFP_counts</span>
<span class="kn">from</span> <span class="nn">qsartuna.descriptors</span> <span class="kn">import</span> <span class="n">ECFP</span><span class="p">,</span> <span class="n">MACCS_keys</span><span class="p">,</span> <span class="n">ECFP_counts</span><span class="p">,</span> <span class="n">PathFP</span>

<span class="c1">##</span>
<span class="c1"># Prepare hyperparameter optimization configuration.</span>
<span class="n">config</span> <span class="o">=</span> <span class="n">OptimizationConfig</span><span class="p">(</span>
<span class="n">data</span><span class="o">=</span><span class="n">Dataset</span><span class="p">(</span>
<span class="n">input_column</span><span class="o">=</span><span class="s2">&quot;canonical&quot;</span><span class="p">,</span>
<span class="n">response_column</span><span class="o">=</span><span class="s2">&quot;molwt&quot;</span><span class="p">,</span>
<span class="n">training_dataset_file</span><span class="o">=</span><span class="s2">&quot;tests/data/DRD2/subset-50/train.csv&quot;</span><span class="p">,</span>
<span class="p">),</span>
<span class="n">descriptors</span><span class="o">=</span><span class="p">[</span><span class="n">ECFP</span><span class="o">.</span><span class="n">new</span><span class="p">(),</span> <span class="n">ECFP_counts</span><span class="o">.</span><span class="n">new</span><span class="p">(),</span> <span class="n">MACCS_keys</span><span class="o">.</span><span class="n">new</span><span class="p">()],</span>
<span class="n">descriptors</span><span class="o">=</span><span class="p">[</span><span class="n">ECFP</span><span class="o">.</span><span class="n">new</span><span class="p">(),</span> <span class="n">ECFP_counts</span><span class="o">.</span><span class="n">new</span><span class="p">(),</span> <span class="n">MACCS_keys</span><span class="o">.</span><span class="n">new</span><span class="p">(),</span> <span class="n">PathFP</span><span class="o">.</span><span class="n">new</span><span class="p">()],</span>
<span class="n">algorithms</span><span class="o">=</span><span class="p">[</span>
<span class="n">SVR</span><span class="o">.</span><span class="n">new</span><span class="p">(),</span>
<span class="n">RandomForest</span><span class="o">.</span><span class="n">new</span><span class="p">(),</span>
<span class="n">RandomForestRegressor</span><span class="o">.</span><span class="n">new</span><span class="p">(),</span>
<span class="n">Ridge</span><span class="o">.</span><span class="n">new</span><span class="p">(),</span>
<span class="n">Lasso</span><span class="o">.</span><span class="n">new</span><span class="p">(),</span>
<span class="n">PLS</span><span class="o">.</span><span class="n">new</span><span class="p">(),</span>
<span class="n">XGBregressor</span><span class="o">.</span><span class="n">new</span><span class="p">(),</span>
<span class="n">XGBRegressor</span><span class="o">.</span><span class="n">new</span><span class="p">(),</span>
<span class="p">],</span>
<span class="n">settings</span><span class="o">=</span><span class="n">OptimizationConfig</span><span class="o">.</span><span class="n">Settings</span><span class="p">(</span>
<span class="n">mode</span><span class="o">=</span><span class="n">ModelMode</span><span class="o">.</span><span class="n">REGRESSION</span><span class="p">,</span>
Expand All @@ -308,22 +305,17 @@ <h2>Run from Python/Jupyter Notebook<a class="headerlink" href="#run-from-python
<span class="p">),</span>
<span class="p">)</span>

<span class="c1">##</span>
<span class="c1"># Run Optuna Study.</span>
<span class="n">study</span> <span class="o">=</span> <span class="n">optimize</span><span class="p">(</span><span class="n">config</span><span class="p">,</span> <span class="n">study_name</span><span class="o">=</span><span class="s2">&quot;my_study&quot;</span><span class="p">)</span>

<span class="c1">##</span>
<span class="c1"># Get the best Trial from the Study and make a Build (Training) configuration for it.</span>
<span class="n">buildconfig</span> <span class="o">=</span> <span class="n">buildconfig_best</span><span class="p">(</span><span class="n">study</span><span class="p">)</span>
<span class="c1"># Optional: write out JSON of the best configuration.</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="nb">print</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">buildconfig</span><span class="o">.</span><span class="n">json</span><span class="p">(),</span> <span class="n">indent</span><span class="o">=</span><span class="mi">2</span><span class="p">))</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">&quot;best_config.txt&quot;</span><span class="p">,</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">buildconfig</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">))</span>

<span class="c1">##</span>
<span class="c1"># Build (re-Train) and save the best model.</span>
<span class="n">build_best</span><span class="p">(</span><span class="n">buildconfig</span><span class="p">,</span> <span class="s2">&quot;target/best.pkl&quot;</span><span class="p">)</span>

<span class="c1">##</span>
<span class="c1"># Build (Train) and save the model on the merged train+test data.</span>
<span class="n">build_merged</span><span class="p">(</span><span class="n">buildconfig</span><span class="p">,</span> <span class="s2">&quot;target/merged.pkl&quot;</span><span class="p">)</span>
</pre></div>
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx-builddir/html/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview: module code &mdash; QSARtuna 3.1.2 documentation</title>
<title>Overview: module code &mdash; QSARtuna 3.1.3 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/autodoc_pydantic.css" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx-builddir/html/_modules/optunaz/automl.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>optunaz.automl &mdash; QSARtuna 3.1.2 documentation</title>
<title>optunaz.automl &mdash; QSARtuna 3.1.3 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/autodoc_pydantic.css" type="text/css" />
Expand Down
44 changes: 35 additions & 9 deletions docs/sphinx-builddir/html/_modules/optunaz/builder.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>optunaz.builder &mdash; QSARtuna 3.1.2 documentation</title>
<title>optunaz.builder &mdash; QSARtuna 3.1.3 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/autodoc_pydantic.css" type="text/css" />
Expand Down Expand Up @@ -98,8 +98,27 @@ <h1>Source code for optunaz.builder</h1><div class="highlight"><pre>
<span class="n">estimator</span> <span class="o">=</span> <span class="n">buildconfig</span><span class="o">.</span><span class="n">algorithm</span><span class="o">.</span><span class="n">estimator</span><span class="p">()</span>
<span class="k">if</span> <span class="n">merge_train_and_test_data</span><span class="p">:</span>
<span class="n">train_smiles</span><span class="p">,</span> <span class="n">train_y</span><span class="p">,</span> <span class="n">train_aux</span> <span class="o">=</span> <span class="n">buildconfig</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get_merged_sets</span><span class="p">()</span>
<span class="n">test_smiles</span><span class="p">,</span> <span class="n">test_y</span><span class="p">,</span> <span class="n">test_aux</span><span class="p">,</span> <span class="n">test_X</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">train_smiles</span><span class="p">,</span> <span class="n">train_y</span><span class="p">,</span> <span class="n">train_aux</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="n">buildconfig</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get_sets</span><span class="p">()</span>
<span class="p">(</span>
<span class="n">train_smiles</span><span class="p">,</span>
<span class="n">train_y</span><span class="p">,</span>
<span class="n">train_aux</span><span class="p">,</span>
<span class="n">test_smiles</span><span class="p">,</span>
<span class="n">test_y</span><span class="p">,</span>
<span class="n">test_aux</span><span class="p">,</span>
<span class="p">)</span> <span class="o">=</span> <span class="n">buildconfig</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get_sets</span><span class="p">()</span>
<span class="k">if</span> <span class="n">test_smiles</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">test_smiles</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">test_X</span><span class="p">,</span> <span class="n">failed_idx</span> <span class="o">=</span> <span class="n">descriptor_from_config</span><span class="p">(</span>
<span class="n">test_smiles</span><span class="p">,</span> <span class="n">buildconfig</span><span class="o">.</span><span class="n">descriptor</span><span class="p">,</span> <span class="n">cache</span><span class="o">=</span><span class="n">cache</span>
<span class="p">)</span>
<span class="n">test_y</span><span class="p">,</span> <span class="n">test_smiles</span><span class="p">,</span> <span class="n">test_aux</span> <span class="o">=</span> <span class="n">remove_failed_idx</span><span class="p">(</span>
<span class="n">failed_idx</span><span class="p">,</span> <span class="n">test_y</span><span class="p">,</span> <span class="n">test_smiles</span><span class="p">,</span> <span class="n">test_aux</span>
<span class="p">)</span>
<span class="k">if</span> <span class="n">test_aux</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">test_X</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hstack</span><span class="p">((</span><span class="n">test_X</span><span class="p">,</span> <span class="n">test_aux</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">test_X</span> <span class="o">=</span> <span class="kc">None</span>

<span class="n">train_X</span><span class="p">,</span> <span class="n">failed_idx</span> <span class="o">=</span> <span class="n">descriptor_from_config</span><span class="p">(</span>
<span class="n">train_smiles</span><span class="p">,</span> <span class="n">buildconfig</span><span class="o">.</span><span class="n">descriptor</span><span class="p">,</span> <span class="n">cache</span><span class="o">=</span><span class="n">cache</span>
Expand All @@ -116,15 +135,22 @@ <h1>Source code for optunaz.builder</h1><div class="highlight"><pre>
<span class="n">estimator</span><span class="o">.</span><span class="n">X_</span> <span class="o">=</span> <span class="n">train_X</span>
<span class="n">estimator</span><span class="o">.</span><span class="n">y_</span> <span class="o">=</span> <span class="n">train_y</span>
<span class="n">estimator</span><span class="o">.</span><span class="n">aux_</span> <span class="o">=</span> <span class="n">train_aux</span>

<span class="k">if</span> <span class="n">merge_train_and_test_data</span><span class="p">:</span>
<span class="n">train_scores</span> <span class="o">=</span> <span class="n">get_merged_train_score</span><span class="p">(</span><span class="n">estimator</span><span class="p">,</span> <span class="n">buildconfig</span><span class="p">,</span> <span class="n">cache</span><span class="o">=</span><span class="n">cache</span><span class="p">)</span>
<span class="n">test_scores</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">estimator</span><span class="o">.</span><span class="n">test_smiles_</span> <span class="o">=</span> <span class="n">test_smiles</span>
<span class="n">estimator</span><span class="o">.</span><span class="n">test_X_</span> <span class="o">=</span> <span class="n">test_X</span>
<span class="n">estimator</span><span class="o">.</span><span class="n">test_y_</span> <span class="o">=</span> <span class="n">test_y</span>
<span class="n">estimator</span><span class="o">.</span><span class="n">test_aux_</span> <span class="o">=</span> <span class="n">test_aux</span>

<span class="k">if</span> <span class="p">(</span>
<span class="ow">not</span> <span class="n">merge_train_and_test_data</span>
<span class="ow">and</span> <span class="n">test_smiles</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span>
<span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">test_smiles</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span>
<span class="p">):</span>
<span class="n">train_scores</span><span class="p">,</span> <span class="n">test_scores</span> <span class="o">=</span> <span class="n">get_train_test_scores</span><span class="p">(</span>
<span class="n">estimator</span><span class="p">,</span> <span class="n">buildconfig</span><span class="p">,</span> <span class="n">cache</span><span class="o">=</span><span class="n">cache</span>
<span class="n">estimator</span><span class="p">,</span> <span class="n">buildconfig</span><span class="p">,</span> <span class="n">train_X</span><span class="p">,</span> <span class="n">train_y</span><span class="p">,</span> <span class="n">test_X</span><span class="p">,</span> <span class="n">test_y</span>
<span class="p">)</span>

<span class="k">else</span><span class="p">:</span>
<span class="n">train_scores</span> <span class="o">=</span> <span class="n">get_merged_train_score</span><span class="p">(</span><span class="n">estimator</span><span class="p">,</span> <span class="n">buildconfig</span><span class="p">,</span> <span class="n">train_X</span><span class="p">,</span> <span class="n">train_y</span><span class="p">)</span>
<span class="n">test_scores</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">return</span> <span class="n">estimator</span><span class="p">,</span> <span class="n">train_scores</span><span class="p">,</span> <span class="n">test_scores</span></div>
</pre></div>

Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx-builddir/html/_modules/optunaz/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>optunaz.config &mdash; QSARtuna 3.1.2 documentation</title>
<title>optunaz.config &mdash; QSARtuna 3.1.3 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/autodoc_pydantic.css" type="text/css" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>optunaz.config.build_from_opt &mdash; QSARtuna 3.1.2 documentation</title>
<title>optunaz.config.build_from_opt &mdash; QSARtuna 3.1.3 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/autodoc_pydantic.css" type="text/css" />
Expand Down
Loading

0 comments on commit b509ff4

Please sign in to comment.