2

2D ポイント (A と B) の 2 つのセットがあり、各セットには約 540 のポイントがあります。A のすべてのポイントから定義された距離アルファよりも遠いセット B のポイントを見つける必要があります。

解決策はありますが、十分な速度ではありません

# 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を使用しています。これを行う別の方法で、速度が大幅に向上する可能性がありますか?

答えてくれてありがとう

4

2 に答える 2

4
>>> from scipy.spatial.distance import cdist
>>> A = np.random.randn(540, 2)
>>> B = np.random.randn(540, 2)
>>> alpha = 1.
>>> ind = np.all(cdist(A, B) > alpha, axis=0)
>>> outliers = B[ind]

必要なポイントを提供します。

于 2013-10-20T09:46:48.347 に答える
0

ポイントのセットが非常に大きい場合は、加算 & 減算 aplha の x & y 境界を計算し、その境界の外側にある特定の考慮事項から b 内のすべてのポイントを削除できます。

于 2013-10-20T10:19:37.443 に答える