Open d5423197 opened 4 years ago
argsort will work fine. argpartition just performs better. In case of you have 1million feature and if we want to identify first 500 important feature, using argpartition we dont need to sort the entire array. Algortithm will stop sorting, once it identified the last 500 (in case of negative indexing).
Hope it helps.
Hello there,
I could not understand this piece of code.
def indices_of_top_k(arr, k): return np.sort(np.argpartition(np.array(arr), -k)[-k:])
Can't we just use argsort() instead?
Thanks for your help.