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
| 归档时间: |
|
| 查看次数: |
4727 次 |
| 最近记录: |