主题建模:如何使用我的拟合LDA模型来预测R中新数据集的新主题?

ank*_*thi 5 r lda topic-modeling

我在R中使用'lda'包进行主题建模.我想使用针对新数据集的拟合Latent Dirichlet分配(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)
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激

感谢和问候,

ANKIT

abh*_*rni 2

我不知道如何在 R 中实现这一目标,但请查看 Wallach 等人 2009 年发表的文章。等人。此处标题为“主题模型的评估方法” 。看一下第 4 节,它提到了三种计算 P(z|w) 的方法,一种基于重要性采样,另外两种称为“Chib 式估计器”和“从左到右估计器”。

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