【发布时间】:2021-05-06 03:26:55
【问题描述】:
我目前正在尝试为我必须写的论文开发代码。我想进行基于 LDA 的主题建模。我在 GitHub 上找到了一些代码存款,并且能够将它们组合起来并在必要时对其进行微调。 现在我想添加一些东西,在分配给相应主题的最高 beta 值的单词之后命名每个识别的主题。 有任何想法吗?这是我第一次编写任何代码,因此我的专业知识非常有限。
这是我要插入“命名部分”的代码部分:
# get the top ten terms for each topic
top_terms <- topics %>%
group_by(topic) %>% # treat each topic as a different group
top_n(10, beta) %>% # get top 10 words
ungroup() %>%
arrange(topic, -beta) # arrange words in descending informativeness
# plot the top ten terms for each topic in order
top_terms %>%
mutate(term = reorder(term, beta)) %>% # sort terms by beta value
ggplot(aes(term, beta, fill = factor(topic))) + # plot beta by theme
geom_col(show.legend = FALSE) + # as bar plot
facet_wrap(~ topic, scales = "free") + # separate plot for each topic
labs(x = NULL, y = "Beta") + # no x label, change y label
coord_flip() # turn bars sideways
我尝试将它插入到这部分代码中,但没有成功。 我找到了这个:R topic modeling: lda model labeling function,但这对我不起作用,或者我没有得到它。
我不能透露更多的代码,因为里面有一些有意义的数据,但仍然非常感谢社区的一些专业知识。
最好的问候并保持安全
注意:它说top_terms 是一个小标题。我试图想出一些我头顶的数据。
top_terms 中的数据结构就是这样
主题词测试版
(int) (chr) (dbl)
1 book 0,9876
1 page 0,9765
1 chapter 0,9654
2 sports 0,8765
2 soccer 0,8654
2 champions 0,8543
3 music 0,9543
3 song 0,8678
3 artist 0,7231
4 movie 0,9846
4 cinema 0,9647
4 cast 0,8878
【问题讨论】:
-
如果您有敏感数据,是否可以生成与
top_terms数据具有相同结构(列名和类型)的虚拟数据集? -
请告诉我,这是否可以作为
top_terms的虚拟数据集。我不确定