cut a dendrogramm at a specific height to generate clusters

20 vues (au cours des 30 derniers jours)
Gabriel Seidl
Gabriel Seidl le 28 Jan 2021
Modifié(e) : Gabriel Seidl le 29 Jan 2021
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?

Réponse acceptée

Gabriel Seidl
Gabriel Seidl le 29 Jan 2021
Modifié(e) : Gabriel Seidl le 29 Jan 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');

Plus de réponses (0)

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by