我想运行一个LDA模型来提取主题。为此,我想先创建二元组,然后创建TF-IDF模型作为模型的输入。
到目前为止,我已经成功地使用bigrams和TF-IDF运行了LDA模型。但是,我没有将它与bigram模型一起用作TF-IDF模型的输入。
我尝试了以下操作:
bigram = gensim.models.Phrases(data_words_nostops, min_count=5, threshold=0.5, scoring = 'npmi')
bigram_mod = gensim.models.phrases.Phraser(bigram)
tfidf = models.TfidfModel(bigram_mod)
前两行效果很好。但是,当我运行最后一行时,出现以下错误消息:
TypeError: 'int' object is not iterable
我在下面找到了链接,但看不到如何将他们的答案纳入我的问题中。
Python - TypeError: 'int' object is not iterable
我该怎么做才能运行一个既包含双字母组又包含TF-IDF的模型?