[SciPy-User] kmeans

Keith Goodman kwgoodman@gmail....
Sun Dec 27 19:09:15 CST 2009

On Sun, Dec 27, 2009 at 10:52 AM, David Warde-Farley <dwf@cs.toronto.edu> wrote:
> On 27-Dec-09, at 12:13 PM, Keith Goodman wrote:
>> Just for fun I tried kmeans on a problem that has a LOT of features. I
>> got an error:
>> UnboundLocalError: local variable 'best_book' referenced before
>> assignment
>> The exception is raised because all sets of randomly selected starting
>> centroids gave a distance greater than the initialized value of
>> best_dist (100k) and therefore best_book is never assigned. Increasing
>> the hard coded best_dist solved the problem. Is there a reason not to
>> initialize best_dist to np.inf?
> No, probably not. Good catch. Can you open a ticket?

Here's the ticket:


More information about the SciPy-User mailing list