{"id":301399,"date":"2020-04-07T09:00:16","date_gmt":"2020-04-07T09:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=301399"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=301399","title":{"rendered":"LDA \u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 LiveJournal + \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/495852\/\">\u041a\u0430\u043a-\u0442\u043e \u0440\u0430\u0437 \u0441\u0442\u0430\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a\u0438\u0435 \u0442\u0435\u043c\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u0442 LDA (\u043b\u0430\u0442\u0435\u043d\u0442\u043d\u043e\u0435 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0414\u0438\u0440\u0438\u0445\u043b\u0435) \u043d\u0430 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430\u0445 \u00ab\u0416\u0438\u0432\u043e\u0433\u043e \u0416\u0443\u0440\u043d\u0430\u043b\u0430\u00bb. \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u2014 \u043d\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. <br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e LDA \u043d\u0430 \u043f\u0430\u043b\u044c\u0446\u0430\u0445, \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c (\u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u2014 \u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442). \u0418\u0442\u0430\u043a, LDA \u2014 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043c. \u041a\u0430\u0436\u0434\u044b\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 (\u0431\u0443\u0434\u044c \u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f, \u043a\u043d\u0438\u0433\u0430 \u0438\u043b\u0438 \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445) \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043c\u0435\u0441\u044c \u0442\u0435\u043c, \u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u0442\u0435\u043c\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043c\u0435\u0441\u044c \u0441\u043b\u043e\u0432. <br \/>  <a name=\"habracut\"><\/a><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/so\/xn\/yb\/soxnybbxasatclgqktqkyyafhhu.png\"><br \/>  \u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0432\u0437\u044f\u0442\u0430 \u0441 \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438<br \/>  <cut><\/cut><br \/>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0437\u0430\u0434\u0430\u0447\u0430 LDA \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430\u0439\u0442\u0438 \u0433\u0440\u0443\u043f\u043f\u044b \u0441\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0442\u0435\u043c\u044b. \u041f\u043e\u0442\u043e\u043c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430.<br \/>  <cut><\/cut><br \/>  \u0421 \u0441\u0430\u0439\u0442\u0430 LifeJournal \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430 1800 \u0441\u0442\u0430\u0442\u0435\u0439, \u0432\u0441\u0435 \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 jsonl<br \/>  \u041d\u0435\u043e\u0447\u0438\u0449\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u043d\u0430 <a href=\"https:\/\/yadi.sk\/d\/wBEOjXCZ7q1upg\" rel=\"nofollow\">\u044f\u043d\u0434\u0435\u043a\u0441 \u0434\u0438\u0441\u043a\u0435<\/a>. \u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445: \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u043c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u0443\u0434\u0430\u043b\u0438\u043c \u0441\u0442\u043e\u043f-\u0441\u043b\u043e\u0432\u0430 (\u0441\u043f\u0438\u0441\u043e\u043a \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 <a href=\"https:\/\/github.com\/Liza1928\/articles-LDA\" rel=\"nofollow\">github<\/a>), \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0432\u0441\u0435 \u0441\u043b\u043e\u0432\u0430 \u043a \u0441\u0442\u0440\u043e\u0447\u043d\u043e\u043c\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e, \u0443\u0434\u0430\u043b\u0438\u043c \u043f\u0443\u043d\u043a\u0442\u0443\u0430\u0446\u0438\u044e \u0438 \u0441\u043b\u043e\u0432\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 3 \u0431\u0443\u043a\u0432\u044b \u0438 \u043c\u0435\u043d\u044c\u0448\u0435. \u041d\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438: \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0441\u043b\u043e\u0432, \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043c\u043e\u0436\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c\u0441\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u043e\u043f-\u0441\u043b\u043e\u0432, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u0447\u0430\u0441\u0442\u043e \u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0431\u0443\u0434\u0443\u0442 \u0432\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043e \u0432\u0441\u0435 \u0442\u0435\u043c\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043f\u043e\u0441\u0442\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430. \u0412\u044b\u0431\u043e\u0440 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u0412\u0430\u043c\u0438.<br \/>  <cut><\/cut>  <\/p>\n<pre><code class=\"python\">stop=open('stop.txt') stop_words=[] for line in stop:     stop_words.append(line) for i in range(0,len(stop_words)):     stop_words[i]=stop_words[i][:-1] # specific regular expresion for this texts  texts=[re.split( r' [\\w\\.\\&amp;\\?!,_\\-#)(:;*%$\u2116&quot;\\@]*\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432' ,texts[i])[0].replace(&quot;\\n&quot;,&quot;&quot;) for i in range(0,len(texts))]        # remove punctuation texts=[test_re(line) for line in texts] texts=[t.lower() for t in texts] # remove stop words texts = [[word for word in document.split() if word not in stop_words] for document in texts] texts=[[word for word in document if len(word)&gt;=3]for document in texts] <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0432\u0441\u0435 \u0441\u043b\u043e\u0432\u0430 \u043a \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435: \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 pymorphy2, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 pip.<br \/>  <cut><\/cut>  <\/p>\n<pre><code class=\"python\">morph = pymorphy2.MorphAnalyzer() for i in range(0,len(texts)):     for j in range(0,len(texts[i])):         texts[i][j] =  morph.parse(texts[i][j])[0].normal_form<\/code><\/pre>\n<p>  \u0414\u0430, \u043c\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0444\u043e\u0440\u043c\u0435 \u0441\u043b\u043e\u0432, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0441\u043e\u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u0441\u043b\u043e\u0432 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u041d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u0448\u0430 \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u043e\u043d\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0439, \u043d\u043e \u043e\u043d\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c LDA.<br \/>  <cut><\/cut><br \/>  \u0414\u0430\u043b\u0435\u0435 \u0442\u043e\u0442 \u043f\u0443\u043d\u043a\u0442, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435, \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c, \u043d\u043e \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u0435\u0435, \u043e\u043f\u044f\u0442\u044c-\u0442\u0430\u043a\u0438 \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u0440\u043e\u0433 \u0431\u0443\u0434\u0435\u0442, \u0440\u0435\u0448\u0430\u0442\u044c \u0432\u0430\u043c, \u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0443\u044e \u043e\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0434\u043b\u0438\u043d\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430:<br \/>  <cut><\/cut>  <\/p>\n<pre><code class=\"python\">counter = collections.Counter() for t in texts:     for r in t:         counter[r]+=1 limit = len(texts)\/5 too_common = [w for w in counter if counter[w] &gt; limit] too_common=set(too_common) texts = [[word for word in document if word not in too_common] for document in texts]<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0438, \u0434\u043b\u044f \u044d\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 gensim, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043a\u0443\u0447\u0443 \u043f\u0440\u0438\u043a\u043e\u043b\u044c\u043d\u044b\u0445 \u043f\u043b\u044e\u0448\u0435\u043a. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u043b\u043e\u0432\u0430, \u044d\u0442\u043e \u0437\u0430 \u043d\u0430\u0441 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f Dictionary, \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0441\u043b\u043e\u0432\u0430 \u043d\u0430 \u0438\u0445 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u044b. \u0417\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 LDA \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0434\u043e\u043b\u0433\u0438\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<br \/>  <cut><\/cut>  <\/p>\n<pre><code class=\"python\">texts=preposition_text_for_lda(my_r) dictionary = gensim.corpora.Dictionary(texts) corpus = [dictionary.doc2bow(text) for text in texts] #lda = gensim.models.ldamodel.LdaModel(corpus=corpus, id2word=dictionary, num_topics=10, update_every=1, chunksize=1, passes=1) lda = gensim.models.ldamodel.LdaModel(corpus=corpus, id2word=dictionary, num_topics=10)<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0442\u0435\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b<br \/>  <cut><\/cut>  <\/p>\n<pre><code class=\"python\">lda.show_topic(i,topn=30)<\/code><\/pre>\n<p>  <cut><\/cut>, \u0433\u0434\u0435 i \u2014 \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043c\u044b, \u0430 topn \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043b\u043e\u0432 \u0432 \u0442\u0435\u043c\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u044b.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0431\u043e\u043d\u0443\u0441 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u043c, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 wordcloud (\u0432\u0440\u043e\u0434\u0435, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0435\u0441\u0442\u044c \u0438 \u0432 matplotlib). \u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0442\u0435\u043c\u044b \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0438\u0445 \u0432 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u043f\u0430\u043f\u043a\u0443.<br \/>  <cut><\/cut>  <\/p>\n<pre><code class=\"python\">from wordcloud import WordCloud, STOPWORDS for i in range(0,10):     a=lda.show_topic(i,topn=30)     wordcloud = WordCloud(                           relative_scaling = 1.0,                           stopwords = too_common # set or space-separated string                           ).generate_from_frequencies(dict(a))     wordcloud.to_file('society'+str(i)+'.png')  <\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0445\u0441\u044f \u0443 \u043c\u0435\u043d\u044f \u0442\u0435\u043c:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/3f\/9f\/r_\/3f9fr_c5ta3bvodrtk2ugnaolo8.png\"><br \/>  <cut><\/cut><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jb\/zi\/32\/jbzi32wizbdzbooiakzojxbo9d0.png\"><br \/>  <cut><\/cut><br \/>  \u042d\u043a\u0441\u043f\u0435\u0440\u0435\u043c\u0438\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/495852\/\"> https:\/\/habr.com\/ru\/post\/495852\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/495852\/\">\u041a\u0430\u043a-\u0442\u043e \u0440\u0430\u0437 \u0441\u0442\u0430\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a\u0438\u0435 \u0442\u0435\u043c\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u0442 LDA (\u043b\u0430\u0442\u0435\u043d\u0442\u043d\u043e\u0435 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0414\u0438\u0440\u0438\u0445\u043b\u0435) \u043d\u0430 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430\u0445 \u00ab\u0416\u0438\u0432\u043e\u0433\u043e \u0416\u0443\u0440\u043d\u0430\u043b\u0430\u00bb. \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u2014 \u043d\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. <br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e LDA \u043d\u0430 \u043f\u0430\u043b\u044c\u0446\u0430\u0445, \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c (\u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u2014 \u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442). \u0418\u0442\u0430\u043a, LDA \u2014 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043c. \u041a\u0430\u0436\u0434\u044b\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 (\u0431\u0443\u0434\u044c \u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f, \u043a\u043d\u0438\u0433\u0430 \u0438\u043b\u0438 \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445) \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043c\u0435\u0441\u044c \u0442\u0435\u043c, \u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u0442\u0435\u043c\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043c\u0435\u0441\u044c \u0441\u043b\u043e\u0432.   <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-301399","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=301399"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301399\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301399"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}