Skip to content

Commit 75b5a94

Browse files
committed
Update solutions and exercises to be equivalent
1 parent aedb47a commit 75b5a94

File tree

2 files changed

+64
-28
lines changed

2 files changed

+64
-28
lines changed

exercises/01_penguin_classification.ipynb

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"cell_type": "markdown",
3838
"metadata": {},
3939
"source": [
40-
"### Task 1 -- Part (a): look at the data\n",
40+
"### Task 1 -- Part (a): Look at the data\n",
4141
"In the following code block, we import the ``load_penguins`` function from the ``palmerpenguins`` package.\n",
4242
"\n",
4343
"- Call this function, which returns a single object, and assign it to the variable ``data``.\n",
@@ -79,7 +79,18 @@
7979
"outputs": [],
8080
"source": [
8181
"# import seaborn as sns\n",
82-
"# sns.pairplot(data.drop(\"year\", axis=1), hue='species')"
82+
"\n",
83+
"# species_palette = {\n",
84+
"# \"Adelie\": sns.color_palette()[0], # Blue\n",
85+
"# \"Chinstrap\": sns.color_palette()[1], # Orange\n",
86+
"# \"Gentoo\": sns.color_palette()[2], # Green\n",
87+
"# }\n",
88+
"\n",
89+
"# sns.pairplot(\n",
90+
"# data.drop(\"year\", axis=1),\n",
91+
"# hue=\"species\",\n",
92+
"# palette=species_palette,\n",
93+
"# hue_order=[\"Adelie\", \"Chinstrap\", \"Gentoo\"], "
8394
]
8495
},
8596
{
@@ -122,14 +133,12 @@
122133
"reducer = umap.UMAP(random_state=42)\n",
123134
"embedding = reducer.fit_transform(scaled_penguin_data)\n",
124135
"\n",
125-
"colors = sns.color_palette()\n",
126-
"\n",
127136
"for i, (species, group) in enumerate(data.groupby(\"species\")):\n",
128137
" plt.scatter(\n",
129138
" embedding[data.species == species, 0],\n",
130139
" embedding[data.species == species, 1],\n",
131140
" label=species,\n",
132-
" color=colors[i],\n",
141+
" color=species_palette[species],\n",
133142
" )\n",
134143
"\n",
135144
"plt.gca().set_aspect(\"equal\", \"datalim\")\n",
@@ -557,7 +566,7 @@
557566
"# Print the model architecture.\n",
558567
"# print(res_model)\n",
559568
"\n",
560-
"list(res_model.parameters())"
569+
"# list(res_model.parameters())"
561570
]
562571
},
563572
{
@@ -795,14 +804,14 @@
795804
"\n",
796805
" # zero the gradients (otherwise gradients accumulate)\n",
797806
"\n",
798-
" # run forward model and compute proxy probabilities over dimension 1 (columns of tensor).\n",
807+
" # run forward model to make predictions\n",
799808
"\n",
800809
" # compute loss\n",
801810
" # e.g. pred : Tensor([3]) and target : int\n",
802811
"\n",
803812
" # compute gradients\n",
804813
"\n",
805-
" # nudge parameters in direction of steepest descent c\n",
814+
" # nudge parameters in direction of steepest descent\n",
806815
"\n",
807816
" # append metrics\n",
808817
"\n",

worked-solutions/01_penguin_classification_solutions.ipynb

Lines changed: 47 additions & 20 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)