From 4114ae3cbcf83241d2418f91ecacff8be23b9755 Mon Sep 17 00:00:00 2001
From: Filip Johnsson <filjo653@student.liu.se>
Date: Mon, 2 Dec 2024 11:23:55 +0100
Subject: [PATCH] done

---
 l4/TM-Lab4.ipynb | 44 ++++++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/l4/TM-Lab4.ipynb b/l4/TM-Lab4.ipynb
index a481d39..d2069d4 100644
--- a/l4/TM-Lab4.ipynb
+++ b/l4/TM-Lab4.ipynb
@@ -1098,7 +1098,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 182,
+   "execution_count": 186,
    "metadata": {
     "deletable": false,
     "nbgrader": {
@@ -1115,20 +1115,40 @@
    },
    "outputs": [
     {
-     "ename": "NotImplementedError",
-     "evalue": "",
-     "output_type": "error",
-     "traceback": [
-      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
-      "\u001b[0;31mNotImplementedError\u001b[0m                       Traceback (most recent call last)",
-      "Cell \u001b[0;32mIn[182], line 2\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[39m# YOUR CODE HERE\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mNotImplementedError\u001b[39;00m()\n",
-      "\u001b[0;31mNotImplementedError\u001b[0m: "
-     ]
+     "data": {
+      "text/plain": [
+       "[(0,\n",
+       "  '0.040*\"children\" + 0.037*\"people\" + 0.033*\"care\" + 0.030*\"health\" + 0.024*\"know\" + 0.019*\"child\" + 0.019*\"families\" + 0.019*\"americans\" + 0.017*\"year\" + 0.017*\"work\"'),\n",
+       " (1,\n",
+       "  '0.029*\"energy\" + 0.025*\"policy\" + 0.016*\"economic\" + 0.016*\"program\" + 0.014*\"states\" + 0.014*\"major\" + 0.014*\"administration\" + 0.014*\"united\" + 0.012*\"oil\" + 0.012*\"foreign\"'),\n",
+       " (2,\n",
+       "  '0.075*\"security\" + 0.035*\"social\" + 0.031*\"soviet\" + 0.027*\"defense\" + 0.024*\"years\" + 0.024*\"economic\" + 0.023*\"military\" + 0.020*\"percent\" + 0.020*\"forces\" + 0.016*\"growth\"'),\n",
+       " (3,\n",
+       "  '0.038*\"tax\" + 0.036*\"education\" + 0.035*\"budget\" + 0.031*\"schools\" + 0.027*\"school\" + 0.022*\"year\" + 0.021*\"help\" + 0.016*\"billion\" + 0.016*\"children\" + 0.016*\"years\"'),\n",
+       " (4,\n",
+       "  '0.036*\"america\" + 0.030*\"world\" + 0.019*\"new\" + 0.018*\"people\" + 0.018*\"nation\" + 0.018*\"economy\" + 0.015*\"great\" + 0.014*\"americans\" + 0.014*\"years\" + 0.014*\"best\"'),\n",
+       " (5,\n",
+       "  '0.035*\"work\" + 0.034*\"new\" + 0.033*\"welfare\" + 0.028*\"jobs\" + 0.023*\"people\" + 0.020*\"years\" + 0.017*\"private\" + 0.015*\"inflation\" + 0.014*\"million\" + 0.013*\"rate\"'),\n",
+       " (6,\n",
+       "  '0.029*\"crime\" + 0.027*\"let\" + 0.025*\"americans\" + 0.024*\"people\" + 0.022*\"thank\" + 0.021*\"congress\" + 0.021*\"american\" + 0.020*\"president\" + 0.019*\"country\" + 0.019*\"government\"'),\n",
+       " (7,\n",
+       "  '0.044*\"federal\" + 0.039*\"government\" + 0.027*\"congress\" + 0.025*\"programs\" + 0.021*\"year\" + 0.018*\"system\" + 0.017*\"act\" + 0.014*\"administration\" + 0.014*\"legislation\" + 0.014*\"new\"'),\n",
+       " (8,\n",
+       "  '0.036*\"peace\" + 0.034*\"world\" + 0.028*\"nuclear\" + 0.023*\"america\" + 0.018*\"nations\" + 0.016*\"democracy\" + 0.016*\"new\" + 0.016*\"freedom\" + 0.015*\"states\" + 0.015*\"year\"'),\n",
+       " (9,\n",
+       "  '0.065*\"america\" + 0.032*\"century\" + 0.031*\"world\" + 0.029*\"state\" + 0.028*\"union\" + 0.021*\"american\" + 0.020*\"time\" + 0.019*\"new\" + 0.018*\"tonight\" + 0.017*\"science\"')]"
+      ]
+     },
+     "execution_count": 186,
+     "metadata": {},
+     "output_type": "execute_result"
     }
    ],
    "source": [
-    "# YOUR CODE HERE\n",
-    "raise NotImplementedError()"
+    "clear_logfile()\n",
+    "model = train_lda_model(documents, 10, passes=30)\n",
+    "likelihoods = parse_logfile()\n",
+    "model.print_topics()"
    ]
   },
   {
-- 
GitLab