I am new in datamining. I decided to play with k-means clustering in r with simple аrtificial data.
set.seed(101) x1 <- runif(100,36.6,37.5) x2 <- runif(100,37.6,38.4) x3 <- runif(100,38.5,40) x<-c(50,150,250) y<-c(37,38,39.25) centers<-c(37.05,38,39.25) all <- c(x1,x2,x3) c1<-kmeans(all,centers=centers,iter.max = 1000,nstart=1,algorithm="Lloyd") plot(all,col = c1$cluster) points(x,y,col="red",pch=19)
I generated three random data sets
x1,x2,x3. Then i taked center of each cluster like mean of each set and used k-means algorith of r. In result i get what you see in picture.
What i am making wrong?
Why second cluster contains the part of third set? How to improve result?
Why result is so bad instead sets is lineary separate?