ismembership#

er_evaluation.ismembership(obj)[source]#

Check if given object is a membership vector.

Membership vector:

A membership vector is a pandas Series indexed by the elements of \(E\) and with values corresponding to cluster identifiers. That is, the memebership vector maps elements to clusters. Example:

>>> pd.Series(["c1", "c1", "c1", "c2", "c2", "c3"], index=[0,1,2,3,4,5])
0    c1
1    c1
2    c1
3    c2
4    c2
5    c3
dtype: object
Returns:

True if membership vector, False otherwise.

Return type:

bool

Examples

>>> import pandas as pd
>>> obj = pd.Series(index=[1,2,3,4,5,6,7,8], data=[1,1,2,3,2,4,4,4])
>>> ismembership(obj)
True
>>> ismembership([1,1,2,3,2,4,4,4])
False