在matlab中将层次集群的根与他们的孩子联系起来
linking root of hierarchical clusters with their childs in matlab
我正在使用层次聚类算法将我的数据集聚类成不同数量的聚类。例如,
a= [1;2;3;4;5;20;21;22;28;29]
Z=linkage(a,'ward')
[clusterIndexes]=cluster(Z,'maxclust',2)
此片段将数据聚类为两个,第一个聚类包含 1、2、3、4、5。让我们将此集群称为 A,第二个包含 20,21,22,28,29,即集群 B。
当我运行下面的脚本和集群数据变成3
a= [1;2;3;4;5;20;21;22;28;29]
Z=linkage(a,'ward')
[clusterIndexes]=cluster(Z,'maxclust',3)
它给了我 (1 2 3 4 5)= 簇 X,(20,21,22) = 簇 Y,(28,29) = 簇 Z。
如何以编程方式演示集群 B 拆分为集群 Y 和集群 Z?
抱歉这个天真的问题,我是 matlab 的新手。
您可以使用 setxor
来识别两个集群之间的任何差异。与 clusterB
比较时,用户 union
合并 clusterY
和 clusterZ
。由于结果为空,因此两个簇包含相同的数字集。如果两者之间有任何差异,它将由 setxor
.
输出
clusterB = [20 21 22 28 29];
clusterY = [20 21 22];
clusterZ = [28 29];
setxor(clusterB, union(clusterY, clusterZ))
ans =
1×0 empty double row vector
假设clusterB
有一个额外的号码,你可以看到下面的结果。
clusterB = [5 20 21 22 28 29];
setxor(clusterB, union(clusterY, [clusterZ]))
ans =
5
我正在使用层次聚类算法将我的数据集聚类成不同数量的聚类。例如,
a= [1;2;3;4;5;20;21;22;28;29]
Z=linkage(a,'ward')
[clusterIndexes]=cluster(Z,'maxclust',2)
此片段将数据聚类为两个,第一个聚类包含 1、2、3、4、5。让我们将此集群称为 A,第二个包含 20,21,22,28,29,即集群 B。
当我运行下面的脚本和集群数据变成3
a= [1;2;3;4;5;20;21;22;28;29]
Z=linkage(a,'ward')
[clusterIndexes]=cluster(Z,'maxclust',3)
它给了我 (1 2 3 4 5)= 簇 X,(20,21,22) = 簇 Y,(28,29) = 簇 Z。
如何以编程方式演示集群 B 拆分为集群 Y 和集群 Z?
抱歉这个天真的问题,我是 matlab 的新手。
您可以使用 setxor
来识别两个集群之间的任何差异。与 clusterB
比较时,用户 union
合并 clusterY
和 clusterZ
。由于结果为空,因此两个簇包含相同的数字集。如果两者之间有任何差异,它将由 setxor
.
clusterB = [20 21 22 28 29];
clusterY = [20 21 22];
clusterZ = [28 29];
setxor(clusterB, union(clusterY, clusterZ))
ans =
1×0 empty double row vector
假设clusterB
有一个额外的号码,你可以看到下面的结果。
clusterB = [5 20 21 22 28 29];
setxor(clusterB, union(clusterY, [clusterZ]))
ans =
5