開始使用免費開始

視覺化主題

運用前面章節學到的技巧,來把 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()
編輯並執行程式碼