Output 50 samples closest to each cluster center using scikit-learn.k-means library
One correction to the @snarly's answer.
after performing d = km.transform(X)[:, j],
d has elements of distances to centroid(j), not similarities.
so in order to give closest top 50 indices, you should remove '-1', i.e.,
 ind = np.argsort(d)[::][:50] 
(normally, d has sorted score of distance in ascending order.)
Also, perhaps the shorter way of doing 
ind = np.argsort(d)[::-1][:50] 
could be
ind = np.argsort(d)[:-51:-1].
I have fitted a k-means algorithm on 5000+ samples using the python scikit-learn library. I want to have the 50 samples closest to a cluster center as an output. How do I perform this task?