[SciPy-user] problem with kmeans

Rich Drewes drewes at interstice.com
Sat Feb 12 19:13:39 CST 2005


Hello,

I was trying to use a simple kmeans test program provided in the docstring
for vq.kmeans and I got this error:

Traceback (most recent call last):
  File "kmeanstest.py", line 54, in ?
    kmeans(whitened,codes)
  File "/usr/lib/python2.3/site-packages/scipy/cluster/vq.py", line 304, 
in kmeans
    guess = take(obs,randint(0,No,k),0)
ValueError: invalid input sequence

Thinking this looked like an error that I found in the scipy genetic
algorithm module (which I reported to this list a few weeks ago), I tried
changing line 304 from:

            guess = take(obs,randint(0,No,k),0) 
to:
            guess = take(obs,randint.rvs(0,No,k),0) 

Now it seems to work, but I am worried.  Can anyone suggest what is going
on here?  Is this a bug arising from a change in how random numbers are
handled or am I doing something dumb?  I am very new to scipy and not a
stats expert.

SciPy 0.3.2, Python 2.3.

Thank you for SciPy!

Rich



More information about the SciPy-user mailing list