Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
K = 3
# ソートはされていない上位k件のインデックス
unsorted_max_indices = np.argpartition(-my_array, K)[:K]
# 上位k件の値
y = my_array[unsorted_max_indices]
# 大きい順にソートし、インデックスを取得
indices = np.argsort(-y)
# 類似度上位k件のインデックス
max_k_indices = unsorted_max_indices[indices]

This comment has been minimized.

Copy link
Owner Author

naoyashiga commented Apr 28, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.