Use Distance Matrix in scipy.cluster.hierarchy.linkage()?

后端 未结 2 1882
你的背包
你的背包 2020-11-29 03:19

I have a distance matrix n*n M where M_ij is the distance between object_i and object_j. So as expected, it takes the fol

2条回答
  •  旧巷少年郎
    2020-11-29 03:55

    For now you should pass in the 'condensed distance matrix', i.e. just the upper triangle of the distance matrix in vector form:

    y = M[np.triu_indices(n,1)]
    

    From the discussion of @hongbo-zhu-cn's pull request it looks as though the solution will be to add an extra keyword argument to the linkage function that will allow the user to explicitly specify that they are passing in an n x n distance matrix rather than an m x n observation matrix.

提交回复
热议问题