比較 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
___ %>%
___(___)