Unsupervised Learning in R
Hank Roark
Senior Data Scientist at Boeing
# Create hierarchical cluster model: hclust.out hclust.out <- hclust(dist(x))
# Inspect the result summary(hclust.out)
Length Class Mode
merge 98 -none- numeric
height 49 -none- numeric
order 50 -none- numeric
labels 0 -none- NULL
method 1 -none- character
call 2 -none- call
dist.method 1 -none- character
# Draws a dendrogram plot(hclust.out)
abline(h = 6, col = "red")
# Cut by height h
cutree(hclust.out, h = 6)
1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3
3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 2 4 2 4 4
# Cut by number of clusters k
cutree(hclust.out, k = 2)
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2
2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1
Unsupervised Learning in R