Extract clusters info from dendrogram as a matrix
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
Wondering if somebody could guide me here...
I do have data from instruments at different locations (Latitude and Longitude) and depths, and I need to cluster these based on their proximity, and I can do that fine, but I also need to extract the info from the clusters for another analysis.
This is a very short example of my data:
ID Depth Lat Lon
A1 0.33 -14.28 -170.56
A2 2 -14.24 -169.42
A3 15 -14.33 -170.83
A4 14.95 -11.06 -171.09
A5 17 -14.28 -170.72
A6 14.8 -0.38 -160.02
A7 1.5 5.87 -162.05
A8 0.33 -0.38 -160.02
A9 12.8 -0.38 -160.02
A10 2.8 -0.38 -160.02
A11 7 -0.38 -160.02
A12 9.8 -0.38 -160.02
A13 10 -0.38 -160.02
This is the result of using the function dendrogram, with a line at 150 (x-axis), which represent the cluster max cut that I want to apply based on the data I have. </matlabcentral/answers/uploaded_files/100362/test.jpg>
What I need is to extract the clusters in a way similar to this:
Cluster ID Depth Lat Lon
1 A7 1.5 5.87 -162.05
2 A8 0.33 -0.38 -160.02
2 A11 7 -0.38 -160.02
3 A12 9.8 -0.38 -160.02
3 A13 10 -0.38 -160.02
3 A9 12.8 -0.38 -160.02
3 A6 14.8 -0.38 -160.02
4 A4 14.95 -11.06 -171.09
5 A3 15 -14.33 -170.83
6 A5 17 -14.28 -170.72
7 A1 0.33 -14.28 -170.56
8 A2 2 -14.24 -169.42
Thank you for your suggestions and/or directions to an existent answer, if that is the case.
0 Commenti
Risposta accettata
Kris Fedorenko
il 8 Gen 2018
Hello Robert,
I am unable to see the image, but sounds like you might find functions like cluster or clusterdata useful.
Are you creating a dendrogram from a binary tree, specified as an (M – 1)-by-3 matrix (e.g. generated with the linkage function)? Then you can just pass on the same matrix to the "cluster" function.
2 Commenti
Kris Fedorenko
il 12 Gen 2018
To expand on that short answer, linkage produces a binary tree of hierarchical clusters. To extract cluster labels from that, you need to choose which level of the tree you want to be looking at. That's why "cluster" and "clusterdata" require you to provide a "cutoff" value. This "cutoff" value can be expressed either in terms of distance (same distance metric as used by "linkage") or in terms of the inconsistency coefficient.
To deal with distances in terms of latitude and longitude you might consider taking a look at the distance function from the Mapping Toolbox. Depending on you application, you might want to specify a custom distance metric to supply for the "linkage" function.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!