我正在使用R中的“lda”软件包进行主题建模。我想使用已拟合的潜在狄利克雷分配(LDA)模型为新数据集预测新主题(文档中相关单词的集合)。在此过程中,我遇到了predictive.distribution()函数。但是该函数需要将document_sums作为输入参数,而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)
任何帮助将不胜感激
谢谢和问候,
Ankit