Documente Academic
Documente Profesional
Documente Cultură
Hierarchial Clustering:
Consider the following dataset. States, murder rates, assault, Urban.Population and Rapes. Lets
investigate some clustering Methods available.
> plot(hc)
> hc1 <- hclust(dist(USArrests), "complete")
> plot(hc1)
> hc2 <- hclust(dist(USArrests), "single")
> plot(hc2)
Moral of the story:
Complete linkage tends to give compact clusters, single linkage can give stretched-out clusters.
Kmeans – when we don’t know how many clusters we have. Let the computer do it!!
x = USArrests
Cluster means:
Clustering vector:
4 4 5 3
4 3 2 4
5 3 1 2
2 4 1 5
3 4 1 4
3 2 2 4
1 3 4 4
5 1 2 3
3 2 3 4
1 3 3 2
1 3 3 1
Wisconsin Wyoming
1 3
Available components:
[7] "size"
>
Kmeans with 3 clusters!!
Cluster means:
Clustering vector:
2 2 2 3 2 3 1
2 2 3 1 1 2 1
1 1 1 2 1 2 3
2 1 2 3 1 1 2
New Hampshire New Jersey New Mexico New York North Carolina North Dakota Ohio
1 3 2 2 2 1 1
Oklahoma Oregon Pennsylvania Rhode Island South Carolina South Dakota Tennessee
3 3 1 3 2 1 3
3 1 1 3 3 1 1
Wyoming
Available components:
hist(w)
> library(mclust)
> summary(wclust)
----------------------------------------------------
----------------------------------------------------
Clustering table:
1 2 3
>
----------------------------------------------------
----------------------------------------------------
Clustering table:
1 2 3
Mixing probabilities:
1 2 3
Means:
1 2 3
Variances:
1 2 3
par(mfrow=c(2,2))