mirror of
https://github.com/20kaushik02/CSE515_MWDB_Project.git
synced 2025-12-06 08:04:06 +00:00
207 lines
8.1 KiB
Plaintext
207 lines
8.1 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 lda on the given similarity matrix to get 10 latent semantics (showing only top 10 image-weight pairs for each latent semantic)...\n",
|
|
"iteration: 1 of max_iter: 10\n",
|
|
"iteration: 2 of max_iter: 10\n",
|
|
"iteration: 3 of max_iter: 10\n",
|
|
"iteration: 4 of max_iter: 10\n",
|
|
"iteration: 5 of max_iter: 10\n",
|
|
"iteration: 6 of max_iter: 10\n",
|
|
"iteration: 7 of max_iter: 10\n",
|
|
"iteration: 8 of max_iter: 10\n",
|
|
"iteration: 9 of max_iter: 10\n",
|
|
"iteration: 10 of max_iter: 10\n",
|
|
"Latent semantic no. 0\n",
|
|
"image\t1320\t-\tWeight\t0.17206070988966676\n",
|
|
"image\t1145\t-\tWeight\t0.17179943626356087\n",
|
|
"image\t3461\t-\tWeight\t0.17154666587650064\n",
|
|
"image\t1324\t-\tWeight\t0.1714916836186797\n",
|
|
"image\t1069\t-\tWeight\t0.17141323253822324\n",
|
|
"image\t3690\t-\tWeight\t0.16959779587188872\n",
|
|
"image\t1206\t-\tWeight\t0.1694328485890043\n",
|
|
"image\t1314\t-\tWeight\t0.16852671831005397\n",
|
|
"image\t3868\t-\tWeight\t0.16772530255560464\n",
|
|
"image\t1315\t-\tWeight\t0.1676951554917541\n",
|
|
"Latent semantic no. 1\n",
|
|
"image\t3461\t-\tWeight\t0.17897274174404698\n",
|
|
"image\t1069\t-\tWeight\t0.17739080866155166\n",
|
|
"image\t3690\t-\tWeight\t0.17715023009170783\n",
|
|
"image\t3868\t-\tWeight\t0.1765583750227632\n",
|
|
"image\t1151\t-\tWeight\t0.17552646878633446\n",
|
|
"image\t3677\t-\tWeight\t0.17491121915496274\n",
|
|
"image\t1145\t-\tWeight\t0.17444522065197465\n",
|
|
"image\t1206\t-\tWeight\t0.17347707411460248\n",
|
|
"image\t1702\t-\tWeight\t0.17323349506823651\n",
|
|
"image\t3236\t-\tWeight\t0.17259361731395684\n",
|
|
"Latent semantic no. 2\n",
|
|
"image\t2913\t-\tWeight\t0.24915169806958332\n",
|
|
"image\t1419\t-\tWeight\t0.24873364607633072\n",
|
|
"image\t3823\t-\tWeight\t0.24765439539815443\n",
|
|
"image\t3914\t-\tWeight\t0.24722108746353014\n",
|
|
"image\t1978\t-\tWeight\t0.24717924801135982\n",
|
|
"image\t2277\t-\tWeight\t0.24716600575687775\n",
|
|
"image\t3278\t-\tWeight\t0.24665320113150327\n",
|
|
"image\t516\t-\tWeight\t0.2458587523178849\n",
|
|
"image\t936\t-\tWeight\t0.24566413261838727\n",
|
|
"image\t3170\t-\tWeight\t0.24563727684846276\n",
|
|
"Latent semantic no. 3\n",
|
|
"image\t2913\t-\tWeight\t0.3266523053746904\n",
|
|
"image\t534\t-\tWeight\t0.3212648440986947\n",
|
|
"image\t484\t-\tWeight\t0.3203437955249965\n",
|
|
"image\t1419\t-\tWeight\t0.31664090320889127\n",
|
|
"image\t1978\t-\tWeight\t0.31547212997691076\n",
|
|
"image\t3191\t-\tWeight\t0.3153671627412605\n",
|
|
"image\t1470\t-\tWeight\t0.31421423272112303\n",
|
|
"image\t3823\t-\tWeight\t0.3141460953426758\n",
|
|
"image\t533\t-\tWeight\t0.3138441729808489\n",
|
|
"image\t3914\t-\tWeight\t0.3137452844226845\n",
|
|
"Latent semantic no. 4\n",
|
|
"image\t2581\t-\tWeight\t0.14803042765338018\n",
|
|
"image\t2427\t-\tWeight\t0.14787119654742203\n",
|
|
"image\t235\t-\tWeight\t0.14725550675790816\n",
|
|
"image\t3318\t-\tWeight\t0.1470958239116371\n",
|
|
"image\t529\t-\tWeight\t0.1464149769906216\n",
|
|
"image\t2502\t-\tWeight\t0.14596833327118602\n",
|
|
"image\t1974\t-\tWeight\t0.1458992530542452\n",
|
|
"image\t479\t-\tWeight\t0.14583345959587438\n",
|
|
"image\t3300\t-\tWeight\t0.14516588137746167\n",
|
|
"image\t2759\t-\tWeight\t0.1446833200007853\n",
|
|
"Latent semantic no. 5\n",
|
|
"image\t3473\t-\tWeight\t0.16653860528182776\n",
|
|
"image\t1204\t-\tWeight\t0.16305223733127827\n",
|
|
"image\t3551\t-\tWeight\t0.16189112109250273\n",
|
|
"image\t2220\t-\tWeight\t0.16159567829951746\n",
|
|
"image\t1231\t-\tWeight\t0.16159001222843358\n",
|
|
"image\t1253\t-\tWeight\t0.1613447857090851\n",
|
|
"image\t3204\t-\tWeight\t0.1610615712011389\n",
|
|
"image\t3331\t-\tWeight\t0.1609424410565923\n",
|
|
"image\t1237\t-\tWeight\t0.16034096468940268\n",
|
|
"image\t3622\t-\tWeight\t0.15993886160572018\n",
|
|
"Latent semantic no. 6\n",
|
|
"image\t599\t-\tWeight\t0.2198899760317277\n",
|
|
"image\t639\t-\tWeight\t0.21846435872932818\n",
|
|
"image\t640\t-\tWeight\t0.21776591339133608\n",
|
|
"image\t702\t-\tWeight\t0.2174138488317365\n",
|
|
"image\t704\t-\tWeight\t0.2166738332332963\n",
|
|
"image\t711\t-\tWeight\t0.21662045479027403\n",
|
|
"image\t703\t-\tWeight\t0.21661091222997475\n",
|
|
"image\t617\t-\tWeight\t0.2163479764382222\n",
|
|
"image\t589\t-\tWeight\t0.21631401416260512\n",
|
|
"image\t642\t-\tWeight\t0.21630913014866476\n",
|
|
"Latent semantic no. 7\n",
|
|
"image\t3928\t-\tWeight\t0.6634818538599493\n",
|
|
"image\t3801\t-\tWeight\t0.6573450633183574\n",
|
|
"image\t1701\t-\tWeight\t0.6480471204807624\n",
|
|
"image\t3840\t-\tWeight\t0.6456662415349316\n",
|
|
"image\t4062\t-\tWeight\t0.6439791662614557\n",
|
|
"image\t4186\t-\tWeight\t0.641220476711286\n",
|
|
"image\t830\t-\tWeight\t0.6384302481021613\n",
|
|
"image\t784\t-\tWeight\t0.6374058630564187\n",
|
|
"image\t3659\t-\tWeight\t0.636175407817677\n",
|
|
"image\t4042\t-\tWeight\t0.6322635857453663\n",
|
|
"Latent semantic no. 8\n",
|
|
"image\t1580\t-\tWeight\t0.28575545742878244\n",
|
|
"image\t1419\t-\tWeight\t0.28332419763850997\n",
|
|
"image\t3914\t-\tWeight\t0.28232175164293977\n",
|
|
"image\t936\t-\tWeight\t0.2823216465790576\n",
|
|
"image\t3859\t-\tWeight\t0.28189499418627034\n",
|
|
"image\t3861\t-\tWeight\t0.2801815894641137\n",
|
|
"image\t1592\t-\tWeight\t0.27958765520327383\n",
|
|
"image\t3823\t-\tWeight\t0.2793916278176494\n",
|
|
"image\t2692\t-\tWeight\t0.27938679856587517\n",
|
|
"image\t1919\t-\tWeight\t0.2786505567477107\n",
|
|
"Latent semantic no. 9\n",
|
|
"image\t1272\t-\tWeight\t0.1837953952807028\n",
|
|
"image\t1274\t-\tWeight\t0.1794627699707628\n",
|
|
"image\t1942\t-\tWeight\t0.17899500770197288\n",
|
|
"image\t3500\t-\tWeight\t0.17707556817302403\n",
|
|
"image\t3192\t-\tWeight\t0.17705287616822626\n",
|
|
"image\t2818\t-\tWeight\t0.17660356031482674\n",
|
|
"image\t1285\t-\tWeight\t0.17617394226847666\n",
|
|
"image\t2587\t-\tWeight\t0.17562936196517273\n",
|
|
"image\t2801\t-\tWeight\t0.17495390468365793\n",
|
|
"image\t3331\t-\tWeight\t0.17343968962278572\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
|
|
}
|