階層式分群複習

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")
R 的無監督式學習

連結法:complete 與 average

完全連結與平均連結法的樹狀圖

R 的無監督式學習

階層式分群

R 的無監督式學習

反覆調整

反覆以取得更多群集

R 的無監督式學習

樹狀圖

5 個群集與完成的樹狀圖

R 的無監督式學習

k-means 與階層式分群的差異

k-means 與樹狀圖對照

R 的無監督式學習

實務注意事項

# 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
R 的無監督式學習

一起來練習吧!

R 的無監督式學習

Preparing Video For Download...