MembershipVector#

class er_evaluation.MembershipVector(data=None, dropna=False, **kwargs)[source]#

Bases: Series

Series wrapper to validate membership vector format and log potential issues.

Given a Series membership representing a membership vector, you can validate it using:

membership = MembershipVector(membership)

This casts its type to the MembershipVector subclass. If membership is already of the MembershipVector subtype, this does absolutely nothing and simply returns the membership object as-is. However, if membership is a Series, then it is validated, potential issues are logged, and then the object is returned as a instance of the MembershipVector subclass.

This wrapper helps avoid duplicate validation and duplicate logging within the er_evaluation package. Externally, you may use ismembership() to validate that a given pandas Series satisfies the requirements of a membership vector.

Examples

>>> series = pd.Series([1,2,3,3])
>>> membership = MembershipVector(series)  # Validates the series and logs potential issues.
>>> membership = MembershipVector(membership)  # Does nothing.