mirror of
https://github.com/20kaushik02/CSE515_MWDB_Project.git
synced 2025-12-06 08:04:06 +00:00
214 lines
8.2 KiB
Plaintext
214 lines
8.2 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from utils import *\n",
|
|
"warnings.filterwarnings('ignore')\n",
|
|
"%matplotlib inline"
|
|
]
|
|
},
|
|
{
|
|
"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 label-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",
|
|
"label\t86\t-\tWeight\t0.0004531654159359732\n",
|
|
"label\t81\t-\tWeight\t0.0004417802626698606\n",
|
|
"label\t20\t-\tWeight\t0.00043909085561082503\n",
|
|
"label\t37\t-\tWeight\t0.0004366108274701382\n",
|
|
"label\t23\t-\tWeight\t0.00043457527167984727\n",
|
|
"label\t30\t-\tWeight\t0.00043324186605595916\n",
|
|
"label\t25\t-\tWeight\t0.00043274706213965473\n",
|
|
"label\t24\t-\tWeight\t0.0004290312838498227\n",
|
|
"label\t26\t-\tWeight\t0.0004290127071576239\n",
|
|
"label\t58\t-\tWeight\t0.0004280705463204183\n",
|
|
"Latent semantic no. 1\n",
|
|
"label\t86\t-\tWeight\t0.00045317505419918263\n",
|
|
"label\t81\t-\tWeight\t0.0004417890180969132\n",
|
|
"label\t20\t-\tWeight\t0.0004391003128445388\n",
|
|
"label\t37\t-\tWeight\t0.00043662070169061585\n",
|
|
"label\t23\t-\tWeight\t0.0004345844126142611\n",
|
|
"label\t30\t-\tWeight\t0.00043325103891919523\n",
|
|
"label\t25\t-\tWeight\t0.00043275655078268234\n",
|
|
"label\t24\t-\tWeight\t0.0004290408792180107\n",
|
|
"label\t26\t-\tWeight\t0.00042902109696286967\n",
|
|
"label\t58\t-\tWeight\t0.0004280807127762838\n",
|
|
"Latent semantic no. 2\n",
|
|
"label\t86\t-\tWeight\t0.00045312072900256355\n",
|
|
"label\t81\t-\tWeight\t0.0004417364497245229\n",
|
|
"label\t20\t-\tWeight\t0.0004390475331611943\n",
|
|
"label\t37\t-\tWeight\t0.0004365681611562296\n",
|
|
"label\t23\t-\tWeight\t0.0004345323157784398\n",
|
|
"label\t30\t-\tWeight\t0.00043319901917670715\n",
|
|
"label\t25\t-\tWeight\t0.0004327044844270213\n",
|
|
"label\t24\t-\tWeight\t0.00042898930777452614\n",
|
|
"label\t26\t-\tWeight\t0.000428970107413019\n",
|
|
"label\t58\t-\tWeight\t0.00042802908762740616\n",
|
|
"Latent semantic no. 3\n",
|
|
"label\t86\t-\tWeight\t0.00045318195164987813\n",
|
|
"label\t81\t-\tWeight\t0.00044179608840518193\n",
|
|
"label\t20\t-\tWeight\t0.0004391067775271899\n",
|
|
"label\t37\t-\tWeight\t0.000436626468446809\n",
|
|
"label\t23\t-\tWeight\t0.00043459099827651484\n",
|
|
"label\t30\t-\tWeight\t0.00043325754714432983\n",
|
|
"label\t25\t-\tWeight\t0.0004327625151138594\n",
|
|
"label\t24\t-\tWeight\t0.00042904668099729267\n",
|
|
"label\t26\t-\tWeight\t0.00042902773613974173\n",
|
|
"label\t58\t-\tWeight\t0.0004280860358219467\n",
|
|
"Latent semantic no. 4\n",
|
|
"label\t86\t-\tWeight\t0.0004532012230924254\n",
|
|
"label\t81\t-\tWeight\t0.0004418145591898838\n",
|
|
"label\t20\t-\tWeight\t0.0004391246602233907\n",
|
|
"label\t37\t-\tWeight\t0.00043664360658210823\n",
|
|
"label\t23\t-\tWeight\t0.0004346094906288087\n",
|
|
"label\t30\t-\tWeight\t0.0004332756310469352\n",
|
|
"label\t25\t-\tWeight\t0.00043277963540597756\n",
|
|
"label\t24\t-\tWeight\t0.0004290633871096734\n",
|
|
"label\t26\t-\tWeight\t0.0004290459466564114\n",
|
|
"label\t58\t-\tWeight\t0.00042810235322099204\n",
|
|
"Latent semantic no. 5\n",
|
|
"label\t86\t-\tWeight\t0.0004531814522875912\n",
|
|
"label\t81\t-\tWeight\t0.00044179547980990153\n",
|
|
"label\t20\t-\tWeight\t0.00043910615276579\n",
|
|
"label\t37\t-\tWeight\t0.0004366251198908978\n",
|
|
"label\t23\t-\tWeight\t0.0004345904089672849\n",
|
|
"label\t30\t-\tWeight\t0.0004332568886788472\n",
|
|
"label\t25\t-\tWeight\t0.0004327609475184491\n",
|
|
"label\t24\t-\tWeight\t0.00042904496501344676\n",
|
|
"label\t26\t-\tWeight\t0.0004290273924817515\n",
|
|
"label\t58\t-\tWeight\t0.0004280843616517628\n",
|
|
"Latent semantic no. 6\n",
|
|
"label\t2\t-\tWeight\t0.9979457923349433\n",
|
|
"label\t95\t-\tWeight\t0.9975714512001539\n",
|
|
"label\t60\t-\tWeight\t0.9974934163989678\n",
|
|
"label\t82\t-\tWeight\t0.9971947522049759\n",
|
|
"label\t51\t-\tWeight\t0.9971885301157567\n",
|
|
"label\t66\t-\tWeight\t0.9970754925406659\n",
|
|
"label\t29\t-\tWeight\t0.9970572171294957\n",
|
|
"label\t42\t-\tWeight\t0.9969819309782944\n",
|
|
"label\t47\t-\tWeight\t0.9969577461454074\n",
|
|
"label\t35\t-\tWeight\t0.9969023226836516\n",
|
|
"Latent semantic no. 7\n",
|
|
"label\t86\t-\tWeight\t0.0004531931222370423\n",
|
|
"label\t81\t-\tWeight\t0.0004418065816432295\n",
|
|
"label\t20\t-\tWeight\t0.0004391176224740742\n",
|
|
"label\t37\t-\tWeight\t0.00043663627448884573\n",
|
|
"label\t23\t-\tWeight\t0.0004346018291120466\n",
|
|
"label\t30\t-\tWeight\t0.00043326792763734024\n",
|
|
"label\t25\t-\tWeight\t0.0004327723354289989\n",
|
|
"label\t24\t-\tWeight\t0.0004290562269897544\n",
|
|
"label\t26\t-\tWeight\t0.000429038285361369\n",
|
|
"label\t58\t-\tWeight\t0.0004280951952808515\n",
|
|
"Latent semantic no. 8\n",
|
|
"label\t86\t-\tWeight\t0.0004531025037746746\n",
|
|
"label\t81\t-\tWeight\t0.00044171873000539025\n",
|
|
"label\t20\t-\tWeight\t0.0004390298979822301\n",
|
|
"label\t37\t-\tWeight\t0.0004365513222341559\n",
|
|
"label\t23\t-\tWeight\t0.00043451495489625614\n",
|
|
"label\t30\t-\tWeight\t0.0004331818006977396\n",
|
|
"label\t25\t-\tWeight\t0.0004326876783366398\n",
|
|
"label\t24\t-\tWeight\t0.00042897279004515285\n",
|
|
"label\t26\t-\tWeight\t0.00042895311102269417\n",
|
|
"label\t58\t-\tWeight\t0.000428012558440153\n",
|
|
"Latent semantic no. 9\n",
|
|
"label\t80\t-\tWeight\t0.9980799926585355\n",
|
|
"label\t48\t-\tWeight\t0.9978481535222623\n",
|
|
"label\t93\t-\tWeight\t0.9975103137028881\n",
|
|
"label\t14\t-\tWeight\t0.99609327389133\n",
|
|
"label\t99\t-\tWeight\t0.9921318122895414\n",
|
|
"label\t91\t-\tWeight\t0.9827860773066165\n",
|
|
"label\t85\t-\tWeight\t0.9762723996945643\n",
|
|
"label\t75\t-\tWeight\t0.9476213255769989\n",
|
|
"label\t3\t-\tWeight\t0.9401709016743883\n",
|
|
"label\t98\t-\tWeight\t0.9244947049183805\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",
|
|
"label_sim_matrix = find_label_label_similarity(fd_collection,selected_feature_model)\n",
|
|
"\n",
|
|
"extract_latent_semantics_from_sim_matrix(\n",
|
|
" label_sim_matrix,\n",
|
|
" selected_feature_model,\n",
|
|
" \"label\",\n",
|
|
" k,\n",
|
|
" selected_dim_reduction_method,\n",
|
|
" top_images=10,\n",
|
|
")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"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
|
|
}
|