Skip to content

Commit 19622e8

Browse files
committed
Update pca_audio_features.ipynb
2D subplots for 3 features view angle
1 parent 13fb4ec commit 19622e8

File tree

1 file changed

+65
-3
lines changed

1 file changed

+65
-3
lines changed

pca_audio_features.ipynb

+65-3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,60 @@
144144
"## Plot Directions of the PCs and Original Data"
145145
]
146146
},
147+
{
148+
"cell_type": "code",
149+
"execution_count": null,
150+
"id": "3d0d6363",
151+
"metadata": {},
152+
"outputs": [],
153+
"source": [
154+
"fig = plt.figure()\n",
155+
"fig.set_size_inches(9,3)\n",
156+
"\n",
157+
"ax = fig.add_subplot(131)\n",
158+
"ax.plot(X[:, 0], X[:, 1], \".\", color=\"gray\", ms=1)\n",
159+
"ax.axis(\"square\")\n",
160+
"ax.set_xlabel(\"original feature 1: true_peak_lin\")\n",
161+
"ax.set_ylabel(\"original feature 2: rms_db\")\n",
162+
"ax.grid(True)\n",
163+
"\n",
164+
"ax = fig.add_subplot(132)\n",
165+
"ax.plot(X[:, 0], X[:, 2], \".\", color=\"gray\", ms=1)\n",
166+
"ax.axis(\"square\")\n",
167+
"ax.set_xlabel(\"original feature 1: true_peak_lin\")\n",
168+
"ax.set_ylabel(\"original feature 3: lufs_db\")\n",
169+
"ax.grid(True)\n",
170+
"\n",
171+
"ax = fig.add_subplot(133)\n",
172+
"ax.plot(X[:, 1], X[:, 2], \".\", color=\"gray\", ms=1)\n",
173+
"ax.axis(\"square\")\n",
174+
"ax.set_xlabel(\"original feature 2: rms_db\")\n",
175+
"ax.set_ylabel(\"original feature 3: lufs_db\")\n",
176+
"ax.grid(True)\n",
177+
"\n",
178+
"plt.tight_layout()"
179+
]
180+
},
181+
{
182+
"cell_type": "code",
183+
"execution_count": null,
184+
"id": "c5dd0957",
185+
"metadata": {},
186+
"outputs": [],
187+
"source": [
188+
"fig = plt.figure()\n",
189+
"ax = fig.add_subplot(111, projection=\"3d\")\n",
190+
"ax.plot(X[:, 0], X[:, 1], X[:, 2], \".\", color=\"gray\", ms=1)\n",
191+
"ax.axis(\"square\")\n",
192+
"ax.set_xlabel(\"original feature 1: true_peak_lin\")\n",
193+
"ax.set_ylabel(\"original feature 2: rms_db\")\n",
194+
"ax.set_zlabel(\"original feature 3: lufs_db\")\n",
195+
"ax.set_title(\"data cloud in original coordinate system\")\n",
196+
"ax.grid(True)\n",
197+
"ax.azim = -44\n",
198+
"ax.elev = 28"
199+
]
200+
},
147201
{
148202
"cell_type": "code",
149203
"execution_count": null,
@@ -174,7 +228,9 @@
174228
"ax.set_zlabel(\"original feature 3: lufs_db\")\n",
175229
"ax.set_title(\"data cloud in original coordinate system\")\n",
176230
"ax.legend()\n",
177-
"ax.grid(True)"
231+
"ax.grid(True)\n",
232+
"ax.azim = -44\n",
233+
"ax.elev = 28"
178234
]
179235
},
180236
{
@@ -235,7 +291,9 @@
235291
"ax.set_zlabel(\"PC 3\")\n",
236292
"ax.set_title(\"data cloud in PC coordinate system\")\n",
237293
"ax.legend()\n",
238-
"ax.grid(True)"
294+
"ax.grid(True)\n",
295+
"ax.azim = -37\n",
296+
"ax.elev = 28"
239297
]
240298
},
241299
{
@@ -306,7 +364,9 @@
306364
"ax.set_zlabel(\"new feature 3\")\n",
307365
"ax.set_title(\"rank-{0:d} approximation of data\".format(r_des))\n",
308366
"ax.legend()\n",
309-
"ax.grid(True)"
367+
"ax.grid(True)\n",
368+
"ax.azim = -44\n",
369+
"ax.elev = 28"
310370
]
311371
},
312372
{
@@ -380,6 +440,8 @@
380440
"plt.title(\"PCA data dimensionality reduction to {0:d}D\".format(dim_des))\n",
381441
"ax.legend()\n",
382442
"ax.grid(True)\n",
443+
"ax.azim = -37\n",
444+
"ax.elev = 28\n",
383445
"\n",
384446
"print(\"reduced to dimension\", X_dim_red.shape)"
385447
]

0 commit comments

Comments
 (0)