k-means

Simple k-means cluster analysis and plot

No votes yet

We know that the iris data set include three species. K-means does a pretty good job of correctly identifying correct groups.

data(iris)
cl <- kmeans(iris[,1:4], 3)
cl$cluster
cbind(1:150,iris$Species)

cl$cluster reveals which group each observation was placed in; compare this with a listing of the species designations mapped next to 150 index values (cbind(1:150,iris$Species)).

Read more

Syndicate content