r - 主题建模 : How do I use my fitted LDA model to predict new topics for a new dataset in R?

标签 r lda topic-modeling

我在 R 中使用“lda”包进行主题建模。我想使用适合新数据集的潜在狄利克雷分配(LDA)模型来预测新主题(文档中相关词的集合)。在这个过程中,我遇到了predictive.distribution() 函数。但是该函数将 document_sums 作为输入参数,它是拟合新模型后结果的输出。我需要帮助来了解在新数据集上使用现有模型并预测主题。
以下是 Johnathan Chang 为包编写的文档中的示例代码:
这是它的代码:

#Fit a model
data(cora.documents)
data(cora.vocab)

K <- 10 ## Num clusters

result <- lda.collapsed.gibbs.sampler(cora.documents,K, cora.vocab,25, 0.1, 0.1) 

# Predict new words for the first two documents
predictions <-  predictive.distribution(result$document_sums[,1:2], result$topics, 0.1, 0.1)

# Use top.topic.words to show the top 5 predictions in each document.
top.topic.words(t(predictions), 5)

任何帮助将不胜感激

感谢和问候,

安 git

最佳答案

我不知道如何在 R 中实现这一点,但请查看 Wallach 等人 2009 年的出版物。阿尔。题为“主题模型的评估方法”here .看看第 4 节,它提到了三种计算 P(z|w) 的方法,一种基于重要性采样,另外两种称为“Chib-style estimator”和“left-to-right estimator”。

Mallet 实现了从左到右的估计器方法

关于r - 主题建模 : How do I use my fitted LDA model to predict new topics for a new dataset in R?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10483349/

相关文章:

r - knitr:带有output.lines=选项的输出钩子(Hook),其工作方式类似于echo=2:6

r - 与ggplot2不同数量的离群值

r - 如何知道 r 在幕后做什么

r - 如何使用 R 的 topicmodels 包中的 LDA 函数重现精确结果

python-2.7 - 实现文本文件的主题建模后,我得到了相似的词来描述所有主题,结果不准确。

从字符串中删除两个字符

python - 使用 Python 可视化 LDA 模型

mahout - 在 mahout 0.8 中运行 cvb

python - 如何在python中保存LDA模型 - LatentDirichletAllocation

java - Mallet 输出主题权重 0.0 或 1.0,不输出任何中间值