Hello everybody,
Yesterday I was completed the assignment for the k-means algorithm, but after seeing that it tooked so long to complete (section 4.2, it even says in the code this takes a couple of minutes
), I tried to implement a vectorized way of computing the closest centroids in exercise 1 and succeeded. It now takes milliseconds.
Nevertheless, there’s one step in the next function that I can’t figure out how to avoid: in the compute_centroids()
function:
Is there a way to avoid having to do for i in range(K):
?
All the ideas that come up to my mind include a numpy array formed from arrays of differents dimensions, which is something that numpy doesn’t support.
I have the code and the approaches that I’ve tried, but I don’t post them here because it’d be against the rules.
Thank you in advance, best regards,
Manuel