【发布时间】:2020-08-05 23:56:17
【问题描述】:
我阅读了有关 random_state 的 gensim LDA 模型文档,其中指出:
random_state ({np.random.RandomState, int}, optional)
– 一个 randomState 对象或一个种子来生成一个。有助于重现性。
我一直在尝试把 random_state=42 或
random_seed=42
state=np.random.RandomState(random_seed)
state.randn(1)
random_state=state.randn(1)
这不起作用。谁能建议我该怎么做
model=ldaModel(corpus=corpus, id2word=dictionary, num_topics=num_topics, random_state=None)
我绑定在没有 random_state 的情况下使用它的功能,但使用 random_state 我收到错误消息说 LDA 模型未定义
def compute_coherence_values(字典、语料库、文本、限制、random_state、start=2、 步骤=3):
coherence_values = []
model_list = []
for num_topics in range(start, limit, step):
#model=LdaModel(corpus=corpus, id2word=dictionary, num_topics=num_topics)
model=ldaModel(corpus=corpus, id2word=dictionary, num_topics=num_topics,
random_state)
model_list.append(model)
coherencemodel = CoherenceModel(model=model, texts=texts, dictionary=dictionary, coherence='c_v')
coherence_values.append(coherencemodel.get_coherence())
return model_list, coherence_values
【问题讨论】: