比较 LDA 输出
目前我们只用特定的主题数跑过一次 LDA。该模型整理后的输出 lda_out_tidy 与 dtm_twitter 都已加载到您的工作区。现在请以 3 个主题运行 LDA,并比较两者的输出。
> lda_out_tidy
# A tibble: 35,928 x 3
topic term beta
<int> <chr> <dbl>
1 1 flight 0.0343
2 1 time 0.0102
3 2 service 0.00882
4 1 plane 0.00688
5 1 trip 0.00614
6 2 customer 0.00604
7 1 delayed 0.00596
8 2 airline 0.00593
9 1 hours 0.00532
10 1 day 0.00499
# ... with 35,918 more rows
本练习是课程的一部分
R 文本分析入门
练习说明
- 使用 3 个主题并采用 Gibbs 采样器运行一次 LDA(可能需要 10 秒或更长时间)。
- 将词概率矩阵整理为整洁格式。
- 按词概率降序排列主题。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Run an LDA with 3 topics and a Gibbs sampler
lda_out2 <- ___(
___,
___,
___,
control = list(seed = 42)
)
# Tidy the matrix of word probabilities
lda_topics2 <- ___ %>%
___(___)
# Arrange the topics by word probabilities in descending order
___ %>%
___(___)