Skip to content

Commit

Permalink
Make dataset tutorial runnable on website docs, improve pulldown form…
Browse files Browse the repository at this point in the history
…atting (cleanlab#220)

* tutorial runnable on website, pulldown formatting

* add note re pulldown for colab users

* darkDF, remove auto-overflow handling

* tell colab users they can ignore bottom checks
  • Loading branch information
jwmueller authored Apr 16, 2022
1 parent 335586f commit 766c13b
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 46 deletions.
9 changes: 8 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,14 @@
.output_area {
max-height: 300px;
overflow: auto;
}
.dataframe {
background: #D7D7D7;
}
th {
color:black;
}
</style>
Expand Down
6 changes: 4 additions & 2 deletions docs/source/tutorials/audio.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
},
"outputs": [],
"source": [
"# Package installation (hidden on docs website).\n",
"dependencies = [\"cleanlab\", \"speechbrain\", \"tensorflow_io\", \"tensorflow\", \"sklearn\"]\n",
"\n",
"if \"google.colab\" in str(get_ipython()): # Check if it's running in Google Colab\n",
Expand Down Expand Up @@ -638,8 +639,9 @@
},
"outputs": [],
"source": [
"# Hidden code cell to check if the examples highlighted here were found in find_label_issues\n",
"highlighted_indices = [1946, 516, 469, 2132]\n",
"# Note: This cell is only for docs.cleanlab.ai, if running on local Jupyter or Colab, please ignore it.\n",
"\n",
"highlighted_indices = [1946, 516, 469, 2132] # verify these examples were found in find_label_issues\n",
"if not all(x in label_issues_indices for x in highlighted_indices):\n",
" raise Exception(\"Some highlighted examples are missing from label_issues_indices.\")"
]
Expand Down
76 changes: 69 additions & 7 deletions docs/source/tutorials/dataset_health.ipynb

Large diffs are not rendered by default.

42 changes: 26 additions & 16 deletions docs/source/tutorials/image.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
},
"outputs": [],
"source": [
"# Package installation (hidden on docs website).\n",
"dependencies = [\"cleanlab\", \"matplotlib\", \"torch\", \"torchvision\", \"skorch\"]\n",
"\n",
"if \"google.colab\" in str(get_ipython()): # Check if it's running in Google Colab\n",
Expand Down Expand Up @@ -301,19 +302,36 @@
]
},
{
"cell_type": "raw",
"cell_type": "markdown",
"metadata": {},
"source": [
"<!-- This cell is for the collapsible block in the doc site -->\n",
"<details><summary>Below is the code used for plotting.</summary>\n",
"\n",
"```\n",
"\n",
"# Note: This pulldown content is for docs.cleanlab.ai, if running on local Jupyter or Colab, please ignore it.\n",
"\n",
"import matplotlib.pyplot as plt\n",
"\n",
"def plot_examples(id_iter, nrows=1, ncols=1):\n",
" for count, id in enumerate(id_iter):\n",
" plt.subplot(nrows, ncols, count + 1)\n",
" plt.imshow(X[id].reshape(28, 28), cmap=\"gray\")\n",
" plt.title(f\"id: {id} \\n label: {y[id]}\")\n",
" plt.axis(\"off\")\n",
"\n",
" plt.tight_layout(h_pad=2.0)\n",
"\n",
"<details>\n",
" <summary markdown=\"1\">Click here to view its code.</summary>"
"```\n",
"</details>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"nbsphinx": "hidden"
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
Expand All @@ -328,15 +346,6 @@
" plt.tight_layout(h_pad=2.0)"
]
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"<!-- This cell is for the collapsible block in the doc site -->\n",
"\n",
"</details>"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -441,8 +450,9 @@
},
"outputs": [],
"source": [
"# Hidden code cell to check if the examples highlighted here were found in find_label_issues\n",
"highlighted_indices = [59915, 24798, 59701, 50340]\n",
"# Note: This cell is only for docs.cleanlab.ai, if running on local Jupyter or Colab, please ignore it.\n",
"\n",
"highlighted_indices = [59915, 24798, 59701, 50340] # verify these examples were found by find_label_issues\n",
"if not all(x in ranked_label_issues for x in highlighted_indices):\n",
" raise Exception(\"Some highlighted examples are missing from ranked_label_issues.\")"
]
Expand Down
21 changes: 5 additions & 16 deletions docs/source/tutorials/indepth_overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"outputs": [],
"source": [
"# Package installation.\n",
"# Package installation (hidden on docs website).\n",
"dependencies = [\"cleanlab\", \"sklearn\", \"matplotlib\"]\n",
"\n",
"if \"google.colab\" in str(get_ipython()): # Check if it's running in Google Colab\n",
Expand All @@ -75,20 +75,7 @@
" print(*missing_dependencies, sep=\", \")\n",
" print(\"\\nPlease install them before running the rest of this notebook.\")\n",
"\n",
"%config InlineBackend.print_figure_kwargs={\"facecolor\": \"w\"}\n",
"\n",
"from IPython.core.display import HTML\n",
"HTML(\"\"\"\n",
"<style>\n",
" .dataframe {\n",
" background: #D7D7D7;\n",
" }\n",
" \n",
" th {\n",
" color:black;\n",
" }\n",
"</style>\n",
"\"\"\")"
"%config InlineBackend.print_figure_kwargs={\"facecolor\": \"w\"}"
]
},
{
Expand Down Expand Up @@ -122,10 +109,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<details><summary>Click here to see data-generation code</summary>\n",
"<details><summary>Below is the code used for data-generation.</summary>\n",
"\n",
"```\n",
"\n",
"# Note: This pulldown content is for docs.cleanlab.ai, if running on local Jupyter or Colab, please ignore it.\n",
"\n",
"SEED = 0\n",
"\n",
"def make_data(\n",
Expand Down
6 changes: 4 additions & 2 deletions docs/source/tutorials/tabular.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
},
"outputs": [],
"source": [
"# Package installation (hidden on docs website).\n",
"dependencies = [\"cleanlab\", \"sklearn\"]\n",
"\n",
"if \"google.colab\" in str(get_ipython()): # Check if it's running in Google Colab\n",
Expand Down Expand Up @@ -400,8 +401,9 @@
},
"outputs": [],
"source": [
"# Hidden code cell to check that cleanlab has improved prediction accuracy\n",
"if acc_og >= acc_cl:\n",
"# Note: This cell is only for docs.cleanlab.ai, if running on local Jupyter or Colab, please ignore it.\n",
"\n",
"if acc_og >= acc_cl: # check cleanlab has improved prediction accuracy\n",
" raise Exception(\"Cleanlab training failed to improve model accuracy.\")"
]
}
Expand Down
6 changes: 4 additions & 2 deletions docs/source/tutorials/text.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
},
"outputs": [],
"source": [
"# Package installation (hidden on docs website).\n",
"dependencies = [\"cleanlab\", \"sklearn\", \"tensorflow\", \"tensorflow_datasets\", \"scikeras\"]\n",
"\n",
"if \"google.colab\" in str(get_ipython()): # Check if it's running in Google Colab\n",
Expand Down Expand Up @@ -651,8 +652,9 @@
},
"outputs": [],
"source": [
"# Hidden code cell to check if the examples highlighted here were found in find_label_issues\n",
"highlighted_indices = [44582, 10404, 30151]\n",
"# Note: This cell is only for docs.cleanlab.ai, if running on local Jupyter or Colab, please ignore it.\n",
"\n",
"highlighted_indices = [44582, 10404, 30151] # check these examples were found in find_label_issues\n",
"if not all(x in ranked_label_issues for x in highlighted_indices):\n",
" raise Exception(\"Some highlighted examples are missing from ranked_label_issues.\")\n",
"\n",
Expand Down

0 comments on commit 766c13b

Please sign in to comment.