Cutting the tree

Cluster Analysis in R

Dmitriy Gorenshteyn

Lead Data Scientist, Memorial Sloan Kettering Cancer Center

Cluster Analysis in R

Cluster Analysis in R

Cluster Analysis in R

Coloring the dendrogram - height

library(dendextend)

dend_players <- as.dendrogram(hc_players)
dend_colored <- color_branches(dend_players, h = 15)
plot(dend_colored)

Cluster Analysis in R

Coloring the dendrogram - height

library(dendextend)

dend_players <- as.dendrogram(hc_players)
dend_colored <- color_branches(dend_players, h = 15)
plot(dend_colored)

Cluster Analysis in R

Coloring the dendrogram - height

library(dendextend)

dend_players <- as.dendrogram(hc_players)
dend_colored <- color_branches(dend_players, h = 10)
plot(dend_colored)

Cluster Analysis in R

Coloring the dendrogram - K

library(dendextend)

dend_players <- as.dendrogram(hc_players)
dend_colored <- color_branches(dend_players, k = 2)
plot(dend_colored)

Cluster Analysis in R

cutree() using height

cluster_assignments <- cutree(hc_players, h = 15)

print(cluster_assignments) [1] 1 1 1 1 2 2
library(dplyr) players_clustered <- mutate(players, cluster = cluster_assignments) print(players_clustered) x y cluster <dbl> <dbl> <int> 1 -1 1 1 2 -2 -3 1 3 8 6 1 4 7 -8 1 5 -12 8 2 6 -15 0 2
Cluster Analysis in R

Let's practice!

Cluster Analysis in R

Preparing Video For Download...