我有二维数据,其中提到了帧数和轨迹速度。例如,这是我的数据:
array([[[ 1. , 0.83025005]],
[[ 1. , 0.83025005]],
[[ 1. , 0.83025005]],
...,
[[165. , 0.21587787]],
[[165. , 0.21587787]],
[[165. , 0.21587787]]])
在绘制这些速度特征时,我得到了以下结果。
我想使用层次化聚类制作三个聚类。 数据形状为
TrajData.shape
(213885, 2)
对于这样的集群,我导入 从scipy.cluster.hierarchy导入树状图,链接
然后,在上一个数字之后,我使用以下代码:
Z=linkage(TrajData,'ward')
Following error generated:
MemoryError Traceback (most recent call last)
<ipython-input-49-734fcd4cc1de> in <module>
----> 1 Z=linkage(TrajData,'ward')
~/miniconda3/envs/himal/lib/python3.7/site-packages/scipy/cluster/hierarchy.py in linkage(y, method, metric, optimal_ordering)
1102 'matrix looks suspiciously like an uncondensed '
1103 'distance matrix')
-> 1104 y = distance.pdist(y, metric)
1105 else:
1106 raise ValueError("`y` must be 1 or 2 dimensional.")
~/miniconda3/envs/himal/lib/python3.7/site-packages/scipy/spatial/distance.py in pdist(X, metric, *args, **kwargs)
1983 out = kwargs.pop("out", None)
1984 if out is None:
-> 1985 dm = np.empty((m * (m - 1)) // 2, dtype=np.double)
1986 else:
1987 if out.shape != (m * (m - 1) // 2,):
MemoryError:
如何进行分层聚类以找到三个聚类?