PRTools contents |
HCLUST
[LABELS, DENDROGRAM] = HCLUST(D,TYPE,K)
DENDROGRAM = HCLUST(D,TYPE)
Input | |
D | dissimilarity matrix |
TYPE | string name of clustering criterion (optional) - 's' or 'single' : single linkage (default) - 'c' or 'complete' : complete linkage - 'a' or 'average' : average linkage (weighted over cluster sizes) |
K | number of clusters (optional) |
Output | |
LABELS | vector with labels |
DENDROGRAM | matrix with dendrogram |
Computation of cluster labels and a dendrogram between the clusters for objects with a given distance matrix D. K is the desired number of clusters. The dendrogram is a 2*K matrix. The first row yields all cluster sizes. The second row is the cluster level on which the set of clusters starting at that position is merged with the set of clusters just above it in the dendrogram. A dendrogram may be plotted by PLOTDG.
DENDROGRAM = HCLUST(D,TYPE)
As in this case no clustering level is supplied, just the entire dendrogram is returned. The first row now contains the object indices.
a = gendats([25 25],20,5); % 50 points in 20 dimensional feature space
d = sqrt(distm(a)); % Euclidean distances
dendg = hclust(d,'complete'); % dendrogram
plotdg(dendg)
lab = hclust(d,'complete',2); % labels
confmat(lab,getlabels(a)); % confusion matrix
plotdg, kmeans, kcentres, modeseek, emclust,
PRTools contents |