2016-05-12 15 views
-1

私はオブジェクト間の距離を説明2次元配列を有する:例えば、距離(A、B)= 1、距離(B、C)のため未知の距離メトリックを有する一次元データをclastering

A B C 
A 0 1 2 
B 1 0 3 
C 2 3 0 

を= 3、距離(A、C)= 2、 距離(x、y)=距離(x、y)。私はこの距離について何も知らない、それはユークリッド距離ではなく、一般に知られている距離関数でもない。

グループとパーティションポイント(x、y)の数を見つける方法は?

+1

可能性は私の質問のにとって必須ではhttp://stats.stackexchange.com/questions/2717/clustering-with-a-distance-matrix – gdlmx

+0

と重複は距離ということですユークリデスではないですが、私は遠く離れていると思っています。 Googleで見つけたK平均アルゴリズムとmoustは、ポイント間のユークリッド距離が必要です。 –

答えて

1

私が見つけた解決策:

D =[x][y] #two dimencion array with distances between x and y 
sorted_distance = sorted_distance(D) # all values apears in D, delete duplicates and sort from max to min value 

for distance in sorted_distance: 
    V = D.keys() 
    E = [] 
    for x in V: 
     for y in V: 
      if x==y: continue 
      if D[x][y]<=distance: 
       E.append((x,y)) 
    G = Grapth(V,E) 
    connected_components = get_connected_components(G) 
    if len(connected_components)>1: # this value could be increase if result is not rewarding 
     return connected_components 
関連する問題