I am trying to run a cluster analysis on a list of coordinates. I'd like to use scipy.cluster.hierarchy.fclusterdata. How do I create an appropriate n by m data matrix from my coordinates?
我试图在一个坐标列表上运行一个集群分析。我想用scipy.cluster.y.fclusterdata。如何从我的坐标中创建一个合适的n×m的数据矩阵?
My list looks something like this:
我的列表是这样的:
list=[[1,2],[3,4],[5,6]]
1 个解决方案
#1
0
According to the documentation, fclusterdata takes an array with shape (n, m) where n is the number of observations and m is the dimension of a given data point.
根据文献,fclusterdata采用一个形状为(n, m)的数组,其中n是观测次数,m是给定数据点的维数。
If you pass your list to numpy.array
, the data is arranged in the proper shape.
如果你把你的名单传递给numpy。阵列,数据以适当的形状排列。
>>> np.array([[1, 2], [3, 4], [5, 6]]).shape
(3, 2)
#1
0
According to the documentation, fclusterdata takes an array with shape (n, m) where n is the number of observations and m is the dimension of a given data point.
根据文献,fclusterdata采用一个形状为(n, m)的数组,其中n是观测次数,m是给定数据点的维数。
If you pass your list to numpy.array
, the data is arranged in the proper shape.
如果你把你的名单传递给numpy。阵列,数据以适当的形状排列。
>>> np.array([[1, 2], [3, 4], [5, 6]]).shape
(3, 2)