num_obs_linkage — SciPy v1.15.2 Manual (original) (raw)
scipy.cluster.hierarchy.
scipy.cluster.hierarchy.num_obs_linkage(Z)[source]#
Return the number of original observations of the linkage matrix passed.
Parameters:
Zndarray
The linkage matrix on which to perform the operation.
Returns:
nint
The number of original observations in the linkage.
Examples
from scipy.cluster.hierarchy import ward, num_obs_linkage from scipy.spatial.distance import pdist
X = [[0, 0], [0, 1], [1, 0], ... [0, 4], [0, 3], [1, 4], ... [4, 0], [3, 0], [4, 1], ... [4, 4], [3, 4], [4, 3]]
Z
is a linkage matrix obtained after using the Ward clustering method with X
, a dataset with 12 data points.
num_obs_linkage(Z) 12