This is a pre-release version (2.0.0.dev0+git20260907.41eeb59).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / cluster / hierarchy / _hierarchy_impl / num_obs_linkage

function

scipy.cluster.hierarchy._hierarchy_impl:num_obs_linkage

source: build-install/usr/lib/python3.14/site-packages/scipy/cluster/hierarchy/_hierarchy_impl.py:2327

Signature

def num_obs_linkage(Z)

Summary

Return the number of original observations of the linkage matrix passed.

Parameters

Z : ndarray

The linkage matrix on which to perform the operation.

Returns

n : int

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 = ward(pdist(X))
✓
``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

Aliases

  • scipy.cluster.hierarchy.num_obs_linkage