Finding the indices of the top three values via argmin() or min() in python/numpy without mutation of list?
Numpy includes an argsort
function which will return all the indices. If I understand your requirement correctly, you should be able to do:
minidx = []
for cluster in sumErrors:
minidx.append(np.argsort(cluster)[:3])
numpy.argpartition(cluster, 3)
would be much more effective.