[SciPy-User] kmeans

Keith Goodman kwgoodman@gmail....
Sun Dec 27 11:13:45 CST 2009

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?

More information about the SciPy-User mailing list