This example requires to install three nltk corpora:nltk.corpus.reuters, nltk.corpus.words, nltk.corpus.stopwords.
You can download the corpora via nltk.download()
In [1]:
import logging
import numpy as np
from ptm import GibbsLDA
from ptm import vbLDA
from ptm.nltk_corpus import get_reuters_ids_cnt
from ptm.utils import convert_cnt_to_list, get_top_words
Load reuter corpus including 1000 documents with maximum vocabulary size of 10000 from NLTK corpus
In [2]:
n_doc = 1000
voca, doc_ids, doc_cnt = get_reuters_ids_cnt(num_doc=n_doc, max_voca=10000)
docs = convert_cnt_to_list(doc_ids, doc_cnt)
n_voca = len(voca)
print('Vocabulary size:%d' % n_voca)
Vocabulary size:4632
In [3]:
max_iter=100
n_topic=10
logger = logging.getLogger('GibbsLDA')
logger.propagate = False
model = GibbsLDA(n_doc, len(voca), n_topic)
model.fit(docs, max_iter=max_iter)
2016-02-10 19:42:01 INFO:GibbsLDA:[ITER] 0, elapsed time:0.86, log_likelihood:-447909.18
2016-02-10 19:42:02 INFO:GibbsLDA:[ITER] 1, elapsed time:0.89, log_likelihood:-421738.22
2016-02-10 19:42:03 INFO:GibbsLDA:[ITER] 2, elapsed time:0.94, log_likelihood:-405181.71
2016-02-10 19:42:04 INFO:GibbsLDA:[ITER] 3, elapsed time:0.87, log_likelihood:-393867.42
2016-02-10 19:42:05 INFO:GibbsLDA:[ITER] 4, elapsed time:0.90, log_likelihood:-385570.47
2016-02-10 19:42:06 INFO:GibbsLDA:[ITER] 5, elapsed time:0.90, log_likelihood:-379114.11
2016-02-10 19:42:07 INFO:GibbsLDA:[ITER] 6, elapsed time:0.92, log_likelihood:-374416.99
2016-02-10 19:42:08 INFO:GibbsLDA:[ITER] 7, elapsed time:0.90, log_likelihood:-371338.53
2016-02-10 19:42:09 INFO:GibbsLDA:[ITER] 8, elapsed time:0.88, log_likelihood:-368035.03
2016-02-10 19:42:10 INFO:GibbsLDA:[ITER] 9, elapsed time:0.93, log_likelihood:-365556.67
2016-02-10 19:42:11 INFO:GibbsLDA:[ITER] 10, elapsed time:0.87, log_likelihood:-363627.94
2016-02-10 19:42:11 INFO:GibbsLDA:[ITER] 11, elapsed time:0.84, log_likelihood:-362118.57
2016-02-10 19:42:12 INFO:GibbsLDA:[ITER] 12, elapsed time:0.83, log_likelihood:-360546.38
2016-02-10 19:42:13 INFO:GibbsLDA:[ITER] 13, elapsed time:0.85, log_likelihood:-359183.30
2016-02-10 19:42:14 INFO:GibbsLDA:[ITER] 14, elapsed time:0.96, log_likelihood:-358050.27
2016-02-10 19:42:15 INFO:GibbsLDA:[ITER] 15, elapsed time:0.92, log_likelihood:-357094.26
2016-02-10 19:42:16 INFO:GibbsLDA:[ITER] 16, elapsed time:0.87, log_likelihood:-356045.67
2016-02-10 19:42:17 INFO:GibbsLDA:[ITER] 17, elapsed time:0.84, log_likelihood:-355085.27
2016-02-10 19:42:18 INFO:GibbsLDA:[ITER] 18, elapsed time:0.85, log_likelihood:-354129.45
2016-02-10 19:42:18 INFO:GibbsLDA:[ITER] 19, elapsed time:0.84, log_likelihood:-353360.71
2016-02-10 19:42:19 INFO:GibbsLDA:[ITER] 20, elapsed time:0.90, log_likelihood:-352636.22
2016-02-10 19:42:20 INFO:GibbsLDA:[ITER] 21, elapsed time:0.87, log_likelihood:-352033.27
2016-02-10 19:42:21 INFO:GibbsLDA:[ITER] 22, elapsed time:0.84, log_likelihood:-351298.31
2016-02-10 19:42:22 INFO:GibbsLDA:[ITER] 23, elapsed time:0.84, log_likelihood:-351056.08
2016-02-10 19:42:23 INFO:GibbsLDA:[ITER] 24, elapsed time:0.83, log_likelihood:-350554.31
2016-02-10 19:42:24 INFO:GibbsLDA:[ITER] 25, elapsed time:0.85, log_likelihood:-350214.01
2016-02-10 19:42:25 INFO:GibbsLDA:[ITER] 26, elapsed time:0.84, log_likelihood:-350201.01
2016-02-10 19:42:25 INFO:GibbsLDA:[ITER] 27, elapsed time:0.85, log_likelihood:-349730.70
2016-02-10 19:42:26 INFO:GibbsLDA:[ITER] 28, elapsed time:0.91, log_likelihood:-349007.47
2016-02-10 19:42:27 INFO:GibbsLDA:[ITER] 29, elapsed time:0.85, log_likelihood:-349175.12
2016-02-10 19:42:28 INFO:GibbsLDA:[ITER] 30, elapsed time:0.88, log_likelihood:-348863.94
2016-02-10 19:42:29 INFO:GibbsLDA:[ITER] 31, elapsed time:0.85, log_likelihood:-348612.34
2016-02-10 19:42:30 INFO:GibbsLDA:[ITER] 32, elapsed time:0.90, log_likelihood:-347934.48
2016-02-10 19:42:31 INFO:GibbsLDA:[ITER] 33, elapsed time:0.97, log_likelihood:-347867.02
2016-02-10 19:42:32 INFO:GibbsLDA:[ITER] 34, elapsed time:0.95, log_likelihood:-347414.72
2016-02-10 19:42:33 INFO:GibbsLDA:[ITER] 35, elapsed time:0.86, log_likelihood:-347418.91
2016-02-10 19:42:34 INFO:GibbsLDA:[ITER] 36, elapsed time:0.96, log_likelihood:-347124.65
2016-02-10 19:42:35 INFO:GibbsLDA:[ITER] 37, elapsed time:0.84, log_likelihood:-346625.26
2016-02-10 19:42:35 INFO:GibbsLDA:[ITER] 38, elapsed time:0.83, log_likelihood:-346294.68
2016-02-10 19:42:36 INFO:GibbsLDA:[ITER] 39, elapsed time:0.86, log_likelihood:-346413.61
2016-02-10 19:42:37 INFO:GibbsLDA:[ITER] 40, elapsed time:0.98, log_likelihood:-346242.04
2016-02-10 19:42:38 INFO:GibbsLDA:[ITER] 41, elapsed time:0.89, log_likelihood:-346290.64
2016-02-10 19:42:39 INFO:GibbsLDA:[ITER] 42, elapsed time:0.86, log_likelihood:-346108.81
2016-02-10 19:42:40 INFO:GibbsLDA:[ITER] 43, elapsed time:0.96, log_likelihood:-345780.29
2016-02-10 19:42:41 INFO:GibbsLDA:[ITER] 44, elapsed time:0.91, log_likelihood:-345771.55
2016-02-10 19:42:42 INFO:GibbsLDA:[ITER] 45, elapsed time:0.85, log_likelihood:-345758.19
2016-02-10 19:42:43 INFO:GibbsLDA:[ITER] 46, elapsed time:0.95, log_likelihood:-345798.00
2016-02-10 19:42:44 INFO:GibbsLDA:[ITER] 47, elapsed time:0.95, log_likelihood:-345794.09
2016-02-10 19:42:45 INFO:GibbsLDA:[ITER] 48, elapsed time:0.95, log_likelihood:-345631.54
2016-02-10 19:42:46 INFO:GibbsLDA:[ITER] 49, elapsed time:0.89, log_likelihood:-345489.19
2016-02-10 19:42:47 INFO:GibbsLDA:[ITER] 50, elapsed time:1.01, log_likelihood:-345386.81
2016-02-10 19:42:48 INFO:GibbsLDA:[ITER] 51, elapsed time:0.93, log_likelihood:-345105.51
2016-02-10 19:42:49 INFO:GibbsLDA:[ITER] 52, elapsed time:0.95, log_likelihood:-345095.54
2016-02-10 19:42:49 INFO:GibbsLDA:[ITER] 53, elapsed time:0.89, log_likelihood:-344779.87
2016-02-10 19:42:50 INFO:GibbsLDA:[ITER] 54, elapsed time:0.91, log_likelihood:-344897.46
2016-02-10 19:42:51 INFO:GibbsLDA:[ITER] 55, elapsed time:0.91, log_likelihood:-344546.15
2016-02-10 19:42:52 INFO:GibbsLDA:[ITER] 56, elapsed time:0.88, log_likelihood:-344541.70
2016-02-10 19:42:53 INFO:GibbsLDA:[ITER] 57, elapsed time:0.89, log_likelihood:-344516.72
2016-02-10 19:42:54 INFO:GibbsLDA:[ITER] 58, elapsed time:0.94, log_likelihood:-344702.70
2016-02-10 19:42:55 INFO:GibbsLDA:[ITER] 59, elapsed time:0.94, log_likelihood:-344196.74
2016-02-10 19:42:56 INFO:GibbsLDA:[ITER] 60, elapsed time:0.90, log_likelihood:-344231.88
2016-02-10 19:42:57 INFO:GibbsLDA:[ITER] 61, elapsed time:0.89, log_likelihood:-344436.79
2016-02-10 19:42:58 INFO:GibbsLDA:[ITER] 62, elapsed time:0.88, log_likelihood:-343805.88
2016-02-10 19:42:59 INFO:GibbsLDA:[ITER] 63, elapsed time:0.91, log_likelihood:-344083.66
2016-02-10 19:43:00 INFO:GibbsLDA:[ITER] 64, elapsed time:0.91, log_likelihood:-344131.20
2016-02-10 19:43:00 INFO:GibbsLDA:[ITER] 65, elapsed time:0.87, log_likelihood:-344327.27
2016-02-10 19:43:01 INFO:GibbsLDA:[ITER] 66, elapsed time:0.85, log_likelihood:-343887.94
2016-02-10 19:43:02 INFO:GibbsLDA:[ITER] 67, elapsed time:0.84, log_likelihood:-343762.63
2016-02-10 19:43:03 INFO:GibbsLDA:[ITER] 68, elapsed time:0.93, log_likelihood:-343623.01
2016-02-10 19:43:04 INFO:GibbsLDA:[ITER] 69, elapsed time:0.89, log_likelihood:-343498.40
2016-02-10 19:43:05 INFO:GibbsLDA:[ITER] 70, elapsed time:0.87, log_likelihood:-343147.74
2016-02-10 19:43:06 INFO:GibbsLDA:[ITER] 71, elapsed time:0.85, log_likelihood:-343025.72
2016-02-10 19:43:07 INFO:GibbsLDA:[ITER] 72, elapsed time:0.87, log_likelihood:-343189.09
2016-02-10 19:43:08 INFO:GibbsLDA:[ITER] 73, elapsed time:0.89, log_likelihood:-343104.90
2016-02-10 19:43:09 INFO:GibbsLDA:[ITER] 74, elapsed time:0.88, log_likelihood:-343020.70
2016-02-10 19:43:09 INFO:GibbsLDA:[ITER] 75, elapsed time:0.91, log_likelihood:-342822.27
2016-02-10 19:43:10 INFO:GibbsLDA:[ITER] 76, elapsed time:0.86, log_likelihood:-342671.10
2016-02-10 19:43:11 INFO:GibbsLDA:[ITER] 77, elapsed time:0.87, log_likelihood:-342537.95
2016-02-10 19:43:12 INFO:GibbsLDA:[ITER] 78, elapsed time:0.88, log_likelihood:-342711.56
2016-02-10 19:43:13 INFO:GibbsLDA:[ITER] 79, elapsed time:0.87, log_likelihood:-342544.57
2016-02-10 19:43:14 INFO:GibbsLDA:[ITER] 80, elapsed time:0.88, log_likelihood:-342719.10
2016-02-10 19:43:15 INFO:GibbsLDA:[ITER] 81, elapsed time:0.92, log_likelihood:-342605.74
2016-02-10 19:43:16 INFO:GibbsLDA:[ITER] 82, elapsed time:0.87, log_likelihood:-342609.81
2016-02-10 19:43:17 INFO:GibbsLDA:[ITER] 83, elapsed time:0.90, log_likelihood:-342740.90
2016-02-10 19:43:18 INFO:GibbsLDA:[ITER] 84, elapsed time:0.89, log_likelihood:-342668.54
2016-02-10 19:43:18 INFO:GibbsLDA:[ITER] 85, elapsed time:0.89, log_likelihood:-342678.21
2016-02-10 19:43:19 INFO:GibbsLDA:[ITER] 86, elapsed time:0.87, log_likelihood:-342797.02
2016-02-10 19:43:20 INFO:GibbsLDA:[ITER] 87, elapsed time:0.92, log_likelihood:-342652.20
2016-02-10 19:43:21 INFO:GibbsLDA:[ITER] 88, elapsed time:0.89, log_likelihood:-342328.18
2016-02-10 19:43:22 INFO:GibbsLDA:[ITER] 89, elapsed time:0.88, log_likelihood:-342428.68
2016-02-10 19:43:23 INFO:GibbsLDA:[ITER] 90, elapsed time:0.90, log_likelihood:-342853.29
2016-02-10 19:43:24 INFO:GibbsLDA:[ITER] 91, elapsed time:0.87, log_likelihood:-342336.00
2016-02-10 19:43:25 INFO:GibbsLDA:[ITER] 92, elapsed time:0.89, log_likelihood:-342357.74
2016-02-10 19:43:26 INFO:GibbsLDA:[ITER] 93, elapsed time:0.89, log_likelihood:-341976.18
2016-02-10 19:43:27 INFO:GibbsLDA:[ITER] 94, elapsed time:0.93, log_likelihood:-342270.78
2016-02-10 19:43:28 INFO:GibbsLDA:[ITER] 95, elapsed time:0.94, log_likelihood:-342271.96
2016-02-10 19:43:29 INFO:GibbsLDA:[ITER] 96, elapsed time:0.94, log_likelihood:-342092.68
2016-02-10 19:43:30 INFO:GibbsLDA:[ITER] 97, elapsed time:0.92, log_likelihood:-341932.06
2016-02-10 19:43:30 INFO:GibbsLDA:[ITER] 98, elapsed time:0.90, log_likelihood:-342061.92
2016-02-10 19:43:31 INFO:GibbsLDA:[ITER] 99, elapsed time:0.89, log_likelihood:-341768.40
In [4]:
for ti in range(n_topic):
top_words = get_top_words(model.TW, voca, ti, n_words=10)
print('Topic', ti ,': ', ','.join(top_words))
Topic 0 : market,bank,week,rate,rose,money,two,rise,three,fed
Topic 1 : quarter,first,april,record,earnings,dividend,share,prior,may,one
Topic 2 : oil,dome,one,debt,gas,price,plan,new,would,energy
Topic 3 : nil,stocks,production,total,end,use,start,soybean,supply,demand
Topic 4 : last,month,wheat,crop,grain,department,sugar,april,week,export
Topic 5 : loss,profit,corp,note,tax,chemical,gain,quarter,nine,operating
Topic 6 : trade,government,last,also,deficit,would,surplus,foreign,canada,industry
Topic 7 : japan,would,could,economic,japanese,market,west,growth,meeting,policy
Topic 8 : dollar,bank,yen,interest,exchange,term,days,currency,rate,current
Topic 9 : share,offer,stock,corp,acquisition,would,group,common,also,cash
In [5]:
logger = logging.getLogger('vbLDA')
logger.propagate = False
vbmodel = vbLDA(n_doc, n_voca, n_topic)
vbmodel.fit(doc_ids, doc_cnt, max_iter=max_iter)
2016-02-10 19:43:32 INFO:vbLDA:[ITER] 0, elapsed time:0.79, ELBO:-478629.24
2016-02-10 19:43:33 INFO:vbLDA:[ITER] 1, elapsed time:0.78, ELBO:-424352.68
2016-02-10 19:43:34 INFO:vbLDA:[ITER] 2, elapsed time:0.79, ELBO:-380711.73
2016-02-10 19:43:34 INFO:vbLDA:[ITER] 3, elapsed time:0.76, ELBO:-364218.72
2016-02-10 19:43:35 INFO:vbLDA:[ITER] 4, elapsed time:0.72, ELBO:-357506.75
2016-02-10 19:43:36 INFO:vbLDA:[ITER] 5, elapsed time:0.69, ELBO:-354117.34
2016-02-10 19:43:37 INFO:vbLDA:[ITER] 6, elapsed time:0.69, ELBO:-352265.21
2016-02-10 19:43:37 INFO:vbLDA:[ITER] 7, elapsed time:0.69, ELBO:-351168.75
2016-02-10 19:43:38 INFO:vbLDA:[ITER] 8, elapsed time:0.65, ELBO:-350393.52
2016-02-10 19:43:39 INFO:vbLDA:[ITER] 9, elapsed time:0.65, ELBO:-349864.68
2016-02-10 19:43:39 INFO:vbLDA:[ITER] 10, elapsed time:0.64, ELBO:-349479.59
2016-02-10 19:43:40 INFO:vbLDA:[ITER] 11, elapsed time:0.66, ELBO:-349231.45
2016-02-10 19:43:40 INFO:vbLDA:[ITER] 12, elapsed time:0.64, ELBO:-349048.99
2016-02-10 19:43:41 INFO:vbLDA:[ITER] 13, elapsed time:0.64, ELBO:-348919.67
2016-02-10 19:43:42 INFO:vbLDA:[ITER] 14, elapsed time:0.63, ELBO:-348796.75
2016-02-10 19:43:42 INFO:vbLDA:[ITER] 15, elapsed time:0.65, ELBO:-348698.18
2016-02-10 19:43:43 INFO:vbLDA:[ITER] 16, elapsed time:0.65, ELBO:-348608.65
2016-02-10 19:43:44 INFO:vbLDA:[ITER] 17, elapsed time:0.64, ELBO:-348538.82
2016-02-10 19:43:44 INFO:vbLDA:[ITER] 18, elapsed time:0.62, ELBO:-348471.38
2016-02-10 19:43:45 INFO:vbLDA:[ITER] 19, elapsed time:0.63, ELBO:-348418.05
2016-02-10 19:43:46 INFO:vbLDA:[ITER] 20, elapsed time:0.62, ELBO:-348372.82
2016-02-10 19:43:46 INFO:vbLDA:[ITER] 21, elapsed time:0.63, ELBO:-348327.48
2016-02-10 19:43:47 INFO:vbLDA:[ITER] 22, elapsed time:0.63, ELBO:-348286.69
2016-02-10 19:43:47 INFO:vbLDA:[ITER] 23, elapsed time:0.63, ELBO:-348257.43
2016-02-10 19:43:48 INFO:vbLDA:[ITER] 24, elapsed time:0.61, ELBO:-348232.60
2016-02-10 19:43:49 INFO:vbLDA:[ITER] 25, elapsed time:0.63, ELBO:-348203.76
2016-02-10 19:43:49 INFO:vbLDA:[ITER] 26, elapsed time:0.62, ELBO:-348182.56
2016-02-10 19:43:50 INFO:vbLDA:[ITER] 27, elapsed time:0.62, ELBO:-348160.58
2016-02-10 19:43:51 INFO:vbLDA:[ITER] 28, elapsed time:0.64, ELBO:-348144.50
2016-02-10 19:43:51 INFO:vbLDA:[ITER] 29, elapsed time:0.65, ELBO:-348122.57
2016-02-10 19:43:52 INFO:vbLDA:[ITER] 30, elapsed time:0.66, ELBO:-348109.34
2016-02-10 19:43:53 INFO:vbLDA:[ITER] 31, elapsed time:0.63, ELBO:-348098.76
2016-02-10 19:43:53 INFO:vbLDA:[ITER] 32, elapsed time:0.62, ELBO:-348084.17
2016-02-10 19:43:54 INFO:vbLDA:[ITER] 33, elapsed time:0.61, ELBO:-348071.97
2016-02-10 19:43:54 INFO:vbLDA:[ITER] 34, elapsed time:0.63, ELBO:-348059.91
2016-02-10 19:43:55 INFO:vbLDA:[ITER] 35, elapsed time:0.62, ELBO:-348051.82
2016-02-10 19:43:56 INFO:vbLDA:[ITER] 36, elapsed time:0.65, ELBO:-348045.39
2016-02-10 19:43:56 INFO:vbLDA:[ITER] 37, elapsed time:0.60, ELBO:-348034.56
2016-02-10 19:43:57 INFO:vbLDA:[ITER] 38, elapsed time:0.63, ELBO:-348025.53
2016-02-10 19:43:58 INFO:vbLDA:[ITER] 39, elapsed time:0.61, ELBO:-348018.32
2016-02-10 19:43:58 INFO:vbLDA:[ITER] 40, elapsed time:0.60, ELBO:-348011.50
2016-02-10 19:43:59 INFO:vbLDA:[ITER] 41, elapsed time:0.62, ELBO:-348008.20
2016-02-10 19:43:59 INFO:vbLDA:[ITER] 42, elapsed time:0.61, ELBO:-348007.99
2016-02-10 19:44:00 INFO:vbLDA:[ITER] 43, elapsed time:0.62, ELBO:-348007.58
2016-02-10 19:44:01 INFO:vbLDA:[ITER] 44, elapsed time:0.61, ELBO:-348006.46
2016-02-10 19:44:01 INFO:vbLDA:[ITER] 45, elapsed time:0.63, ELBO:-348003.09
2016-02-10 19:44:02 INFO:vbLDA:[ITER] 46, elapsed time:0.61, ELBO:-347999.54
2016-02-10 19:44:02 INFO:vbLDA:[ITER] 47, elapsed time:0.61, ELBO:-347995.14
2016-02-10 19:44:03 INFO:vbLDA:[ITER] 48, elapsed time:0.60, ELBO:-347992.98
2016-02-10 19:44:04 INFO:vbLDA:[ITER] 49, elapsed time:0.59, ELBO:-347990.23
2016-02-10 19:44:04 INFO:vbLDA:[ITER] 50, elapsed time:0.59, ELBO:-347986.13
2016-02-10 19:44:05 INFO:vbLDA:[ITER] 51, elapsed time:0.59, ELBO:-347984.36
2016-02-10 19:44:05 INFO:vbLDA:[ITER] 52, elapsed time:0.60, ELBO:-347981.83
2016-02-10 19:44:06 INFO:vbLDA:[ITER] 53, elapsed time:0.59, ELBO:-347980.00
2016-02-10 19:44:07 INFO:vbLDA:[ITER] 54, elapsed time:0.60, ELBO:-347975.99
2016-02-10 19:44:07 INFO:vbLDA:[ITER] 55, elapsed time:0.58, ELBO:-347973.46
2016-02-10 19:44:08 INFO:vbLDA:[ITER] 56, elapsed time:0.60, ELBO:-347970.75
2016-02-10 19:44:08 INFO:vbLDA:[ITER] 57, elapsed time:0.59, ELBO:-347970.34
2016-02-10 19:44:09 INFO:vbLDA:[ITER] 58, elapsed time:0.60, ELBO:-347970.31
2016-02-10 19:44:10 INFO:vbLDA:[ITER] 59, elapsed time:0.59, ELBO:-347970.25
2016-02-10 19:44:10 INFO:vbLDA:[ITER] 60, elapsed time:0.60, ELBO:-347970.11
2016-02-10 19:44:11 INFO:vbLDA:[ITER] 61, elapsed time:0.65, ELBO:-347969.67
2016-02-10 19:44:12 INFO:vbLDA:[ITER] 62, elapsed time:0.69, ELBO:-347968.08
2016-02-10 19:44:12 INFO:vbLDA:[ITER] 63, elapsed time:0.67, ELBO:-347967.16
2016-02-10 19:44:13 INFO:vbLDA:[ITER] 64, elapsed time:0.65, ELBO:-347966.72
2016-02-10 19:44:13 INFO:vbLDA:[ITER] 65, elapsed time:0.63, ELBO:-347965.37
2016-02-10 19:44:14 INFO:vbLDA:[ITER] 66, elapsed time:0.62, ELBO:-347964.13
2016-02-10 19:44:15 INFO:vbLDA:[ITER] 67, elapsed time:0.62, ELBO:-347964.13
2016-02-10 19:44:15 INFO:vbLDA:[ITER] 68, elapsed time:0.63, ELBO:-347964.12
2016-02-10 19:44:16 INFO:vbLDA:[ITER] 69, elapsed time:0.63, ELBO:-347964.11
2016-02-10 19:44:17 INFO:vbLDA:[ITER] 70, elapsed time:0.65, ELBO:-347964.11
2016-02-10 19:44:17 INFO:vbLDA:[ITER] 71, elapsed time:0.65, ELBO:-347964.10
2016-02-10 19:44:18 INFO:vbLDA:[ITER] 72, elapsed time:0.64, ELBO:-347964.08
2016-02-10 19:44:19 INFO:vbLDA:[ITER] 73, elapsed time:0.62, ELBO:-347964.06
2016-02-10 19:44:19 INFO:vbLDA:[ITER] 74, elapsed time:0.64, ELBO:-347964.02
2016-02-10 19:44:20 INFO:vbLDA:[ITER] 75, elapsed time:0.62, ELBO:-347963.94
2016-02-10 19:44:20 INFO:vbLDA:[ITER] 76, elapsed time:0.62, ELBO:-347963.75
2016-02-10 19:44:21 INFO:vbLDA:[ITER] 77, elapsed time:0.62, ELBO:-347963.15
2016-02-10 19:44:22 INFO:vbLDA:[ITER] 78, elapsed time:0.62, ELBO:-347961.36
2016-02-10 19:44:22 INFO:vbLDA:[ITER] 79, elapsed time:0.64, ELBO:-347960.89
2016-02-10 19:44:23 INFO:vbLDA:[ITER] 80, elapsed time:0.62, ELBO:-347960.88
2016-02-10 19:44:24 INFO:vbLDA:[ITER] 81, elapsed time:0.61, ELBO:-347960.86
2016-02-10 19:44:24 INFO:vbLDA:[ITER] 82, elapsed time:0.59, ELBO:-347960.78
2016-02-10 19:44:25 INFO:vbLDA:[ITER] 83, elapsed time:0.64, ELBO:-347960.45
2016-02-10 19:44:25 INFO:vbLDA:[ITER] 84, elapsed time:0.64, ELBO:-347959.02
2016-02-10 19:44:26 INFO:vbLDA:[ITER] 85, elapsed time:0.64, ELBO:-347958.29
2016-02-10 19:44:27 INFO:vbLDA:[ITER] 86, elapsed time:0.69, ELBO:-347958.28
2016-02-10 19:44:27 INFO:vbLDA:[ITER] 87, elapsed time:0.64, ELBO:-347958.28
2016-02-10 19:44:28 INFO:vbLDA:[ITER] 88, elapsed time:0.62, ELBO:-347958.28
2016-02-10 19:44:29 INFO:vbLDA:[ITER] 89, elapsed time:0.61, ELBO:-347958.27
2016-02-10 19:44:29 INFO:vbLDA:[ITER] 90, elapsed time:0.59, ELBO:-347958.27
2016-02-10 19:44:30 INFO:vbLDA:[ITER] 91, elapsed time:0.59, ELBO:-347958.26
2016-02-10 19:44:30 INFO:vbLDA:[ITER] 92, elapsed time:0.60, ELBO:-347958.26
2016-02-10 19:44:31 INFO:vbLDA:[ITER] 93, elapsed time:0.63, ELBO:-347958.25
2016-02-10 19:44:32 INFO:vbLDA:[ITER] 94, elapsed time:0.65, ELBO:-347958.24
2016-02-10 19:44:32 INFO:vbLDA:[ITER] 95, elapsed time:0.66, ELBO:-347958.23
2016-02-10 19:44:33 INFO:vbLDA:[ITER] 96, elapsed time:0.61, ELBO:-347958.23
2016-02-10 19:44:34 INFO:vbLDA:[ITER] 97, elapsed time:0.59, ELBO:-347958.22
2016-02-10 19:44:34 INFO:vbLDA:[ITER] 98, elapsed time:0.58, ELBO:-347958.20
2016-02-10 19:44:35 INFO:vbLDA:[ITER] 99, elapsed time:0.59, ELBO:-347958.19
In [6]:
for ti in range(n_topic):
top_words = get_top_words(vbmodel._lambda, voca, ti, n_words=10)
print('Topic', ti ,': ', ','.join(top_words))
Topic 0 : share,stock,profit,would,offer,corp,earnings,per,dividend,first
Topic 1 : fed,price,trade,may,two,april,market,reserve,would,japan
Topic 2 : dollar,would,one,foreign,growth,last,trade,economic,week,rise
Topic 3 : loss,profit,corp,note,quarter,national,share,gain,one,first
Topic 4 : bank,market,week,days,rate,money,new,april,today,day
Topic 5 : quarter,first,tax,share,income,april,bank,dividend,record,may
Topic 6 : oil,quarter,first,gas,march,gold,february,price,earnings,last
Topic 7 : japan,dollar,trade,would,yen,dome,japanese,market,also,agreement
Topic 8 : nil,last,stocks,month,production,total,grain,crop,wheat,end
Topic 9 : share,corp,april,wheat,price,new,group,would,exchange,department
In [ ]:
Content source: arongdari/python-topic-model
Similar notebooks: