openclean.function.value.vote module
Value function that implements a conflict resolution stategy for majority voting.
- class openclean.function.value.vote.MajorityVote(tiebreaker: Optional[openclean.function.value.base.ValueFunction] = None)
Bases:
openclean.function.value.base.UnpreparedFunction
Value function that implements a majority voting strategy for conflict resolution. Selects the most frequent value in a given list of values during the preparation step. Returns a constant value function for the selected value as the preparation result.
If there is a tie for the most frequent value the tie is broken using a given tiebreaker function. If no tiebreaker function is specified an error will be raised.
- prepare(values: List[Union[int, float, str, datetime.datetime, Tuple[Union[int, float, str, datetime.datetime]]]]) openclean.function.value.base.ValueFunction
Select the most frequent value in the given list of values. A constant value function is returned as the result.
If there is a tie for the most frequent value the tie is broken using the tiebreaker function. If no tiebreaker function is specified a ValuError will be raised.
- Parameters
values (list) – List of scalar values or tuples of scalar values.
- Return type