[SciPy-User] kmeans

David Warde-Farley dwf@cs.toronto....
Sun Dec 27 12:52:02 CST 2009

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?


More information about the SciPy-User mailing list