查看完整版本: Python3.6-LDA模型_特徵值分布
頁: [1]

凱斯先生 發表於 2018-1-28 12:15 PM

Python3.6-LDA模型_特徵值分布

圖一

圖二

with open('C:\conte-out.txt',encoding='utf8') as f3:
    ks = f3.read()

stpwrdpath = ("C:\stopwords.txt")
stpwrd_dic = open(stpwrdpath, 'rb')
stpwrd_content = stpwrd_dic.read()

stpwrdlst = stpwrd_content.splitlines()
stpwrd_dic.close()
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.decomposition import LatentDirichletAllocation
corpus =
cntVector = CountVectorizer(stop_words=stpwrdlst)
cntTf = cntVector.fit_transform(corpus)
print (cntTf)
import numpy as np
np.set_printoptions(threshold=np.inf, precision=8)
lda = LatentDirichletAllocation(n_topics=120,
                                learning_offset=50.,
                                random_state=0)
docres = lda.fit_transform(cntTf)
print(lda.components_,file = open('c:/testone.txt','a',encoding='utf8'))


----------------------------------------------------
這不是伸手文,只是不太了解....n_topics=120  我將主題數設定為某值後,輸出後應該是T1,T2,T3嗎@@
為何會變成圖一這樣子0.0

另外,print(lda.components_),看國外的討論之後,還是不知道他的功能是什麼,有人說是主題和詞分布(圖2)
輸出後跑出了291481筆的數值..也不清楚哪個是主題哪個是詞...
------------------------------------------------------------------------------------------------------------
我的資料總共才294筆數據(1筆為一天),也就是294天的資料..
麻煩各位大哥姐姐們,解答疑問,感謝您們。


...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div><div></div>
頁: [1]