Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

cluster

Construct agglomerative clusters from linkages

Syntax

T = cluster(Z,'cutoff',c)
T = cluster(Z,'cutoff',c,'depth',d)
T = cluster(Z,'cutoff',c,'criterion',criterion)
T = cluster(Z,'maxclust',n)

Description

T = cluster(Z,'cutoff',c) constructs clusters from the agglomerative hierarchical cluster tree, Z, as generated by the linkage function. Z is a matrix of size (m – 1)-by-3, where m is the number of observations in the original data. c is a threshold for cutting Z into clusters. Clusters are formed when a node and all of its subnodes have inconsistent value less than c. All leaves at or below the node are grouped into a cluster. t is a vector of size m containing the cluster assignments of each observation.

If c is a vector, T is a matrix of cluster assignments with one column per cutoff value.

T = cluster(Z,'cutoff',c,'depth',d) evaluates inconsistent values by looking to a depth d below each node. The default depth is 2.

T = cluster(Z,'cutoff',c,'criterion',criterion) uses the specified criterion for forming clusters, where criterion is 'inconsistent' (default) or 'distance'. The 'distance' criterion uses the distance between the two subnodes merged at a node to measure node height. All leaves at or below a node with height less than c are grouped into a cluster.

T = cluster(Z,'maxclust',n) constructs a maximum of n clusters using the 'distance' criterion. cluster finds the smallest height at which a horizontal cut through the tree leaves n or fewer clusters.

If n is a vector, T is a matrix of cluster assignments with one column per maximum value.

Examples

Compare clusters from Fisher iris data with species:

load fisheriris
d = pdist(meas);
Z = linkage(d);
c = cluster(Z,'maxclust',3:5);

crosstab(c(:,1),species)
ans =
     0     0     2
     0    50    48
    50     0     0

crosstab(c(:,2),species)
ans =
     0     0     1
     0    50    47
     0     0     2
    50     0     0

crosstab(c(:,3),species)
ans =
     0     4     0
     0    46    47
     0     0     1
     0     0     2
    50     0     0

Introduced before R2006a

Was this topic helpful?