我想生成一个Topic to Topic Matrix,以便找到类似的主题,以便使用gensim LDA中的函数gensim.models.ldamodel.diff
生成内部集群。
如何将生成的数据保存到csv中,主题包括主题和单元格中的距离(在本例中为hellinger distance)?
这段代码对我不起作用:
from gensim import models
import pandas
dateiname_model1 = "lda.model"
model1 = models.LdaModel.load(dateiname_model1)
topic_over_topic = model1.diff(model1, annotation=True)
topic_over_topic_speicherpfad = "topic_over_topic_similarity.csv"
pandas.DataFrame(topic_over_topic).to_csv(topic_over_topic_speicherpfad, sep=';')
答案 0 :(得分:0)
它适用于代码topic_over_topic, annotation = model1.diff(model1, annotation=True)
:
from gensim import models
import pandas
dateiname_model1 = "lda.model"
model1 = models.LdaModel.load(dateiname_model1)
topic_over_topic, annotation = model1.diff(model1, annotation=True)
topic_over_topic_speicherpfad = "topic_over_topic_similarity.csv"
pandas.DataFrame(topic_over_topic).to_csv(topic_over_topic_speicherpfad, sep=';')