Finding the cluster with a certian parameter (HCA)

10 views (last 30 days)
Hey all!
I did a hierarchical cluster analysis, with a 15 x 800 matrix. The 800 represents all my parameters I clustered and created a dendrogram of. Now I have a certain parameter I want to know with which other parameter it clusters the most. So basically I want to find the cluster, on whatever level, that contains this specific parameter.
Since its so many, it is not directly visible and I was wondering if there is a more elegant way, than just scrolling over the clustergram / zooming (which is quite some pain and sometimes even impossible).
I appreciate all your help!
Thanks a bunch.
This is the type of cluster analysis I did:
cgo1 = clustergram(matrix, 'Standardize',1 ,'Colormap',map, ...
'RowPDist','euclidean', 'ColumnPDist','euclidean' ,'Linkage','ward',...
'DisplayRange',3, 'Symmetric', 0, 'Cluster',3);

Accepted Answer

Shubh
Shubh on 26 Dec 2023
Edited: Shubh on 26 Dec 2023
Hi Anna,
I understand that you need an easier way to find a cluster having a specific parameter.
To find the cluster containing a specific parameter in your hierarchical cluster analysis in MATLAB, you can follow these steps:
  1. Perform Hierarchical Clustering: Use the "linkage" function to perform hierarchical clustering on your data.
  2. Create a Dendrogram: Use the "dendrogram" function to visualize the clustering, which will help in understanding the structure of the clusters.
  3. Identify the Cluster: Use the clustering information to find the cluster that contains your specific parameter.
Since you have a large dataset (15 x 800), the standard dendrogram might not be very informative due to the large number of parameters. However, the clustering information can still be used to find the cluster for your parameter.
Here's how you can do it:
  1. Perform hierarchical clustering using the "linkage" function.
  2. Determine the cluster indices for each parameter at a chosen level of clustering using the "cluster" function.
  3. Find the cluster index of your specific parameter.
  4. Identify other parameters that belong to the same cluster.
I'll provide you with the complete MATLAB code to perform these steps. Assume that your matrix is named "matrix" and the parameter of interest is at column index "parameter_index".
% Your matrix (15x800)
% matrix = ...; % Your data matrix
parameter_index = ...; % Index of your parameter of interest
% Perform hierarchical clustering
Y = pdist(matrix, 'euclidean'); % Pairwise distances
Z = linkage(Y, 'ward'); % Hierarchical clustering
% Optional: Create a dendrogram
figure;
[H, T, outperm] = dendrogram(Z, 0); % Display the full dendrogram
% Determine the cluster indices (choose a suitable number of clusters)
numClusters = 10; % Adjust this as needed
T = cluster(Z, 'maxclust', numClusters);
% Find the cluster for your specific parameter
parameter_cluster = T(parameter_index);
% Find other parameters in the same cluster
parameters_in_cluster = find(T == parameter_cluster);
% Display parameters in the same cluster
disp('Parameters in the same cluster:');
disp(parameters_in_cluster);
Replace "parameter_index" with the index of your specific parameter. Adjust "numClusters" to a suitable value depending on your dataset and the granularity of clustering you need.
This code will display the indices of parameters that are in the same cluster as your parameter of interest. Below are the links to the cluster, dendogram and linkage funtions :
https://www.mathworks.com/help/stats/linkage.html
  1 Comment
Anna Breuninger
Anna Breuninger on 28 Dec 2023
Edited: Anna Breuninger on 28 Dec 2023
Hey Shubh,
thanks a lot for your detailed answer and the provided code!
That definitely helped :)

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!