我一直在尝试对 MOOC 中的一组讨论论坛帖子进行主题建模。我尝试过基本的 LDA 来创建主题,但主题毫无意义。所以现在我正在考虑播种我的主题以创建更好的主题。我找到了 seededlda 包,它需要一个 dfm 作为输入以及一个种子术语字典。它运作良好!我的问题是弄清楚每个文档或论坛帖子是如何分类的。
我的原始数据将“userid”作为变量,将“post”作为我用于 LDA 的文档。到目前为止,我的代码看起来像这样。
text <- introduction_posts$post
dfmt <- dfm(text, remove_number = TRUE) %>%
dfm_remove(stopwords('en'), min_nchar = 2)
#install.packages("seededlda")
library(seededlda)
slda <- textmodel_seededlda(dfmt,
seeded_dict,
valuetype = c("glob", "regex", "fixed"),
case_insensitive = FALSE,
residual = TRUE,
weight = 0.01,
max_iter = 2000,
alpha = NULL,
beta = NULL,
verbose = quanteda_options("verbose")
)
terms <- terms(slda)
如何确定哪些条款适用于哪个用户?
当我使用 topicmodeling 包下的 LDA 函数时,我使用了以这种方式定义的文档术语矩阵
posts_dtm <- CreateDtm(doc_vec = introduction_posts$post, # character vector of documents
doc_names = introduction_posts$userid_bycourse, # document names
ngram_window = c(1, 2), # minimum and maximum n-gram length
stopword_vec = c(stopwords::stopwords("en"), # stopwords from tm
stopwords::stopwords(source = "smart"))
它在文件进行时命名了这些文件。最后,我能够很好地看到哪些主题去了哪些参与者。但我似乎无法用 seededlda 包使用的 dfm 做到这一点。
任何帮助,将不胜感激。