I have a numpy array with shape (291336, 50). ie there are 291336 points where each point has 50 dimensions.
For each point in this array, I want to find the distance and index of its k
th nearest neighbor by distance, belonging to the same array. I found this related question, but it finds the 1st
nearest neighbor not the k
th.
I have thought about using this brute force approach-
for i in X.shape[0]:
distance_from_i = {}
for j in X.shape[0]:
store distance & index of j from i in distance_from_i
sort distance_from_i and select the k'th point
But I know it's terrible. There must be a better way.
How do I solve this problem?
如何按距np.zeros的距离对它们进行一次排序(50)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.