2016-09-02 14 views
0

私はgensimLdaModelを使用しています。documentationによれば、パラメータはrandom_stateです。しかし、私が言うエラー取得しています:LdaModel - random_stateパラメータが認識されない - gensim

TypeError: __init__() got an unexpected keyword argument 'random_state' 

random_stateパラメータを指定しないと予想されるように、機能が動作します。だから、ワークフローが...何が起こっている他に何を知りたいもののために、このようになります

上記のエラーメッセージになり
from gensim import corpora, models 
import numpy as np 

# pseudo code of text pre-processing all on "comments" variable 
# stop words 
# remove punctuation (optional) 
# keep alpha only 
# stemming 
# get bigrams and integrate with corpus (gensim makes this very easy) 


dictionary = corpora.Dictionary(comments) 
corpus = [dictionary.doc2bow(comm) for comm in comments] 
tfidf = models.TfidfModel(corpus) # change weights 
corp_tfidf = tfidf[corpus] # apply them to corpus 

# set random seed 
random_seed = 135 
state = np.random.RandomState(random_seed) 

# train model 
num_topics = 3 
lda_mod = models.LdaModel(corp_tfidf, # corpus 
          num_topics=num_topics, # number of topics we want back 
          id2word=dictionary, # our id-word map 
          passes=10, # how many passes to take over the data 
          random_state=state) # reproduce the results 

...

TypeError: __init__() got an unexpected keyword argument 'random_state' 

私はなりたいです可能であれば、結果を再現することができます。

答えて

1

thisによると、random_stateパラメータが最新バージョン(0.13.2)で追加されました。 gensimインストールをpip install gensim --upgradeで更新できます。問題が発生したため、scipyをまず更新する必要があります。

関連する問題