{"id":852,"date":"2017-01-22T21:16:14","date_gmt":"2017-01-22T21:16:14","guid":{"rendered":"http:\/\/intelligentonlinetools.com\/blog\/?p=852"},"modified":"2018-09-09T00:10:01","modified_gmt":"2018-09-09T00:10:01","slug":"data-visualization-visualizing-an-lda-model-using-python","status":"publish","type":"post","link":"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/","title":{"rendered":"Data Visualization &#8211; Visualizing an LDA Model using Python"},"content":{"rendered":"<p>In the previous post <a href=http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/08\/topic-extraction-from-blog-posts-with-lsi-and-lda-and-python\/ target=\"_blank\">Topic Extraction from Blog Posts with LSI , LDA and Python<\/a> python code was created for text documents topic modeling using Latent Dirichlet allocation (LDA) method.<br \/>\nThe output was just an overview of the words with corresponding probability distribution for each topic and it was hard to use the results. So in this post we will implement python code for LDA results <strong>visualization<\/strong>.<\/p>\n<p>As before we will run LDA the same way from the same data input. <\/p>\n<p>After LDA is done we get needed data for visualization using the following statement:<\/p>\n<pre><code>\r\ntopicWordProbMat = ldamodel.print_topics(K)\r\n<\/code><\/pre>\n<p>Here is the example of output of topicWordProbMat (shown partially):<\/p>\n<p>[(0, &#8216;0.016*&#8221;use&#8221; + 0.013*&#8221;extract&#8221; + 0.011*&#8221;web&#8221; + 0.011*&#8221;script&#8221; + 0.011*&#8221;can&#8221; + 0.010*&#8221;link&#8221; + 0.009*&#8221;comput&#8221; + 0.008*&#8221;intellig&#8221; + 0.008*&#8221;modul&#8221; + 0.007*&#8221;page&#8221;&#8216;), (1, &#8216;0.037*&#8221;cloud&#8221; + 0.028*&#8221;tag&#8221; + 0.018*&#8221;number&#8221; + 0.015*&#8221;life&#8221; + 0.013*&#8221;path&#8221; + 0.012*&#8221;can&#8221; + 0.010*&#8221;word&#8221; + 0.008*&#8221;gener&#8221; + 0.007*&#8221;web&#8221; + 0.006*&#8221;born&#8221;&#8216;), &#8230;&#8230;..<\/p>\n<p>Using <strong>topicWordProbMat<\/strong> we will prepare matrix with the probabilities of words per each topic and per each word.  We will prepare also dataframe and will output it in the table format, each column for topic, showing the words for each topic in the column.  This is very useful to review results and decide if some words need to be removed. For example I see that I need remove some words like &#8220;will&#8221;, &#8220;use&#8221;, &#8220;can&#8221;.<\/p>\n<p>Below is the code for preparation of dataframe and matrix. The matrix zz is showing probability for each word and topic. Here we create empty dataframe df and then populate it element by element. Word Topic DataFrame is shown in the end of this post.<\/p>\n<pre><code>\r\nimport pandas as pd\r\nimport numpy as np\r\n\r\ncolumns = ['1','2','3','4','5']\r\n\r\ndf = pd.DataFrame(columns = columns)\r\npd.set_option('display.width', 1000)\r\n\r\n# 40 will be resized later to match number of words in DC\r\nzz = np.zeros(shape=(40,K))\r\n\r\nlast_number=0\r\nDC={}\r\n\r\nfor x in range (10):\r\n  data = pd.DataFrame({columns[0]:\"\",\r\n                     columns[1]:\"\",\r\n                     columns[2]:\"\",\r\n                     columns[3]:\"\",\r\n                     columns[4]:\"\",\r\n                                                                                       \r\n                     \r\n                    },index=[0])\r\n  df=df.append(data,ignore_index=True)  \r\n    \r\nfor line in topicWordProbMat:\r\n    \r\n    tp, w = line\r\n    probs=w.split(\"+\")\r\n    y=0\r\n    for pr in probs:\r\n               \r\n        a=pr.split(\"*\")\r\n        df.iloc[y,tp] = a[1]\r\n       \r\n        if a[1] in DC:\r\n           zz[DC[a[1]]][tp]=a[0]\r\n        else:\r\n           zz[last_number][tp]=a[0]\r\n           DC[a[1]]=last_number\r\n           last_number=last_number+1\r\n        y=y+1\r\n\r\nprint (df)\r\nprint (zz)\r\n<\/code><\/pre>\n<p>The matrix zz will be used now for <strong>creating plot for visualization<\/strong>. Such plot can be called heatmap. Below is the code for this. The dark areas correspondent to  0 probability and the areas with less dark and more white correspondent to higher word probabilities for the given word and topic. Word topic map is shown in the end of this post. <\/p>\n<pre><code>\r\nimport matplotlib.pyplot as plt\r\n\r\nzz=np.resize(zz,(len(DC.keys()),zz.shape[1]))\r\n\r\nfor val, key in enumerate(DC.keys()):\r\n        plt.text(-2.5, val + 0.5, key,\r\n                 horizontalalignment='center',\r\n                 verticalalignment='center'\r\n                 )\r\n\r\nplt.imshow(zz, cmap='hot', interpolation='nearest')\r\nplt.show()\r\n<\/code><\/pre>\n<p>Below is the output from running python code.<br \/>\n<img data-attachment-id=\"863\" data-permalink=\"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/word_topic_dataframe\/#main\" data-orig-file=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_dataframe.png\" data-orig-size=\"747,279\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"word_topic_dataframe\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_dataframe-300x112.png\" data-large-file=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_dataframe.png\" decoding=\"async\" loading=\"lazy\" src=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_dataframe-300x112.png\" alt=\"\" width=\"500\" height=\"200\" class=\"alignnone size-medium wp-image-863\" \/><br \/>\n<strong>Word Topic DataFrame<\/strong><\/p>\n<p><img data-attachment-id=\"864\" data-permalink=\"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/word_topic_map\/#main\" data-orig-file=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_map.png\" data-orig-size=\"229,781\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"word_topic_map\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_map-88x300.png\" data-large-file=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_map.png\" decoding=\"async\" loading=\"lazy\" src=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_map-88x300.png\" alt=\"\" width=\"270\" height=\"800\" class=\"alignnone size-medium wp-image-864\" \/><br \/>\n<strong>Word Topic Map<\/strong><\/p>\n<p><img data-attachment-id=\"865\" data-permalink=\"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/word_topic_prob_matrix\/#main\" data-orig-file=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_prob_matrix.png\" data-orig-size=\"422,705\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"word_topic_prob_matrix\" data-image-description=\"&lt;p&gt;LDA visualzation &#8211; matrix, plot and word topic table&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;LDA visualzation &#8211; matrix, plot and word topic table&lt;\/p&gt;\n\" data-medium-file=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_prob_matrix-180x300.png\" data-large-file=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_prob_matrix.png\" decoding=\"async\" loading=\"lazy\" src=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_prob_matrix-180x300.png\" alt=\"\" width=\"240\" height=\"400\" class=\"size-medium wp-image-865\" srcset=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_prob_matrix-180x300.png 180w, http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_prob_matrix.png 422w\" sizes=\"(max-width: 240px) 100vw, 240px\" \/><br \/>\n<strong>Matrix Data<\/strong><\/p>\n<p>Below is the full source code of the script.  <\/p>\n<pre><code>\r\n# -*- coding: utf-8 -*-\r\n     \r\nimport csv\r\nfrom stop_words import get_stop_words\r\nfrom nltk.stem.porter import PorterStemmer\r\nfrom gensim import corpora\r\nimport gensim\r\nimport re\r\nfrom nltk.tokenize import RegexpTokenizer\r\n\r\ndef remove_html_tags(text):\r\n        \"\"\"Remove html tags from a string\"\"\"\r\n     \r\n        clean = re.compile('<.*?>')\r\n        return re.sub(clean, '', text)\r\n\r\ntokenizer = RegexpTokenizer(r'\\w+')\r\n\r\n# use English stop words list\r\nen_stop = get_stop_words('en')\r\n\r\n# use p_stemmer of class PorterStemmer\r\np_stemmer = PorterStemmer()\r\n\r\nfn=\"posts.csv\" \r\ndoc_set = []\r\n\r\nwith open(fn, encoding=\"utf8\" ) as f:\r\n            csv_f = csv.reader(f)\r\n            for i, row in enumerate(csv_f):\r\n               if i > 1 and len(row) > 1 :\r\n                \r\n                 temp=remove_html_tags(row[1]) \r\n                 temp = re.sub(\"[^a-zA-Z ]\",\"\", temp)\r\n                 doc_set.append(temp)\r\n              \r\ntexts = []\r\n\r\nfor i in doc_set:\r\n    # clean and tokenize document string\r\n    raw = i.lower()\r\n    raw=' '.join(word for word in raw.split() if len(word)>2)    \r\n\r\n    raw=raw.replace(\"nbsp\", \"\")\r\n    tokens = tokenizer.tokenize(raw)\r\n   \r\n    stopped_tokens = [i for i in tokens if not i in en_stop]\r\n    stemmed_tokens = [p_stemmer.stem(i) for i in stopped_tokens]\r\n    texts.append(stemmed_tokens)\r\n# turn our tokenized documents into a id <-> term dictionary\r\ndictionary = corpora.Dictionary(texts)\r\n# convert tokenized documents into a document-term matrix\r\ncorpus = [dictionary.doc2bow(text) for text in texts]\r\nldamodel = gensim.models.ldamodel.LdaModel(corpus, num_topics=5, id2word = dictionary, passes=20)\r\nprint (ldamodel)\r\nprint(ldamodel.print_topics(num_topics=3, num_words=3))\r\nfor i in  ldamodel.show_topics(num_words=4):\r\n    print (i[0], i[1])\r\n\r\n# Get Per-topic word probability matrix:\r\nK = ldamodel.num_topics\r\n \r\ntopicWordProbMat = ldamodel.print_topics(K)\r\nprint (topicWordProbMat) \r\n \r\nfor t in texts:\r\n     vec = dictionary.doc2bow(t)\r\n     print (ldamodel[vec])\r\n\r\nimport pandas as pd\r\nimport numpy as np\r\ncolumns = ['1','2','3','4','5']\r\ndf = pd.DataFrame(columns = columns)\r\npd.set_option('display.width', 1000)\r\n\r\n# 40 will be resized later to match number of words in DC\r\nzz = np.zeros(shape=(40,K))\r\n\r\nlast_number=0\r\nDC={}\r\n\r\nfor x in range (10):\r\n  data = pd.DataFrame({columns[0]:\"\",\r\n                     columns[1]:\"\",\r\n                     columns[2]:\"\",\r\n                     columns[3]:\"\",\r\n                     columns[4]:\"\",\r\n                                                                                 \r\n                   \r\n                    },index=[0])\r\n  df=df.append(data,ignore_index=True)  \r\n   \r\nfor line in topicWordProbMat:\r\n\r\n    tp, w = line\r\n    probs=w.split(\"+\")\r\n    y=0\r\n    for pr in probs:\r\n               \r\n        a=pr.split(\"*\")\r\n        df.iloc[y,tp] = a[1]\r\n       \r\n        if a[1] in DC:\r\n           zz[DC[a[1]]][tp]=a[0]\r\n        else:\r\n           zz[last_number][tp]=a[0]\r\n           DC[a[1]]=last_number\r\n           last_number=last_number+1\r\n        y=y+1\r\n \r\nprint (df)\r\nprint (zz)\r\nimport matplotlib.pyplot as plt\r\nzz=np.resize(zz,(len(DC.keys()),zz.shape[1]))\r\n\r\nfor val, key in enumerate(DC.keys()):\r\n        plt.text(-2.5, val + 0.5, key,\r\n                 horizontalalignment='center',\r\n                 verticalalignment='center'\r\n                 )\r\nplt.imshow(zz, cmap='hot', interpolation='nearest')\r\nplt.show()\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In the previous post Topic Extraction from Blog Posts with LSI , LDA and Python python code was created for text documents topic modeling using Latent Dirichlet allocation (LDA) method. The output was just an overview of the words with corresponding probability distribution for each topic and it was hard to use the results. So &#8230; <a title=\"Data Visualization &#8211; Visualizing an LDA Model using Python\" class=\"read-more\" href=\"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[2,6,9,10],"tags":[29,93,94],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Data Visualization - Visualizing an LDA Model using Python - Machine Learning Applications<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Data Visualization - Visualizing an LDA Model using Python - Machine Learning Applications\" \/>\n<meta property=\"og:description\" content=\"In the previous post Topic Extraction from Blog Posts with LSI , LDA and Python python code was created for text documents topic modeling using Latent Dirichlet allocation (LDA) method. The output was just an overview of the words with corresponding probability distribution for each topic and it was hard to use the results. So ... Read more\" \/>\n<meta property=\"og:url\" content=\"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Machine Learning Applications\" \/>\n<meta property=\"article:published_time\" content=\"2017-01-22T21:16:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-09-09T00:10:01+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_dataframe-300x112.png\" \/>\n<meta name=\"author\" content=\"owygs156\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"owygs156\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/\",\"url\":\"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/\",\"name\":\"Data Visualization - Visualizing an LDA Model using Python - Machine Learning Applications\",\"isPartOf\":{\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/#website\"},\"datePublished\":\"2017-01-22T21:16:14+00:00\",\"dateModified\":\"2018-09-09T00:10:01+00:00\",\"author\":{\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/#\/schema\/person\/7a886dc5eb9758369af2f6d2cb342478\"},\"breadcrumb\":{\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/intelligentonlinetools.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Data Visualization &#8211; Visualizing an LDA Model using Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/#website\",\"url\":\"http:\/\/intelligentonlinetools.com\/blog\/\",\"name\":\"Machine Learning Applications\",\"description\":\"Artificial intelligence, data mining and machine learning for building web based tools and services.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/intelligentonlinetools.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/#\/schema\/person\/7a886dc5eb9758369af2f6d2cb342478\",\"name\":\"owygs156\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/intelligentonlinetools.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/2.gravatar.com\/avatar\/b351def598609cb4c0b5bca26497c7e5?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/2.gravatar.com\/avatar\/b351def598609cb4c0b5bca26497c7e5?s=96&d=mm&r=g\",\"caption\":\"owygs156\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Data Visualization - Visualizing an LDA Model using Python - Machine Learning Applications","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/","og_locale":"en_US","og_type":"article","og_title":"Data Visualization - Visualizing an LDA Model using Python - Machine Learning Applications","og_description":"In the previous post Topic Extraction from Blog Posts with LSI , LDA and Python python code was created for text documents topic modeling using Latent Dirichlet allocation (LDA) method. The output was just an overview of the words with corresponding probability distribution for each topic and it was hard to use the results. So ... Read more","og_url":"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/","og_site_name":"Machine Learning Applications","article_published_time":"2017-01-22T21:16:14+00:00","article_modified_time":"2018-09-09T00:10:01+00:00","og_image":[{"url":"http:\/\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/01\/word_topic_dataframe-300x112.png"}],"author":"owygs156","twitter_card":"summary_large_image","twitter_misc":{"Written by":"owygs156","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/","url":"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/","name":"Data Visualization - Visualizing an LDA Model using Python - Machine Learning Applications","isPartOf":{"@id":"http:\/\/intelligentonlinetools.com\/blog\/#website"},"datePublished":"2017-01-22T21:16:14+00:00","dateModified":"2018-09-09T00:10:01+00:00","author":{"@id":"http:\/\/intelligentonlinetools.com\/blog\/#\/schema\/person\/7a886dc5eb9758369af2f6d2cb342478"},"breadcrumb":{"@id":"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/22\/data-visualization-visualizing-an-lda-model-using-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/intelligentonlinetools.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Data Visualization &#8211; Visualizing an LDA Model using Python"}]},{"@type":"WebSite","@id":"http:\/\/intelligentonlinetools.com\/blog\/#website","url":"http:\/\/intelligentonlinetools.com\/blog\/","name":"Machine Learning Applications","description":"Artificial intelligence, data mining and machine learning for building web based tools and services.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/intelligentonlinetools.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/intelligentonlinetools.com\/blog\/#\/schema\/person\/7a886dc5eb9758369af2f6d2cb342478","name":"owygs156","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/intelligentonlinetools.com\/blog\/#\/schema\/person\/image\/","url":"http:\/\/2.gravatar.com\/avatar\/b351def598609cb4c0b5bca26497c7e5?s=96&d=mm&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/b351def598609cb4c0b5bca26497c7e5?s=96&d=mm&r=g","caption":"owygs156"}}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7h1IJ-dK","jetpack-related-posts":[{"id":797,"url":"http:\/\/intelligentonlinetools.com\/blog\/2017\/01\/08\/topic-extraction-from-blog-posts-with-lsi-and-lda-and-python\/","url_meta":{"origin":852,"position":0},"title":"Topic Extraction from Blog Posts with LSI , LDA and Python","date":"January 8, 2017","format":false,"excerpt":"In the previous post we created python script to get posts from Wordpress (WP) blog through WP API. This script was saving retrieved posts into csv file. In this post we will create script for topic extraction from the posts saved in this csv file. We will use the following\u2026","rel":"","context":"In &quot;Machine Learning&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":721,"url":"http:\/\/intelligentonlinetools.com\/blog\/2016\/12\/15\/latent-dirichlet-allocation-lda-with-python\/","url_meta":{"origin":852,"position":1},"title":"Latent Dirichlet Allocation (LDA) with Python Script","date":"December 15, 2016","format":false,"excerpt":"In the previous posts [1],[2] few scripts for extracting web data were created. Combining these scripts, we will create now web crawling script with text mining functionality such as Latent Dirichlet Allocation (LDA). In LDA, each document may be viewed as a mixture of various topics. Where each document is\u2026","rel":"","context":"In &quot;Artificial Intelligence&quot;","img":{"alt_text":"Program Flow Chart for Extracting Data from Web and Doing LDA","src":"https:\/\/i0.wp.com\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2016\/12\/program-flow-300x247.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":256,"url":"http:\/\/intelligentonlinetools.com\/blog\/2016\/06\/05\/using-python-for-mining-data-from-twitter-visualization-and-other-enchancements\/","url_meta":{"origin":852,"position":2},"title":"Using Python for Data Visualization of Clustering Results","date":"June 5, 2016","format":false,"excerpt":"In one of the previous post http:\/\/intelligentonlinetools.com\/blog\/2016\/05\/28\/using-python-for-mining-data-from-twitter\/ python source code for mining Twitter data was implemented. Clustering was applied to put tweets in different groups using bag of words representation for the text. The results of clustering were obtained via numerical matrix. Now we will look at visualization of clustering\u2026","rel":"","context":"In &quot;Artificial Intelligence&quot;","img":{"alt_text":"Data Visualization for Clustering Results","src":"https:\/\/i0.wp.com\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2016\/06\/data-visualization1-300x220.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":966,"url":"http:\/\/intelligentonlinetools.com\/blog\/2017\/02\/18\/building-decision-trees-in-python\/","url_meta":{"origin":852,"position":3},"title":"Building Decision Trees in Python","date":"February 18, 2017","format":false,"excerpt":"A decision tree is a decision support tool that uses a tree-like graph or model of decisions and their possible consequences, including chance event outcomes, resource costs, and utility. It is one way to display an algorithm. Decision trees are commonly used in operations research, specifically in decision analysis, to\u2026","rel":"","context":"In &quot;Artificial Intelligence&quot;","img":{"alt_text":"Decision Tree","src":"https:\/\/i0.wp.com\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/02\/dt_post1_N_CTQ_Cost_regr1-2-use-this-300x103.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1857,"url":"http:\/\/intelligentonlinetools.com\/blog\/2018\/02\/10\/how-to-create-data-visualization-for-association-rules-in-data-mining\/","url_meta":{"origin":852,"position":4},"title":"How to Create Data Visualization for Association Rules in Data Mining","date":"February 10, 2018","format":false,"excerpt":"Association rule learning is used in machine learning for discovering interesting relations between variables. Apriori algorithm is a popular algorithm for association rules mining and extracting frequent itemsets with applications in association rule learning. It has been designed to operate on databases containing transactions, such as purchases by customers of\u2026","rel":"","context":"In &quot;Data Mining&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2018\/02\/association_rules_scatter_plot_for_retailer_dataset.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1422,"url":"http:\/\/intelligentonlinetools.com\/blog\/2017\/11\/02\/data-visualization-of-word-correlations-with-networkx\/","url_meta":{"origin":852,"position":5},"title":"Data Visualization of Word Correlations with NetworkX","date":"November 2, 2017","format":false,"excerpt":"This is a continuation of my previous post, found here Combining Machine Learning and Data Scraping. Data visualization is added to show correlations between words. The graph was built using NetworkX python library. The input for the graph is the array corr_data with 3 columns : pair of words and\u2026","rel":"","context":"In &quot;Data Mining&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/intelligentonlinetools.com\/blog\/wp-content\/uploads\/2017\/11\/NetworkX_graph-300x211.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/posts\/852"}],"collection":[{"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/comments?post=852"}],"version-history":[{"count":10,"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/posts\/852\/revisions"}],"predecessor-version":[{"id":874,"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/posts\/852\/revisions\/874"}],"wp:attachment":[{"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/media?parent=852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/categories?post=852"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/intelligentonlinetools.com\/blog\/wp-json\/wp\/v2\/tags?post=852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}