Skip to content

Commit

Permalink
Ravin Kohli: Merge pull request #83 from franchuterivera/refactor_dev…
Browse files Browse the repository at this point in the history
…elopment_docs
  • Loading branch information
Github Actions committed Feb 2, 2021
1 parent 442354e commit a28a385
Show file tree
Hide file tree
Showing 32 changed files with 275 additions and 544 deletions.
2 changes: 1 addition & 1 deletion refactor_development/.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: 395ef1b736268e6c59361d91832ecd27
config: badc6677826ff369d0cd924e63d913f3
tags: 645f666f9bcd5a90fca523b33c5a78b7
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
The following example shows how to fit a sample classification model
with AutoPyTorch
"""
import os
import tempfile as tmp
import typing
import warnings

os.environ['JOBLIB_TEMP_FOLDER'] = tmp.gettempdir()
os.environ['OMP_NUM_THREADS'] = '1'
os.environ['OPENBLAS_NUM_THREADS'] = '1'
os.environ['MKL_NUM_THREADS'] = '1'

warnings.simplefilter(action='ignore', category=UserWarning)
warnings.simplefilter(action='ignore', category=FutureWarning)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.7"
}
},
"nbformat": 4,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"outputs": [],
"source": [
"import typing\nimport warnings\n\nwarnings.simplefilter(action='ignore', category=UserWarning)\nwarnings.simplefilter(action='ignore', category=FutureWarning)\n\nimport sklearn.datasets\nimport sklearn.model_selection\n\nfrom autoPyTorch.api.tabular_classification import TabularClassificationTask\nfrom autoPyTorch.datasets.tabular_dataset import TabularDataset\nfrom autoPyTorch.utils.hyperparameter_search_space_update import HyperparameterSearchSpaceUpdates\n\n\n# Get the training data for tabular classification\ndef get_data_to_train() -> typing.Tuple[typing.Any, typing.Any, typing.Any, typing.Any]:\n \"\"\"\n This function returns a fit dictionary that within itself, contains all\n the information to fit a pipeline\n \"\"\"\n\n # Get the training data for tabular classification\n # Move to Australian to showcase numerical vs categorical\n X, y = sklearn.datasets.fetch_openml(data_id=40981, return_X_y=True, as_frame=True)\n X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(\n X,\n y,\n random_state=1,\n )\n\n return X_train, X_test, y_train, y_test\n\n\ndef get_search_space_updates():\n \"\"\"\n Search space updates to the task can be added using HyperparameterSearchSpaceUpdates\n Returns:\n HyperparameterSearchSpaceUpdates\n \"\"\"\n updates = HyperparameterSearchSpaceUpdates()\n updates.append(node_name=\"data_loader\",\n hyperparameter=\"batch_size\",\n value_range=[16, 512],\n default_value=32)\n updates.append(node_name=\"lr_scheduler\",\n hyperparameter=\"CosineAnnealingLR:T_max\",\n value_range=[50, 60],\n default_value=55)\n updates.append(node_name='network_backbone',\n hyperparameter='ResNetBackbone:dropout',\n value_range=[0, 0.5],\n default_value=0.2)\n return updates\n\n\nif __name__ == '__main__':\n ############################################################################\n # Data Loading\n # ============\n X_train, X_test, y_train, y_test = get_data_to_train()\n datamanager = TabularDataset(\n X=X_train, Y=y_train,\n X_test=X_test, Y_test=y_test)\n\n ############################################################################\n # Build and fit a classifier\n # ==========================\n api = TabularClassificationTask(\n delete_tmp_folder_after_terminate=False,\n search_space_updates=get_search_space_updates()\n )\n api.search(\n dataset=datamanager,\n optimize_metric='accuracy',\n total_walltime_limit=500,\n func_eval_time_limit=150\n )\n\n ############################################################################\n # Print the final ensemble performance\n # ====================================\n print(api.run_history, api.trajectory)\n y_pred = api.predict(X_test)\n score = api.score(y_pred, y_test)\n print(score)"
"import os\nimport tempfile as tmp\nimport typing\nimport warnings\n\nos.environ['JOBLIB_TEMP_FOLDER'] = tmp.gettempdir()\nos.environ['OMP_NUM_THREADS'] = '1'\nos.environ['OPENBLAS_NUM_THREADS'] = '1'\nos.environ['MKL_NUM_THREADS'] = '1'\n\nwarnings.simplefilter(action='ignore', category=UserWarning)\nwarnings.simplefilter(action='ignore', category=FutureWarning)\n\nimport sklearn.datasets\nimport sklearn.model_selection\n\nfrom autoPyTorch.api.tabular_classification import TabularClassificationTask\nfrom autoPyTorch.datasets.tabular_dataset import TabularDataset\nfrom autoPyTorch.utils.hyperparameter_search_space_update import HyperparameterSearchSpaceUpdates\n\n\n# Get the training data for tabular classification\ndef get_data_to_train() -> typing.Tuple[typing.Any, typing.Any, typing.Any, typing.Any]:\n \"\"\"\n This function returns a fit dictionary that within itself, contains all\n the information to fit a pipeline\n \"\"\"\n\n # Get the training data for tabular classification\n # Move to Australian to showcase numerical vs categorical\n X, y = sklearn.datasets.fetch_openml(data_id=40981, return_X_y=True, as_frame=True)\n X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(\n X,\n y,\n random_state=1,\n )\n\n return X_train, X_test, y_train, y_test\n\n\ndef get_search_space_updates():\n \"\"\"\n Search space updates to the task can be added using HyperparameterSearchSpaceUpdates\n Returns:\n HyperparameterSearchSpaceUpdates\n \"\"\"\n updates = HyperparameterSearchSpaceUpdates()\n updates.append(node_name=\"data_loader\",\n hyperparameter=\"batch_size\",\n value_range=[16, 512],\n default_value=32)\n updates.append(node_name=\"lr_scheduler\",\n hyperparameter=\"CosineAnnealingLR:T_max\",\n value_range=[50, 60],\n default_value=55)\n updates.append(node_name='network_backbone',\n hyperparameter='ResNetBackbone:dropout',\n value_range=[0, 0.5],\n default_value=0.2)\n return updates\n\n\nif __name__ == '__main__':\n ############################################################################\n # Data Loading\n # ============\n X_train, X_test, y_train, y_test = get_data_to_train()\n datamanager = TabularDataset(\n X=X_train, Y=y_train,\n X_test=X_test, Y_test=y_test)\n\n ############################################################################\n # Build and fit a classifier\n # ==========================\n api = TabularClassificationTask(\n delete_tmp_folder_after_terminate=False,\n search_space_updates=get_search_space_updates()\n )\n api.search(\n dataset=datamanager,\n optimize_metric='accuracy',\n total_walltime_limit=500,\n func_eval_time_limit=150\n )\n\n ############################################################################\n # Print the final ensemble performance\n # ====================================\n print(api.run_history, api.trajectory)\n y_pred = api.predict(X_test)\n score = api.score(y_pred, y_test)\n print(score)"
]
}
],
Expand All @@ -46,7 +46,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.7"
}
},
"nbformat": 4,
Expand Down
Binary file not shown.
8 changes: 4 additions & 4 deletions refactor_development/_modules/autoPyTorch/api/base_task.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

</head><body>

<a href="https://github.com/automl/auto-sklearn"
<a href="https://github.com/automl/Auto-PyTorch"
class="visible-desktop hidden-xs"><img
id="gh-banner"
style="position: absolute; top: 50px; right: 0; border: 0;"
Expand Down Expand Up @@ -328,7 +328,7 @@ <h1>Source code for autoPyTorch.api.base_task</h1><div class="highlight"><pre>
<span class="sd"> then sets them to the current pipeline</span>
<span class="sd"> configuration.</span>
<span class="sd"> Args:</span>
<span class="sd"> **pipeline_config_kwargs: Valid config options include &quot;job_id&quot;,</span>
<span class="sd"> **pipeline_config_kwargs: Valid config options include &quot;num_run&quot;,</span>
<span class="sd"> &quot;device&quot;, &quot;budget_type&quot;, &quot;epochs&quot;, &quot;runtime&quot;, &quot;torch_num_threads&quot;,</span>
<span class="sd"> &quot;early_stopping&quot;, &quot;use_tensorboard_logger&quot;, &quot;use_pynisher&quot;,</span>
<span class="sd"> &quot;metrics_during_training&quot;</span>
Expand Down Expand Up @@ -1035,7 +1035,7 @@ <h1>Source code for autoPyTorch.api.base_task</h1><div class="highlight"><pre>
<span class="s1">&#39;train_indices&#39;</span><span class="p">:</span> <span class="n">dataset</span><span class="o">.</span><span class="n">splits</span><span class="p">[</span><span class="n">split_id</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span>
<span class="s1">&#39;val_indices&#39;</span><span class="p">:</span> <span class="n">dataset</span><span class="o">.</span><span class="n">splits</span><span class="p">[</span><span class="n">split_id</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span>
<span class="s1">&#39;split_id&#39;</span><span class="p">:</span> <span class="n">split_id</span><span class="p">,</span>
<span class="s1">&#39;job_id&#39;</span><span class="p">:</span> <span class="mi">0</span>
<span class="s1">&#39;num_run&#39;</span><span class="p">:</span> <span class="mi">0</span>
<span class="p">})</span>
<span class="n">X</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">pipeline_options</span><span class="p">,</span> <span class="o">**</span><span class="n">budget_config</span><span class="p">})</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">models_</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">models_</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">ensemble_</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
Expand Down Expand Up @@ -1108,7 +1108,7 @@ <h1>Source code for autoPyTorch.api.base_task</h1><div class="highlight"><pre>
<span class="s1">&#39;train_indices&#39;</span><span class="p">:</span> <span class="n">dataset</span><span class="o">.</span><span class="n">splits</span><span class="p">[</span><span class="n">split_id</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span>
<span class="s1">&#39;val_indices&#39;</span><span class="p">:</span> <span class="n">dataset</span><span class="o">.</span><span class="n">splits</span><span class="p">[</span><span class="n">split_id</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span>
<span class="s1">&#39;split_id&#39;</span><span class="p">:</span> <span class="n">split_id</span><span class="p">,</span>
<span class="s1">&#39;job_id&#39;</span><span class="p">:</span> <span class="mi">0</span>
<span class="s1">&#39;num_run&#39;</span><span class="p">:</span> <span class="mi">0</span>
<span class="p">})</span>
<span class="n">X</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">pipeline_options</span><span class="p">,</span> <span class="o">**</span><span class="n">budget_config</span><span class="p">})</span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

</head><body>

<a href="https://github.com/automl/auto-sklearn"
<a href="https://github.com/automl/Auto-PyTorch"
class="visible-desktop hidden-xs"><img
id="gh-banner"
style="position: absolute; top: 50px; right: 0; border: 0;"
Expand Down
2 changes: 1 addition & 1 deletion refactor_development/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

</head><body>

<a href="https://github.com/automl/auto-sklearn"
<a href="https://github.com/automl/Auto-PyTorch"
class="visible-desktop hidden-xs"><img
id="gh-banner"
style="position: absolute; top: 50px; right: 0; border: 0;"
Expand Down

0 comments on commit a28a385

Please sign in to comment.