clusterdata
Construct agglomerative clusters from data
Description
为每个观察返回集群指数(行)of an input data matrixT
= clusterdata(X
,cutoff
)X
, given a thresholdcutoff
for cutting an agglomerative hierarchical tree that thelinkage
function generates fromX
.
clusterdata
supports agglomerative clustering and incorporates thepdist
,linkage
, andcluster
functions, which you can use separately for more detailed analysis. SeeAlgorithm Descriptionfor more details.
Examples
Input Arguments
Output Arguments
Tips
If
'Linkage'
is'centroid'
or'median'
,nlinkage
can produce a cluster tree that is not monotonic. This result occurs when the distance from the union of two clusters,rands, to a third cluster is less than the distance betweenrands. In this case, in a dendrogram drawn with the default orientation, the path from a leaf to the root node takes some downward steps. To avoid this result, specify another value for'Linkage'
. The following image shows a nonmonotonic cluster tree.In this case, cluster 1 and cluster 3 are joined into a new cluster, while the distance between this new cluster and cluster 2 is less than the distance between cluster 1 and cluster 3.
Algorithms
If you specify a valuec
for thecutoff
input argument, then
performs the following steps:T
=clusterdata
(X
,c)
Create a vector of the Euclidean distance between pairs of observations in
X
by usingpdist
.Y =
pdist
(X
,'euclidean')Create an agglomerative hierarchical cluster tree from
Y
by usinglinkage
with the'single'
method for computing the shortest distance between clusters.Z =
linkage
(Y,'single')If
0 <
c
< 2
, usecluster
to define clusters fromZ
when inconsistent values are less thanc
.T
=cluster
(Z,'Cutoff',c)If
c
is an integer value≥ 2
, usecluster
to find a maximum ofc
clusters fromZ
.T
= cluster(Z,'MaxClust',c)
Alternative Functionality
If you have a hierarchical cluster treeZ
(the output of thelinkage
function for the input data matrixX
), you can usecluster
to perform agglomerative clustering onZ
and return the cluster assignment for each observation (row) inX
.