gpt4 book ai didi

python - 包装器的 Gensim 模块属性错误

转载 作者:行者123 更新时间:2023-12-04 16:24:45 24 4
gpt4 key购买 nike

我将找到 LDA 的最佳主题数。为此,我使用了 GENSIM 如下:

def compute_coherence_values(dictionary, corpus, texts, limit, start=2, step=3):
coherence_values = []
model_list = []
for num_topics in range(start, limit, step):
model = gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus, num_topics=num_topics, id2word=id2word)
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


但是我有一个属性错误:我使用了 spyder。
AttributeError: module 'gensim.models' has no attribute 'wrappers'

最佳答案

最新的主要 Gensim 版本 4.0 删除了 wrappers其他库算法。每 "Migrating from Gensim 3.x to 4" wiki page :

15. Removed third party wrappers

These wrappers of 3rd party libraries required too much effort. There were no volunteers to maintain andsupport them properly in Gensim.

If your work depends on any of the modules below, feel free to copy itout of Gensim 3.8.3 (the last release where they appear), and extend &maintain the wrapper yourself.

The removed submodules are:

- gensim.models.wrappers.dtmmodel
- gensim.models.wrappers.ldamallet
- gensim.models.wrappers.ldavowpalwabbit
- gensim.models.wrappers.varembed
- gensim.models.wrappers.wordrank
- gensim.sklearn_api.atmodel
- gensim.sklearn_api.d2vmodel
- gensim.sklearn_api.ftmodel
- gensim.sklearn_api.hdp
- gensim.sklearn_api.ldamodel
- gensim.sklearn_api.ldaseqmodel
- gensim.sklearn_api.lsimodel
- gensim.sklearn_api.phrases
- gensim.sklearn_api.rpmodel
- gensim.sklearn_api.text2bow
- gensim.sklearn_api.tfidf
- gensim.sklearn_api.w2vmodel
- gensim.viz

如果您迫切需要旧的支持,您还可以考虑安装和使用旧的 Gensim。 (例如,通过 pippip install gensim==3.8.3 。)但一般来说,最新版本将得到最好的支持。

关于python - 包装器的 Gensim 模块属性错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67095698/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com