Charles Kabui
commited on
Commit
·
e5734d4
1
Parent(s):
21e70d3
starting colclutions
Browse files- analysis.ipynb +83 -0
analysis.ipynb
CHANGED
@@ -232,6 +232,75 @@
|
|
232 |
" ax.set_title(column)"
|
233 |
]
|
234 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
{
|
236 |
"cell_type": "markdown",
|
237 |
"metadata": {},
|
@@ -428,6 +497,20 @@
|
|
428 |
" width_parts=100,\n",
|
429 |
" height_parts=100)"
|
430 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
}
|
432 |
],
|
433 |
"metadata": {
|
|
|
232 |
" ax.set_title(column)"
|
233 |
]
|
234 |
},
|
235 |
+
{
|
236 |
+
"cell_type": "code",
|
237 |
+
"execution_count": null,
|
238 |
+
"metadata": {},
|
239 |
+
"outputs": [],
|
240 |
+
"source": [
|
241 |
+
"def correlation_fn(index: int):\n",
|
242 |
+
" vectors = vectors_df.loc[index, 'vectors']\n",
|
243 |
+
" weighted_vectors = vectors_df.loc[index, 'weighted_vectors']\n",
|
244 |
+
" reduced_vectors = vectors_df.loc[index, 'reduced_vectors']\n",
|
245 |
+
" reduced_weighted_vectors = vectors_df.loc[index, 'reduced_weighted_vectors']\n",
|
246 |
+
" return {\n",
|
247 |
+
" 'vectors vs weighted_vectors': pearsonr(vectors, weighted_vectors),\n",
|
248 |
+
" 'vectors vs reduced_vectors': pearsonr(vectors, reduced_vectors),\n",
|
249 |
+
" 'vectors vs reduced_weighted_vectors': pearsonr(vectors, reduced_weighted_vectors),\n",
|
250 |
+
" 'weighted_vectors vs reduced_vectors': pearsonr(weighted_vectors, reduced_vectors),\n",
|
251 |
+
" 'weighted_vectors vs reduced_weighted_vectors': pearsonr(weighted_vectors, reduced_weighted_vectors),\n",
|
252 |
+
" 'reduced_vectors vs reduced_weighted_vectors': pearsonr(reduced_vectors, reduced_weighted_vectors),\n",
|
253 |
+
" }\n",
|
254 |
+
"\n",
|
255 |
+
"correlation_results_2 = [correlation_fn(i) for i in tqdm.tqdm(range(len(vectors_df)))]"
|
256 |
+
]
|
257 |
+
},
|
258 |
+
{
|
259 |
+
"cell_type": "code",
|
260 |
+
"execution_count": null,
|
261 |
+
"metadata": {},
|
262 |
+
"outputs": [],
|
263 |
+
"source": [
|
264 |
+
"import matplotlib.pyplot as plt\n",
|
265 |
+
"\n",
|
266 |
+
"columns = list(correlation_results_2[0].keys())\n",
|
267 |
+
"fig, axes = plt.subplots(6, 2, figsize=(24, 24))\n",
|
268 |
+
"axes = axes.flatten()\n",
|
269 |
+
"for i, column in enumerate(columns):\n",
|
270 |
+
" ax = axes[i]\n",
|
271 |
+
" corr = [j[column][0] for j in correlation_results_2]\n",
|
272 |
+
" pvalues = [j[column][1] for j in correlation_results_2]\n",
|
273 |
+
" # ax.hist([j[column][0] for j in correlation_results_2], bins=100)\n",
|
274 |
+
" ax.plot(range(0, len(corr)), corr, label='Correlation', color='blue')\n",
|
275 |
+
" # ax.plot(range(0, len(pvalues)), pvalues, label='pvalues', color='red')\n",
|
276 |
+
" ax.set_title(column)"
|
277 |
+
]
|
278 |
+
},
|
279 |
+
{
|
280 |
+
"cell_type": "code",
|
281 |
+
"execution_count": null,
|
282 |
+
"metadata": {},
|
283 |
+
"outputs": [],
|
284 |
+
"source": [
|
285 |
+
"import matplotlib.pyplot as plt\n",
|
286 |
+
"\n",
|
287 |
+
"columns = list(correlation_results_2[0].keys())\n",
|
288 |
+
"fig, axes = plt.subplots(3, 2, figsize=(24, 24))\n",
|
289 |
+
"axes = axes.flatten()\n",
|
290 |
+
"for i, column in enumerate(columns):\n",
|
291 |
+
" ax = axes[i]\n",
|
292 |
+
" corr = [j[column][0] for j in correlation_results_2]\n",
|
293 |
+
" pvalues = [j[column][1] for j in correlation_results_2]\n",
|
294 |
+
" ax.plot(range(0, len(corr)), corr, label='correlation', color='blue')\n",
|
295 |
+
" ax.plot(range(0, len(pvalues)), pvalues, label='p-value', color='red')\n",
|
296 |
+
" ax.legend(bbox_to_anchor=(1, 0.1), loc='lower right')\n",
|
297 |
+
" ax.set_ylabel('correlation & p-value')\n",
|
298 |
+
" ax.set_xlabel(f'images - {column}')\n",
|
299 |
+
" ax.set_title(column)\n",
|
300 |
+
"\n",
|
301 |
+
"fig.savefig('/Users/charleskabue/Downloads/vector-correlations.png')"
|
302 |
+
]
|
303 |
+
},
|
304 |
{
|
305 |
"cell_type": "markdown",
|
306 |
"metadata": {},
|
|
|
497 |
" width_parts=100,\n",
|
498 |
" height_parts=100)"
|
499 |
]
|
500 |
+
},
|
501 |
+
{
|
502 |
+
"cell_type": "markdown",
|
503 |
+
"metadata": {},
|
504 |
+
"source": [
|
505 |
+
"<hr/>"
|
506 |
+
]
|
507 |
+
},
|
508 |
+
{
|
509 |
+
"cell_type": "code",
|
510 |
+
"execution_count": null,
|
511 |
+
"metadata": {},
|
512 |
+
"outputs": [],
|
513 |
+
"source": []
|
514 |
}
|
515 |
],
|
516 |
"metadata": {
|