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

bundles / scipy latest / scipy / cluster / hierarchy / _hierarchy_impl / inconsistent

function

scipy.cluster.hierarchy._hierarchy_impl:inconsistent

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

Signature

def inconsistent(Z, d = 2)

Summary

Calculate inconsistency statistics on a linkage matrix.

Parameters

Z : ndarray

The by 4 matrix encoding the linkage (hierarchical clustering). See linkage documentation for more information on its form.

d : int, optional

The number of links up to d levels below each non-singleton cluster.

Returns

R : ndarray

A by 4 matrix where the i'th row contains the link statistics for the non-singleton cluster i. The link statistics are computed over the link heights for links levels below the cluster i. R[i,0] and R[i,1] are the mean and standard deviation of the link heights, respectively; R[i,2] is the number of links included in the calculation; and R[i,3] is the inconsistency coefficient,

Notes

This function behaves similarly to the MATLAB(TM) inconsistent function.

Examples

from scipy.cluster.hierarchy import inconsistent, linkage
from matplotlib import pyplot as plt
X = [[i] for i in [2, 8, 0, 4, 1, 9, 9, 0]]
Z = linkage(X, 'ward')
✓
print(Z)
inconsistent(Z)
✗
array([[0.     , 0.     , 1.     , 0.     ],
       [0.     , 0.     , 1.     , 0.     ],
       [1.     , 0.     , 1.     , 0.     ],
       [0.57735, 0.8165 , 2.     , 0.70711],
       [1.04044, 1.06124, 3.     , 1.01851],
       [3.11614, 1.40689, 2.     , 0.70711],
       [6.44583, 6.76771, 3.     , 1.12682]])

Aliases

  • scipy.cluster.hierarchy.inconsistent