开始使用免费开始使用

可视化主题

结合前面章节的内容,来可视化 LDA 生成的主题。

本练习是课程的一部分

R 文本分析入门

查看课程

练习说明

  • 保留每个主题下概率最高的 10 个词。
  • 创建 term2,即按词的概率对 term 进行排序得到的因子。
  • 绘制 term2 与对应的词概率。
  • 使用分面将条形图按主题展示(即使用 ~ 语法)。

交互式实操练习

通过完成这段示例代码来试试这个练习。

word_probs <- lda_topics %>%
  # Keep the top 10 highest word probabilities by topic
  ___(___) %>% 
  ___(___) %>% 
  ___() %>%
  # Create term2, a factor ordered by word probability
  ___(term2 = ___(___))

# Plot term2 and the word probabilities
___(___) +
  geom_col() +
  # Facet the bar plot by topic
  ___(___, scales = "free") +
  coord_flip()
编辑并运行代码