Skip to content

Commit

Permalink
Reuse arg_parse code in demo notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
mccalluc committed Oct 21, 2024
1 parent 3d97978 commit 4fdf1a5
Showing 1 changed file with 8 additions and 206 deletions.
214 changes: 8 additions & 206 deletions demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,227 +4,29 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This is just to demonstrate how the analysis will work for the POC, and also to show what the final exported notebook will look like. When that is implemented, get rid of this!\n",
"\n",
"First, generate a fake dataset. In the future, let's check it in and use it if the [`--demo` flag](https://github.com/opendp/dp-creator-ii/issues/7) is given."
"This is just to demonstrate how the analysis will work for the POC, and also to show what the final exported notebook will look like. When that is implemented, get rid of this!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Make mock \n",
"# Make fake dataset \n",
"\n",
"When [Add `--demo` CLI option](https://github.com/opendp/dp-creator-ii/pull/61) is merged, reference that code and delete these cells.\n"
"This will not be part of the final notebook!\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import csv\n",
"import random\n",
"\n",
"random.seed(0) # So the mock data will be stable across runs.\n",
"\n",
"def clip(n, lower, upper):\n",
" return max(min(n, upper), lower)\n",
"\n",
"csv_path = '/tmp/demo.csv'\n",
"\n",
"with open(csv_path, 'w', newline='') as demo_handle:\n",
" fields = ['student_id', 'class_year', 'hw_number', 'grade']\n",
" writer = csv.DictWriter(demo_handle, fieldnames=fields)\n",
" writer.writeheader()\n",
" for student_id in range(1, 100):\n",
" class_year = int(clip(random.gauss(2, 1), 1, 4))\n",
" mean_grade = random.gauss(80, 5) + class_year * 2\n",
" for hw_number in range(1, 10):\n",
" grade = int(clip(random.gauss(mean_grade, 5), 0, 100))\n",
" writer.writerow({\n",
" 'student_id': student_id,\n",
" 'class_year': class_year,\n",
" 'hw_number': hw_number,\n",
" 'grade': grade,\n",
" })"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Sanity check:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><style>\n",
".dataframe > thead > tr,\n",
".dataframe > tbody > tr {\n",
" text-align: right;\n",
" white-space: pre-wrap;\n",
"}\n",
"</style>\n",
"<small>shape: (891, 4)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>student_id</th><th>class_year</th><th>hw_number</th><th>grade</th></tr><tr><td>i64</td><td>i64</td><td>i64</td><td>i64</td></tr></thead><tbody><tr><td>1</td><td>2</td><td>1</td><td>73</td></tr><tr><td>1</td><td>2</td><td>2</td><td>78</td></tr><tr><td>1</td><td>2</td><td>3</td><td>71</td></tr><tr><td>1</td><td>2</td><td>4</td><td>76</td></tr><tr><td>1</td><td>2</td><td>5</td><td>77</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>99</td><td>2</td><td>5</td><td>78</td></tr><tr><td>99</td><td>2</td><td>6</td><td>74</td></tr><tr><td>99</td><td>2</td><td>7</td><td>75</td></tr><tr><td>99</td><td>2</td><td>8</td><td>72</td></tr><tr><td>99</td><td>2</td><td>9</td><td>82</td></tr></tbody></table></div>"
],
"text/plain": [
"shape: (891, 4)\n",
"┌────────────┬────────────┬───────────┬───────┐\n",
"│ student_id ┆ class_year ┆ hw_number ┆ grade │\n",
"│ --- ┆ --- ┆ --- ┆ --- │\n",
"│ i64 ┆ i64 ┆ i64 ┆ i64 │\n",
"╞════════════╪════════════╪═══════════╪═══════╡\n",
"│ 1 ┆ 2 ┆ 1 ┆ 73 │\n",
"│ 1 ┆ 2 ┆ 2 ┆ 78 │\n",
"│ 1 ┆ 2 ┆ 3 ┆ 71 │\n",
"│ 1 ┆ 2 ┆ 4 ┆ 76 │\n",
"│ 1 ┆ 2 ┆ 5 ┆ 77 │\n",
"│ … ┆ … ┆ … ┆ … │\n",
"│ 99 ┆ 2 ┆ 5 ┆ 78 │\n",
"│ 99 ┆ 2 ┆ 6 ┆ 74 │\n",
"│ 99 ┆ 2 ┆ 7 ┆ 75 │\n",
"│ 99 ┆ 2 ┆ 8 ┆ 72 │\n",
"│ 99 ┆ 2 ┆ 9 ┆ 82 │\n",
"└────────────┴────────────┴───────────┴───────┘"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import polars\n",
"from dp_creator_ii.argparse_helpers import _get_demo_csv_contrib\n",
"\n",
"lf = polars.scan_csv(csv_path)\n",
"lf.collect()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"TODO: Plot function from in https://github.com/opendp/dp-creator-ii/pull/35... but see farther down in the notebook: This can probably be further simplified."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"\n",
"def plot_error_bars_with_cutoff(\n",
" y_values, x_min_label=\"min\", x_max_label=\"max\", y_cutoff=0, y_error=0\n",
"):\n",
" x_values = 0.5 + np.arange(len(y_values))\n",
" x_values_above = []\n",
" x_values_below = []\n",
" y_values_above = []\n",
" y_values_below = []\n",
" for x, y in zip(x_values, y_values):\n",
" if y < y_cutoff:\n",
" x_values_below.append(x)\n",
" y_values_below.append(y)\n",
" else:\n",
" x_values_above.append(x)\n",
" y_values_above.append(y)\n",
"\n",
" figure, axes = plt.subplots()\n",
" color = \"skyblue\"\n",
" shared = {\n",
" \"width\": 0.8,\n",
" \"edgecolor\": color,\n",
" \"linewidth\": 1,\n",
" \"yerr\": y_error,\n",
" }\n",
" axes.bar(x_values_above, y_values_above, color=color, **shared)\n",
" axes.bar(x_values_below, y_values_below, color=\"white\", **shared)\n",
" axes.hlines([y_cutoff], 0, len(y_values), colors=[\"black\"], linestyles=[\"dotted\"])\n",
"\n",
" axes.set(xlim=(0, len(y_values)), ylim=(0, max(y_values)))\n",
" axes.get_xaxis().set_ticks(\n",
" ticks=[x_values[0], x_values[-1]],\n",
" labels=[x_min_label, x_max_label],\n",
" )\n",
" axes.get_yaxis().set_ticks([])"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><style>\n",
".dataframe > thead > tr,\n",
".dataframe > tbody > tr {\n",
" text-align: right;\n",
" white-space: pre-wrap;\n",
"}\n",
"</style>\n",
"<small>shape: (4, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>class_year</th><th>len</th></tr><tr><td>i64</td><td>u32</td></tr></thead><tbody><tr><td>1</td><td>414</td></tr><tr><td>2</td><td>297</td></tr><tr><td>3</td><td>126</td></tr><tr><td>4</td><td>54</td></tr></tbody></table></div>"
],
"text/plain": [
"shape: (4, 2)\n",
"┌────────────┬─────┐\n",
"│ class_year ┆ len │\n",
"│ --- ┆ --- │\n",
"│ i64 ┆ u32 │\n",
"╞════════════╪═════╡\n",
"│ 1 ┆ 414 │\n",
"│ 2 ┆ 297 │\n",
"│ 3 ┆ 126 │\n",
"│ 4 ┆ 54 │\n",
"└────────────┴─────┘"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"class_years = lf.group_by('class_year').len().collect().sort('class_year')\n",
"class_years"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAhAAAAGdCAYAAABDxkoSAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAWvklEQVR4nO3df4xd5Xng8efOjMceOJ7BiMQwwtZQhJpYZdkkgEWmItJihYSGLhslKZRSlqRYFQtJSlIlSIXLdlESUJTSgBXibhIS1NI0rExa0gZRQHiVgGENIVtgg4ncxK47jsD2jMcz9sz9sX+4Pp5rD8WPmWF+fT5SpJzXr+99Z87JnG/OneNTaTabzQAASGib6QUAAHOPgAAA0gQEAJ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vevKi+LMt5/U8jPie3/z3aj298VfrL2sZe6H/tOF5c+ILQO7YueuPfHSxoej2t8X6656f8vcb1z3kaj298Xz//BAOfbK0xuj2t8Xd37swpa53/mjq6La3xfPbLivHPvlT5+Jan9ffPm3z2uZe/9N10a1vy9+dP/6cuxfX/6nqPb3xRfef3bL3Adu/WRU+/viiW/dVY69+oufR7W/L2698MyWud//0uei2t8X//i128uxwZ3/EtX+vqj298XInt3l+N9/5dao9vfF33/l1nJsZM/ucu7gzn8px//xa7dHtb8vvv+lz7W8360XnhnV/r549Rc/L8ee+NZdUe3viwdu/WTL3C+8/+yo9vfFv778T+XYj+5fH9X+vrj/pmtb5n75t8+Lan9f/PKnz5Rjz2y4L6r9ffGdP7qqZe6dH7swqv198crTG8ux5//hgaj298U3rvtIy9x1V70/qv198dLGh8uxFx5/KKr9ffG1a36rZe5frL0sqv198dNHvl+Ovfzjx6La3xd3XXlRy9x7b7giqv19sflv7y/Htj73ZFT7++IrH35vy9y//ONrotrfF089cG85tv2F56La3xe3X/Kulrl/c/N/i2p/X2y8b13sH94bB/7tlygPncenQqWZeLXt27fHihUrpuzNAYC3zrZt2+L000+fktdKBUSj0YgdO3ZEs9mMlStXxrZt26K7u3tKFgIATJ2hoaFYsWJFbNu2LZYuXRp79+6N3t7e8mOgNyv1OxBtbW1x+umnx9DQUEREdHd3CwgAmMUOnat7enqm9HXdhQEApAkIACDtuAJi8eLFUa1WW27HAgBmj+k+V6d+iRIAIMJHGADAcRAQAECagAAA0gQEAJB2XAGxbt266OvriyVLlsTq1avj6aefnup1AQCT2LhxY1x66aXR29sblUolHnzwwZY/bzabccstt8Rpp50WXV1dsWbNmtiyZUvLnF27dsWVV14Z3d3dcdJJJ8UnPvGJGB4eTq0jHRDf/e5348Ybb4xqtRrPPvtsnHPOOXHxxRfHr371q+xLAQBJ+/bti3POOSfWrVs36Z/fcccd8dWvfjXuueee2LRpU5x44olx8cUXx/79+8s5V155ZbzwwgvxyCOPxEMPPRQbN26MtWvXptaRvo1z9erVcd5558Xdd98dEQefj7FixYq44YYb4vOf/3zqzQGA41epVGLDhg1x2WWXRcTBqw+9vb3xmc98Jj772c9GRMTg4GAsX7487r333rj88svjpZdeilWrVsUzzzwT5557bkRE/PCHP4xLLrkktm/fHr29vcf03qkrEGNjY7F58+ZYs2bN4Rdoa4s1a9bEk08+mXkpAGCKbd26NQYGBlrO0z09PbF69eryPP3kk0/GSSedVMZDRMSaNWuira0tNm3adMzvlQqIV199Ner1eixfvrxlfPny5TEwMJB5KQBgih06F/975+mBgYF4+9vf3vLnHR0dcfLJJ6fO5e7CAADSUgFxyimnRHt7e+zcubNlfOfOnXHqqadO6cIAgJxD5+J/7zx96qmnHnXjQ61Wi127dqXO5amA6OzsjPe85z3x6KOPlmONRiMeffTRuOCCCzIvBQBMsTPOOCNOPfXUlvP00NBQbNq0qTxPX3DBBbFnz57YvHlzOeexxx6LRqMRq1evPub36sgu7sYbb4yrr746zj333Dj//PPjzjvvjH379sU111yTfSkAIGl4eDheeeWVcnvr1q3xk5/8JE4++eRYuXJlfPrTn47bbrstzjrrrDjjjDPi5ptvjt7e3vJOjXe+853xgQ98IK699tq45557Ynx8PK6//vq4/PLLj/kOjIiIaB6Hu+66q7ly5cpmZ2dn8/zzz28+9dRTx/MyAEDS448/3oyIo/5z9dVXN5vNZrPRaDRvvvnm5vLly5uLFy9uXnTRRc2f/exnLa/x2muvNa+44opmURTN7u7u5jXXXNPcu3dvah0e5w0ApLkLAwBIExAAQJqAAADSBAQAkCYgAIA0AQEApAkIACBNQAAAaQICAEgTEABAmoAAANIEBACQ9v8BmyHfa7tyd54AAAAASUVORK5CYII=",
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"grades = lf.group_by('grade').len().collect().sort('grade')\n",
"min_grade = 0\n",
"max_grade = 100\n",
"df_0_100 = polars.from_dict({'grade': range(min_grade, max_grade+1)})\n",
"grades_0_100 = df_0_100.join(grades, on='grade', how='left').select(['len']).fill_null(0)\n",
"plot_error_bars_with_cutoff(grades_0_100.to_series().to_list(), min_grade, max_grade)"
"(csv_path, contributions) = _get_demo_csv_contrib()\n",
"assert csv_path == '/tmp/demo.csv'\n",
"assert contributions == 10\n"
]
},
{
Expand Down

0 comments on commit 4fdf1a5

Please sign in to comment.