[SciPy-user] problem with kmeans

eric jones eric at enthought.com
Mon Feb 14 01:03:41 CST 2005

That is a change to the random number package that didn't propagate 
through to the examples.  What you did is the correct fix.  Please 
submit a patch to the tracker.


Rich Drewes wrote:

>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) 
>            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!
>SciPy-user mailing list
>SciPy-user at scipy.net

More information about the SciPy-user mailing list