scipy.cluster.hierarchy.cophenet¶
-
scipy.cluster.hierarchy.
cophenet
(Z, Y=None)[source]¶ Calculate the cophenetic distances between each observation in the hierarchical clustering defined by the linkage
Z
.Suppose
p
andq
are original observations in disjoint clusterss
andt
, respectively ands
andt
are joined by a direct parent clusteru
. The cophenetic distance between observationsi
andj
is simply the distance between clusterss
andt
.Parameters: - Z : ndarray
The hierarchical clustering encoded as an array (see
linkage
function).- Y : ndarray (optional)
Calculates the cophenetic correlation coefficient
c
of a hierarchical clustering defined by the linkage matrix Z of a set of \(n\) observations in \(m\) dimensions. Y is the condensed distance matrix from which Z was generated.
Returns: - c : ndarray
The cophentic correlation distance (if
Y
is passed).- d : ndarray
The cophenetic distance matrix in condensed form. The \(ij\) th entry is the cophenetic distance between original observations \(i\) and \(j\).