mirror of
https://github.com/20kaushik02/CSE515_MWDB_Project.git
synced 2025-12-06 07:54:07 +00:00
197 lines
7.8 KiB
Plaintext
197 lines
7.8 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from utils import *\n",
|
|
"warnings.filterwarnings('ignore')\n",
|
|
"%matplotlib inline\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"fd_collection = getCollection(\"team_5_mwdb_phase_2\", \"fd_collection\")\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Applying svd on the given similarity matrix to get 10 latent semantics (showing only top 10 image-weight pairs for each latent semantic)...\n",
|
|
"Latent semantic no. 0\n",
|
|
"image\t4327\t-\tWeight\t0.06387300915798859\n",
|
|
"image\t1653\t-\tWeight\t0.06225930582406118\n",
|
|
"image\t4309\t-\tWeight\t0.06095954690299202\n",
|
|
"image\t4329\t-\tWeight\t0.05889167793151601\n",
|
|
"image\t4318\t-\tWeight\t0.057637806985593974\n",
|
|
"image\t2325\t-\tWeight\t0.05612114732712442\n",
|
|
"image\t106\t-\tWeight\t0.0553241190050714\n",
|
|
"image\t4315\t-\tWeight\t0.05421665176601695\n",
|
|
"image\t3627\t-\tWeight\t0.05399516331236024\n",
|
|
"image\t4310\t-\tWeight\t0.053878520320048216\n",
|
|
"Latent semantic no. 1\n",
|
|
"image\t926\t-\tWeight\t0.05969523866379485\n",
|
|
"image\t900\t-\tWeight\t0.05738047297133547\n",
|
|
"image\t826\t-\tWeight\t0.05737642454934881\n",
|
|
"image\t868\t-\tWeight\t0.05734058503897999\n",
|
|
"image\t895\t-\tWeight\t0.05679076771674271\n",
|
|
"image\t904\t-\tWeight\t0.05665906456098433\n",
|
|
"image\t894\t-\tWeight\t0.05659729687888854\n",
|
|
"image\t892\t-\tWeight\t0.05637734281187336\n",
|
|
"image\t896\t-\tWeight\t0.05626000549868052\n",
|
|
"image\t901\t-\tWeight\t0.05621099897239924\n",
|
|
"Latent semantic no. 2\n",
|
|
"image\t3685\t-\tWeight\t0.03814215214744671\n",
|
|
"image\t3049\t-\tWeight\t0.036692586102556525\n",
|
|
"image\t4152\t-\tWeight\t0.03586290113404638\n",
|
|
"image\t4219\t-\tWeight\t0.03489203423252102\n",
|
|
"image\t3208\t-\tWeight\t0.034624460148066645\n",
|
|
"image\t4015\t-\tWeight\t0.034128851806262454\n",
|
|
"image\t3838\t-\tWeight\t0.03287941968649245\n",
|
|
"image\t3544\t-\tWeight\t0.03241416766297603\n",
|
|
"image\t4313\t-\tWeight\t0.03231321369753675\n",
|
|
"image\t3999\t-\tWeight\t0.0320836528785244\n",
|
|
"Latent semantic no. 3\n",
|
|
"image\t3892\t-\tWeight\t0.06648490667589399\n",
|
|
"image\t3827\t-\tWeight\t0.06563860391481106\n",
|
|
"image\t4285\t-\tWeight\t0.06444388987867274\n",
|
|
"image\t2076\t-\tWeight\t0.0632874253246352\n",
|
|
"image\t3745\t-\tWeight\t0.059842032954945085\n",
|
|
"image\t2563\t-\tWeight\t0.058523031976053054\n",
|
|
"image\t3884\t-\tWeight\t0.05599712556112116\n",
|
|
"image\t3890\t-\tWeight\t0.05593428984607223\n",
|
|
"image\t1402\t-\tWeight\t0.055899080338839564\n",
|
|
"image\t2665\t-\tWeight\t0.05546907037179164\n",
|
|
"Latent semantic no. 4\n",
|
|
"image\t3915\t-\tWeight\t0.046851797776368324\n",
|
|
"image\t474\t-\tWeight\t0.04434329032960532\n",
|
|
"image\t1536\t-\tWeight\t0.04432346480047559\n",
|
|
"image\t475\t-\tWeight\t0.04072813117892643\n",
|
|
"image\t4255\t-\tWeight\t0.040667016325110085\n",
|
|
"image\t3406\t-\tWeight\t0.04040216466729356\n",
|
|
"image\t525\t-\tWeight\t0.04029068846509459\n",
|
|
"image\t470\t-\tWeight\t0.03997152944980991\n",
|
|
"image\t1384\t-\tWeight\t0.03934508125909288\n",
|
|
"image\t3357\t-\tWeight\t0.038333999492323516\n",
|
|
"Latent semantic no. 5\n",
|
|
"image\t3956\t-\tWeight\t0.060011760982094924\n",
|
|
"image\t2767\t-\tWeight\t0.056207067311306175\n",
|
|
"image\t2775\t-\tWeight\t0.05358938347103485\n",
|
|
"image\t3902\t-\tWeight\t0.04905728202908321\n",
|
|
"image\t3099\t-\tWeight\t0.048312802387355414\n",
|
|
"image\t2794\t-\tWeight\t0.04816327335760051\n",
|
|
"image\t3638\t-\tWeight\t0.047326856090526045\n",
|
|
"image\t2951\t-\tWeight\t0.04694598325565932\n",
|
|
"image\t2493\t-\tWeight\t0.04693933314957065\n",
|
|
"image\t1519\t-\tWeight\t0.04692793968385709\n",
|
|
"Latent semantic no. 6\n",
|
|
"image\t899\t-\tWeight\t0.0557700158434989\n",
|
|
"image\t901\t-\tWeight\t0.05385589776037553\n",
|
|
"image\t903\t-\tWeight\t0.05326609068648323\n",
|
|
"image\t892\t-\tWeight\t0.05278963837571468\n",
|
|
"image\t893\t-\tWeight\t0.05252069078249831\n",
|
|
"image\t895\t-\tWeight\t0.052452644917562574\n",
|
|
"image\t894\t-\tWeight\t0.050699354240581404\n",
|
|
"image\t896\t-\tWeight\t0.049699837882682285\n",
|
|
"image\t898\t-\tWeight\t0.04862913600225998\n",
|
|
"image\t821\t-\tWeight\t0.048576878816213136\n",
|
|
"Latent semantic no. 7\n",
|
|
"image\t1171\t-\tWeight\t0.03313529748848967\n",
|
|
"image\t1350\t-\tWeight\t0.0331120998877209\n",
|
|
"image\t1069\t-\tWeight\t0.03307893455959305\n",
|
|
"image\t1145\t-\tWeight\t0.032922013181510126\n",
|
|
"image\t1324\t-\tWeight\t0.03250158367280327\n",
|
|
"image\t1320\t-\tWeight\t0.03214994190354176\n",
|
|
"image\t1251\t-\tWeight\t0.0320119250948106\n",
|
|
"image\t1353\t-\tWeight\t0.031686689071375326\n",
|
|
"image\t1341\t-\tWeight\t0.031629828629460004\n",
|
|
"image\t1314\t-\tWeight\t0.03156526413086752\n",
|
|
"Latent semantic no. 8\n",
|
|
"image\t4291\t-\tWeight\t0.030379982764735483\n",
|
|
"image\t3659\t-\tWeight\t0.030303639415262738\n",
|
|
"image\t4062\t-\tWeight\t0.03009699185922372\n",
|
|
"image\t3645\t-\tWeight\t0.030070839535056917\n",
|
|
"image\t4186\t-\tWeight\t0.029988779115247072\n",
|
|
"image\t3651\t-\tWeight\t0.02991186566754093\n",
|
|
"image\t4306\t-\tWeight\t0.029842728762290226\n",
|
|
"image\t4290\t-\tWeight\t0.029821657616221558\n",
|
|
"image\t4295\t-\tWeight\t0.029776560377156956\n",
|
|
"image\t4063\t-\tWeight\t0.029718537108632898\n",
|
|
"Latent semantic no. 9\n",
|
|
"image\t3461\t-\tWeight\t-0.01124924934362133\n",
|
|
"image\t3690\t-\tWeight\t-0.011359970957367781\n",
|
|
"image\t3677\t-\tWeight\t-0.011388302213245766\n",
|
|
"image\t2274\t-\tWeight\t-0.011401573573016426\n",
|
|
"image\t2695\t-\tWeight\t-0.011431074774005161\n",
|
|
"image\t3868\t-\tWeight\t-0.011463898013717732\n",
|
|
"image\t1137\t-\tWeight\t-0.011497915659232156\n",
|
|
"image\t1647\t-\tWeight\t-0.01152169864389044\n",
|
|
"image\t1203\t-\tWeight\t-0.011532017314265241\n",
|
|
"image\t2391\t-\tWeight\t-0.011548629237775063\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"selected_feature_model = valid_feature_models[\n",
|
|
" str(input(\"Enter feature model - one of \" + str(list(valid_feature_models.keys()))))\n",
|
|
"]\n",
|
|
"\n",
|
|
"k = int(input(\"Enter value of k: \"))\n",
|
|
"if k < 1:\n",
|
|
" raise ValueError(\"k should be a positive integer\")\n",
|
|
"\n",
|
|
"selected_dim_reduction_method = str(\n",
|
|
" input(\n",
|
|
" \"Enter dimensionality reduction method - one of \"\n",
|
|
" + str(list(valid_dim_reduction_methods.keys()))\n",
|
|
" )\n",
|
|
")\n",
|
|
"\n",
|
|
"image_sim_matrix = find_image_image_similarity(fd_collection,selected_feature_model)\n",
|
|
"\n",
|
|
"extract_latent_semantics_from_sim_matrix(\n",
|
|
" image_sim_matrix,\n",
|
|
" selected_feature_model,\n",
|
|
" \"image\",\n",
|
|
"\tk,\n",
|
|
" selected_dim_reduction_method,\n",
|
|
" top_images=10,\n",
|
|
")\n"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.11.4"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|