簡單詞彙分群

R 的 Bag-of-Words 文本探勘

Ted Kwartler

Instructor

階層式分群範例

dist_rain <- dist(rain[, 2])

階層式分群示意圖

R 的 Bag-of-Words 文本探勘

簡單樹狀圖

# Convert to hierarchical cluster obj
hc <- hclust(dist_rain)

# Plot dendrogram with city labels plot(hc, labels = rain$city)

樹狀圖

R 的 Bag-of-Words 文本探勘

樹狀圖美化

# Load dendextend package
library(dendextend)

# Convert distance matrix to dendrogram hc <- hclust(tweets_dist) hcd <- as.dendrogram(hc)
# Color branches
hcd <- branches_attr_by_labels(hcd, 
           c("marvin", "gaye"), "red")

# Plot dendrogram with some aesthetics plot(hcd, main = "Better Dendrogram") rect.dendrogram(hcd, k = 2, border = "grey50")

樹狀圖美化

R 的 Bag-of-Words 文本探勘

一起來練習吧!

R 的 Bag-of-Words 文本探勘

Preparing Video For Download...