kmeans2 question/issue
2012-08-05 23:09:06 GMT
Hi,
I'm trying to use scipy.cluster.vq.kmeans2() but I'm getting inconsistent
output. With a simple test input that should have 3 clusters, I'm getting
good results most of the time but every so often the output creates the
wrong clustering. If anyone could point to what I'm doing wrong I'd
appreciate it!
Code and sample output below.
Thanks!
James
Code:
import sys
import scipy
from scipy.cluster.vq import *
print sys.version
vals = scipy.array((0.0,0.1,0.5,0.6,1.0,1.1))
print vals
white_vals = whiten(vals)
print white_vals.shape, white_vals
# try it several times to see if we get similar answers
count = 0
while count < 5:
res, idx = kmeans2(white_vals, 3) # changing iter doesn't seem to matter
print res, idx
count += 1
Output:
(Continue reading)
RSS Feed