Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed broken links and table of contents #616

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
521 changes: 451 additions & 70 deletions docs/tutorials/basic/Tutorial I Components.ipynb

Large diffs are not rendered by default.

191 changes: 125 additions & 66 deletions docs/tutorials/basic/Tutorial II Loop Constructs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Introduction\n",
"## Basic Tutorial II: Loop Constructs"
"# Basic Tutorial II: Loop Constructs\n",
"## Introduction"
]
},
{
Expand All @@ -16,12 +16,7 @@
"source": [
"**[AutoRA](https://pypi.org/project/autora/)** (**Au**tomated **R**esearch **A**ssistant) is an open-source framework designed to automate various stages of empirical research, including model discovery, experimental design, and data collection.\n",
"\n",
"This notebook is the second of four notebooks within the basic tutorials of ``autora``. We suggest that you go through these notebooks in order as each builds upon the last. However, each notebook is self-contained and so there is no need to *run* the content of the last notebook for your current notebook. We will here provide a link to each notebook, but we will also provide a link at the end of each notebook to navigate you to the next notebook.\n",
"\n",
"[AutoRA Basic Tutorial I: Components](https://autoresearch.github.io/autora/tutorials/basic/Tutorial-I-Components/) <br>\n",
"[AutoRA Basic Tutorial II: Loop Constructs](https://autoresearch.github.io/autora/tutorials/basic/Tutorial-II-Loop-Constructs/) <br>\n",
"[AutoRA Basic Tutorial III: Functional Workflow](https://autoresearch.github.io/autora/tutorials/basic/Tutorial-III-Functional-Workflow/) <br>\n",
"[AutoRA Basic Tutorial IV: Customization](https://autoresearch.github.io/autora/tutorials/basic/Tutorial-IV-Customization/) <br>\n",
"This notebook is the second of four notebooks within the basic tutorials of ``autora``. We suggest that you go through these notebooks in order as each builds upon the last. However, each notebook is self-contained and so there is no need to *run* the content of the last notebook for your current notebook. \n",
"\n",
"These notebooks provide a comprehensive introduction to the capabilities of ``autora``. **It demonstrates the fundamental components of ``autora``, and how they can be combined to facilitate automated (closed-loop) empirical research through synthetic experiments.**\n",
"\n",
Expand All @@ -33,7 +28,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Tutorial Setup\n",
"### Tutorial Setup\n",
"This tutorial is self-contained so that you do not need to run the previous notebook to begin. However, the four notebooks are continuous so that what we define in a previous notebook should still exist within this notebook. As such, we will here re-run relevant code from past tutorials. We will not again walk you through these, but if you need a reminder what they are then go see the descriptions in previous notebooks."
]
},
Expand All @@ -46,16 +41,9 @@
"name": "stderr",
"output_type": "stream",
"text": [
"\n",
"[notice] A new release of pip is available: 23.2 -> 23.3.1\n",
"[notice] To update, run: python.exe -m pip install --upgrade pip\n",
"WARNING: autora 3.1.1 does not provide the extra 'experimentalist-model-disagreement'\n",
"\n",
"[notice] A new release of pip is available: 23.2 -> 23.3.1\n",
"[notice] To update, run: python.exe -m pip install --upgrade pip\n",
"\n",
"[notice] A new release of pip is available: 23.2 -> 23.3.1\n",
"[notice] To update, run: python.exe -m pip install --upgrade pip\n"
"WARNING: typer 0.12.3 does not provide the extra 'all'\n",
"WARNING: typer 0.12.3 does not provide the extra 'all'\n",
"WARNING: typer 0.12.3 does not provide the extra 'all'\n"
]
}
],
Expand Down Expand Up @@ -101,7 +89,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Loop Constructs\n",
"## Loop Constructs\n",
"After defining all the components required for the empirical research process, we can create an automated workflow using basic loop constructs in Python.\n",
"\n",
"The following code block demonstrates how to build such a workflow using the components introduced in the preceding notebook, such as\n",
Expand Down Expand Up @@ -129,7 +117,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 1: Falsification Sampler"
"### Example 1: Falsification Sampler"
]
},
{
Expand All @@ -142,7 +130,7 @@
"output_type": "stream",
"text": [
"INFO:autora.theorist.bms.regressor:BMS fitting started\n",
"100%|██████████| 100/100 [00:04<00:00, 23.65it/s]\n",
"100%|██████████| 100/100 [00:04<00:00, 21.43it/s]\n",
"INFO:autora.theorist.bms.regressor:BMS fitting finished\n",
"INFO:autora.theorist.bms.regressor:BMS fitting started\n"
]
Expand All @@ -151,18 +139,18 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[[6.28318531]\n",
" [6.21971879]\n",
" [6.15625227]]\n",
"Loss in cycle 0: 1.0728386415534816\n",
"Discovered Model: 0.76\n"
"[[0. ]\n",
" [0.06346652]\n",
" [0.12693304]]\n",
"Loss in cycle 0: 0.99\n",
"Discovered Model: sin(X0)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 100/100 [00:04<00:00, 23.15it/s]\n",
"100%|██████████| 100/100 [00:04<00:00, 22.62it/s]\n",
"INFO:autora.theorist.bms.regressor:BMS fitting finished\n",
"INFO:autora.theorist.bms.regressor:BMS fitting started\n"
]
Expand All @@ -171,9 +159,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[[6.28318531]\n",
" [6.21971879]\n",
" [1.3962634 ]]\n",
"[[0. ]\n",
" [0.44426563]\n",
" [0.38079911]]\n",
"Loss in cycle 1: 0.99\n",
"Discovered Model: sin(X0)\n"
]
Expand All @@ -182,7 +170,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 100/100 [00:04<00:00, 20.20it/s]\n",
"100%|██████████| 100/100 [00:04<00:00, 20.91it/s]\n",
"INFO:autora.theorist.bms.regressor:BMS fitting finished\n",
"INFO:autora.theorist.bms.regressor:BMS fitting started\n"
]
Expand All @@ -191,18 +179,18 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[[4.25225672]\n",
" [4.31572324]\n",
" [4.1887902 ]]\n",
"Loss in cycle 2: inf\n",
"Discovered Model: (1.29 / X0)\n"
"[[0. ]\n",
" [0.57119866]\n",
" [0.63466518]]\n",
"Loss in cycle 2: 0.99\n",
"Discovered Model: sin(X0)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 100/100 [00:04<00:00, 24.55it/s]\n",
"100%|██████████| 100/100 [00:04<00:00, 20.60it/s]\n",
"INFO:autora.theorist.bms.regressor:BMS fitting finished\n",
"INFO:autora.theorist.bms.regressor:BMS fitting started\n"
]
Expand All @@ -212,27 +200,27 @@
"output_type": "stream",
"text": [
"[[0. ]\n",
" [0.06346652]\n",
" [0.12693304]]\n",
"Loss in cycle 3: 0.4973522295525592\n",
"Discovered Model: 0.05\n"
" [6.28318531]\n",
" [6.21971879]]\n",
"Loss in cycle 3: 0.99\n",
"Discovered Model: sin(X0)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 100/100 [00:04<00:00, 24.49it/s]\n",
"100%|██████████| 100/100 [00:04<00:00, 22.85it/s]\n",
"INFO:autora.theorist.bms.regressor:BMS fitting finished\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[0.06346652]\n",
" [0.12693304]\n",
" [0.19039955]]\n",
"[[6.28318531]\n",
" [6.21971879]\n",
" [6.15625227]]\n",
"Loss in cycle 4: 0.99\n",
"Discovered Model: sin(X0)\n"
]
Expand Down Expand Up @@ -286,7 +274,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 2: Model Disagreement Sampler\n",
"### Example 2: Model Disagreement Sampler\n",
"We can easily replace components in the workflow above.\n",
"\n",
"In the following code block, we add a linear regression theorist, to fit a linear model to the data. In addition, we replace ``falsification_sample`` with ``model_disagreement_sample`` to sample experimental conditions that differentiate most between the linear model and the model discovered by the BMS theorist."
Expand All @@ -302,30 +290,104 @@
"output_type": "stream",
"text": [
"INFO:autora.theorist.bms.regressor:BMS fitting started\n",
"100%|██████████| 100/100 [00:04<00:00, 23.55it/s]\n",
"INFO:autora.theorist.bms.regressor:BMS fitting finished\n"
"100%|██████████| 100/100 [00:04<00:00, 21.66it/s]\n",
"INFO:autora.theorist.bms.regressor:BMS fitting finished\n",
"INFO:autora.theorist.bms.regressor:BMS fitting started\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0\n",
"0 0.000000\n",
"1 0.063467\n",
"2 0.126933\n",
"Loss in cycle 0: 0.5027103676355225\n",
"Discovered BMS Model: -0.09\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 100/100 [00:04<00:00, 21.51it/s]\n",
"INFO:autora.theorist.bms.regressor:BMS fitting finished\n",
"INFO:autora.theorist.bms.regressor:BMS fitting started\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0\n",
"26 1.650129\n",
"25 1.586663\n",
"27 1.713596\n",
"Loss in cycle 1: 0.99\n",
"Discovered BMS Model: sin(X0)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 100/100 [00:04<00:00, 21.92it/s]\n",
"INFO:autora.theorist.bms.regressor:BMS fitting finished\n",
"INFO:autora.theorist.bms.regressor:BMS fitting started\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0\n",
"73 4.633056\n",
"74 4.696522\n",
"72 4.569589\n",
"Loss in cycle 2: 0.99\n",
"Discovered BMS Model: sin(X0)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 100/100 [00:04<00:00, 21.94it/s]\n",
"INFO:autora.theorist.bms.regressor:BMS fitting finished\n",
"INFO:autora.theorist.bms.regressor:BMS fitting started\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0\n",
"99 6.283185\n",
"98 6.219719\n",
"97 6.156252\n"
"28 1.777063\n",
"27 1.713596\n",
"29 1.840529\n",
"Loss in cycle 3: 0.99\n",
"Discovered BMS Model: sin(X0)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 100/100 [00:04<00:00, 24.37it/s]\n",
"INFO:autora.theorist.bms.regressor:BMS fitting finished\n"
]
},
{
"ename": "AttributeError",
"evalue": "'DataFrame' object has no attribute 'reshape'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_10828\\1882676081.py\u001b[0m in \u001b[0;36m?\u001b[1;34m()\u001b[0m\n\u001b[0;32m 29\u001b[0m \u001b[0mnew_observations\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrun_experiment\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnew_conditions\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 30\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 31\u001b[0m \u001b[1;31m# combine old and new conditions and observations\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 32\u001b[0m \u001b[0mconditions\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconcatenate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mconditions\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnew_conditions\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 33\u001b[1;33m \u001b[0mobservations\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconcatenate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobservations\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnew_observations\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 34\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 35\u001b[0m \u001b[1;31m# evaluate model of the theorist based on its ability to predict each observation from the ground truth, evaluated across the entire space of experimental conditions\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 36\u001b[0m \u001b[0mloss\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmean\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msquare\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtheorist_bms\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpredict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcondition_pool\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m-\u001b[0m \u001b[0mground_truth\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcondition_pool\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mc:\\Users\\cwill\\GitHub\\virtualEnvs\\autoraEnv\\lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36m?\u001b[1;34m(self, name)\u001b[0m\n\u001b[0;32m 5985\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mname\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_accessors\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5986\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_info_axis\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_can_hold_identifiers_and_holds_name\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5987\u001b[0m ):\n\u001b[0;32m 5988\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 5989\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mobject\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__getattribute__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mAttributeError\u001b[0m: 'DataFrame' object has no attribute 'reshape'"
"name": "stdout",
"output_type": "stream",
"text": [
" 0\n",
"71 4.506123\n",
"72 4.569589\n",
"70 4.442656\n",
"Loss in cycle 4: 0.99\n",
"Discovered BMS Model: sin(X0)\n"
]
}
],
Expand Down Expand Up @@ -375,11 +437,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Next Notebook\n",
"While the basic loop construct is flexible, there are more convenient ways to specify a research cycle in ``autora``. The next notebook illustrates the use of these constructs.\n",
"\n",
"Follow this link for the next notebook tutorial:\n",
"[AutoRA Basic Tutorial III: Functional Workflow](https://autoresearch.github.io/autora/tutorials/basic/Tutorial-III-Workflow-Logic/) <br>"
"## Next Notebook\n",
"While the basic loop construct is flexible, there are more convenient ways to specify a research cycle in ``autora``. The next notebook, **AutoRA Basic Tutorial III: Functional Workflow**, illustrates the use of these constructs.\n"
]
}
],
Expand Down
Loading
Loading