This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / cluster / hierarchy / _hierarchy_impl / maxinconsts

function

scipy.cluster.hierarchy._hierarchy_impl:maxinconsts

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

Signature

def maxinconsts(Z, R)

Summary

Return the maximum inconsistency coefficient for each non-singleton cluster and its children.

Parameters

Z : ndarray

The hierarchical clustering encoded as a matrix. See linkage for more information.

R : ndarray

The inconsistency matrix.

Returns

MI : ndarray

A monotonic (n-1)-sized numpy array of doubles.

Examples

from scipy.cluster.hierarchy import median, inconsistent, maxinconsts
from scipy.spatial.distance import pdist
✓
Given a data set ``X``, we can apply a clustering method to obtain a linkage matrix ``Z``. `scipy.cluster.hierarchy.inconsistent` can be also used to obtain the inconsistency matrix ``R`` associated to this clustering process:
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 = median(pdist(X))
R = inconsistent(Z)
✓
Z
R
✗
array([[1.     , 0.     , 1.     , 0.     ],
       [1.     , 0.     , 1.     , 0.     ],
       [1.     , 0.     , 1.     , 0.     ],
       [1.     , 0.     , 1.     , 0.     ],
       [1.05902, 0.08346, 2.     , 0.70711],
       [1.05902, 0.08346, 2.     , 0.70711],
       [1.05902, 0.08346, 2.     , 0.70711],
       [1.05902, 0.08346, 2.     , 0.70711],
       [1.74536, 1.08655, 3.     , 1.1547 ],
       [1.91202, 1.37523, 3.     , 1.1547 ],
       [3.25   , 0.25   , 3.     , 0.     ]])
Here, `scipy.cluster.hierarchy.maxinconsts` can be used to compute the maximum value of the inconsistency statistic (the last column of ``R``) for each non-singleton cluster and its children:
maxinconsts(Z, R)
✗
array([0.     , 0.     , 0.     , 0.     , 0.70711, 0.70711, 0.70711,
       0.70711, 1.1547 , 1.1547 , 1.1547 ])

See also

inconsistent

for the creation of a inconsistency matrix.

linkage

for a description of what a linkage matrix is.

Aliases

  • scipy.cluster.hierarchy.maxinconsts