Statistics Toolbox | ![]() ![]() |
Construct clusters from linkage
output
Syntax
T = cluster(Z,'cutoff',c)
T = cluster(Z,'maxclust',n)
T = cluster(...,'criterion','crit
')
T = cluster(...,'depth',d)
Description
T = cluster(Z,'cutoff',c)
constructs clusters from the hierarchical cluster tree, Z
, 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 inconsistent values are less than c
. See the inconsistent
function for more information. The output T
is a vector of size m that contains the cluster number for each observation in the original data.
T = cluster(Z,'maxclust',n)
specifies n
as the maximum number of clusters to form from the hierarchical tree in Z
.
T = cluster(...,'criterion','
uses the specified criterion for forming clusters, where crit
')
crit
is either 'inconsistent'
or 'distance'
.
T = cluster(...,'depth',d)
evaluates inconsistent values to a depth of d
in the tree. The default is d = 2
. An inconsistency coefficient computation compares a link between two objects in the cluster tree with neighboring links up to the specified depth. See the inconsistent
function for more information.
Example
The example uses the pdist
function to calculate the distance between items in a matrix of random numbers and then uses the linkage
function to compute the hierarchical cluster tree based on the matrix. The example passes the output of the linkage
function to the cluster
function. The 'maxclust'
value 3
indicates that you want to group the items into three clusters. The find
function lists all the items grouped into cluster 1.
rand('seed', 0); X = [rand(10,3); rand(10,3)+1; rand(10,3)+2]; Y = pdist(X); Z = linkage(Y); T = cluster(Z,'maxclust',3); find(T==1) ans = 11 12 13 14 15 16 17 18 19 20
See Also
clusterdata
, cophenet
, inconsistent
, linkage
, pdist
![]() | classify | clusterdata | ![]() |