Unsupervised Learning in R
Hank Roark
Senior Data Scientist at Boeing
# Fitting various hierarchical clustering models
hclust.complete <- hclust(d, method = "complete")
hclust.average <- hclust(d, method = "average")
hclust.single <- hclust(d, method = "single")
# Scale the data
pokemon.scaled <- scale(pokemon)
# Create hierarchical and k-means clustering models
hclust.pokemon <- hclust(dist(pokemon.scaled), method = "complete")
km.pokemon <- kmeans(pokemon.scaled, centers = 3,
nstart = 20, iter.max = 50)
# Compare results of the models
cut.pokemon <- cutree(hclust.pokemon, k = 3)
table(km.pokemon$cluster, cut.pokemon)
cut.pokemon
1 2 3
1 242 1 0
2 342 1 0
3 204 9 1
Unsupervised Learning in R