|
37 | 37 | "cell_type": "markdown", |
38 | 38 | "metadata": {}, |
39 | 39 | "source": [ |
40 | | - "### Task 1 -- Part (a): look at the data\n", |
| 40 | + "### Task 1 -- Part (a): Look at the data\n", |
41 | 41 | "In the following code block, we import the ``load_penguins`` function from the ``palmerpenguins`` package.\n", |
42 | 42 | "\n", |
43 | 43 | "- Call this function, which returns a single object, and assign it to the variable ``data``.\n", |
|
79 | 79 | "outputs": [], |
80 | 80 | "source": [ |
81 | 81 | "# 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\"], " |
83 | 94 | ] |
84 | 95 | }, |
85 | 96 | { |
|
122 | 133 | "reducer = umap.UMAP(random_state=42)\n", |
123 | 134 | "embedding = reducer.fit_transform(scaled_penguin_data)\n", |
124 | 135 | "\n", |
125 | | - "colors = sns.color_palette()\n", |
126 | | - "\n", |
127 | 136 | "for i, (species, group) in enumerate(data.groupby(\"species\")):\n", |
128 | 137 | " plt.scatter(\n", |
129 | 138 | " embedding[data.species == species, 0],\n", |
130 | 139 | " embedding[data.species == species, 1],\n", |
131 | 140 | " label=species,\n", |
132 | | - " color=colors[i],\n", |
| 141 | + " color=species_palette[species],\n", |
133 | 142 | " )\n", |
134 | 143 | "\n", |
135 | 144 | "plt.gca().set_aspect(\"equal\", \"datalim\")\n", |
|
557 | 566 | "# Print the model architecture.\n", |
558 | 567 | "# print(res_model)\n", |
559 | 568 | "\n", |
560 | | - "list(res_model.parameters())" |
| 569 | + "# list(res_model.parameters())" |
561 | 570 | ] |
562 | 571 | }, |
563 | 572 | { |
|
795 | 804 | "\n", |
796 | 805 | " # zero the gradients (otherwise gradients accumulate)\n", |
797 | 806 | "\n", |
798 | | - " # run forward model and compute proxy probabilities over dimension 1 (columns of tensor).\n", |
| 807 | + " # run forward model to make predictions\n", |
799 | 808 | "\n", |
800 | 809 | " # compute loss\n", |
801 | 810 | " # e.g. pred : Tensor([3]) and target : int\n", |
802 | 811 | "\n", |
803 | 812 | " # compute gradients\n", |
804 | 813 | "\n", |
805 | | - " # nudge parameters in direction of steepest descent c\n", |
| 814 | + " # nudge parameters in direction of steepest descent\n", |
806 | 815 | "\n", |
807 | 816 | " # append metrics\n", |
808 | 817 | "\n", |
|
0 commit comments