我有 2 组 2D 点(A 和 B),每组大约有 540 个点。我需要找到集合 B 中距 A 中所有点的定义距离 alpha 远的点。
我有一个解决方案,但速度不够快
# find the closest point of each of the new point to the target set
def find_closest_point( self, A, B):
outliers = []
for i in range(len(B)):
# find all the euclidean distances
temp = distance.cdist([B[i]],A)
minimum = numpy.min(temp)
# if point is too far away from the rest is consider outlier
if minimum > self.alpha :
outliers.append([i, B[i]])
else:
continue
return outliers
我正在使用带有 numpy 和 scipy 的 python 2.7。还有另一种方法可以使我的速度大大提高吗?
提前感谢您的答案