I have a problem using kmeans in a ubuntu system. I seem to be getting different results! My data is say:
x<- c(0.1295..,-0.58928,-0.244252,-0.41614,-0.58804,-0.74628,-0.9045188,-1.050903,-1.197288,-1.3353877,-1.47348656,-1.607894)
when I perform kmeans function and want to get only the max value of kmeans$centers in a windows system,
means <- max(kmeans(x, 3)$centers)
means
[1] -0.05892
When I run the exact code in ubuntu 12.04 system, I get a completely different answer
means <- max(kmeans(x,3)$centers)
means
[1] -0.1482334
So, I performed the kmeans again without the max function
means <- kmeans(x, 3)
means$centers
NULL
But, means itself has all the entries
means
Available components:
[1] "cluster" "centers" "tots" "withinss" "tot.withinss"
[6] "betweenss" "size" "iter" "ifault"
There seems to be something changing between the functionality in windows and linux. Can anyone help me figuring this out?!
A k-means algorithm generally is not deterministic, i.e., it usually does not lead to perfectly reproducible results. The main reason is that in common algorithms the initialization is random.
As discussed in ?kmeans
trying several random starts (nstart> 1) is often recommended