subrela.clustering.get_groups function

subrela.clustering.get_groups(Z, threshold)[source]

Define groups by a distance threshold.

Parameters
Returns

groups (list[int]) – Indices of group clusters.

Examples

>>> import numpy
>>> X = numpy.array([[0, -5, -5, 6, 6], [0, -1, 1, -2, 2]])
>>> Z = get_clusters(X)
>>> Z
        children  distance           leaves
cluster
5         [1, 2]  2.000000           [1, 2]
6         [3, 4]  4.000000           [3, 4]
7         [0, 5]  5.099020        [0, 1, 2]
8         [6, 7]  6.324555  [3, 4, 0, 1, 2]
>>> get_groups(Z, 4.5)
[0, 5, 6]