Simple word clustering

Text Mining with Bag-of-Words in R

Ted Kwartler

Instructor

Hierarchical clustering example

dist_rain <- dist(rain[, 2])

hierarch_clust.png

Text Mining with Bag-of-Words in R

A simple dendrogram

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

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

clust_dendro.png

Text Mining with Bag-of-Words in R

Dendrogram aesthetics

# 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")

dendro_aes.png

Text Mining with Bag-of-Words in R

Let's practice!

Text Mining with Bag-of-Words in R

Preparing Video For Download...