clusters_to_membership#

er_evaluation.clusters_to_membership(clusters)[source]#

Transform clusters dictionary into membership vector.

Parameters:

clusters (dictionary) – Dictionary mapping cluster identifiers to numpy array of cluster elements.

Returns:

Membership vector.

Examples

>>> from numpy import array
>>> clusters = {1: array([1, 2]), 2: array([3, 5]), 3: array([4]), 4: array([6, 7, 8])}
>>> clusters_to_membership(clusters)
1    1
2    1
3    2
5    2
4    3
6    4
7    4
8    4
dtype: int64