cut a dendrogramm at a specific height to generate clusters

15 visualizaciones (últimos 30 días)
Hello, I am trying to group some columns of a complex-valued matrix with the hierarchical clustering method. I created the dissimilarity matrix "dissim" and extract the distance vector from this. I am then generating the linkage matrix and feeding it to the dendrogram function, where I used the example from the mathworks help center to find the (in this example very obvious) 4 groups of entries. The dendrogram looks fine, but as soon as I am applying the cluster() function to the linkage, I am getting rubbish output:
distvec = distancevector(dissim);
tree = linkage(distvec, 'average');
cutoff = 0.5;
CL = cluster(tree, 'Cutoff', cutoff, 'Criterion', 'inconsistent');
dendrogram(tree,'ColorThreshold',cutoff);
The colored dendrogram looks like this, which shows the groups exactly as I want it:
So, the output I would be expecting from the cluster function would be something like this:CL =
CL =
2
2
3
3
1
4
2
1
4
1
4
4
2
1
3
3
i.e, 4 data entries are matched to each of the four clusters. However, CL is put out like that:
CL =
5
8
12
7
4
2
11
9
10
9
3
10
11
1
6
12
I think the dendrogram() function has a different understanding of the cutoff that the cluster() function. How can I fix it so that the clustering works as I want it to?

Respuesta aceptada

Gabriel Seidl
Gabriel Seidl el 29 de En. de 2021
Editada: Gabriel Seidl el 29 de En. de 2021
I solved it. It turned out that the cutoff used for the ColorThreshold option in the dendrogram-function is using the distance criterion cutoff definition of the cluster-function.
The issue was fixed when I replaced
CL = cluster(tree, 'Cutoff', cutoff, 'Criterion', 'inconsistent');
with
CL = cluster(tree, 'Cutoff', cutoff, 'Criterion', 'distance');

Más respuestas (0)

Productos


Versión

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by