Skip to content

Voting rights

Step 2 in the pipeline

Voting rights are assigned per user and per entity, based on users' trust scores and privacy settings.

VotingRightsAssignment

Bases: ABC

__call__

__call__(
    users: DataFrame,
    entities: DataFrame,
    vouches: DataFrame,
    privacy: PrivacySettings,
) -> tuple[VotingRights, DataFrame]

Compute voting rights

Parameters:

Name Type Description Default
users DataFrame
  • user_id (int, index)
  • trust_score (float)
required
entities DataFrame
  • entity_id (int, index)
required
vouches DataFrame
  • voucher (int)
  • vouchee (int)
  • vouch (float)
required
privacy PrivacySettings

privacy[user, entity] in { True, False, None }

required

Returns:

Name Type Description
voting_rights[user, entity] is the voting right

of a user on entity for criterion

entities DataFrame with columns
  • entity_id (int, index)

to_json

to_json()

IsTrust

IsTrust(privacy_penalty: float = 0.5)

Bases: VotingRightsAssignment

Implements voting rights assignment directly based on user trust scores and applying some privacy penalty.

Parameters:

Name Type Description Default
privacy_penalty float

Penalty on private comparisons.

0.5

privacy_penalty

privacy_penalty = privacy_penalty

__call__

__call__(
    users: DataFrame,
    entities: DataFrame,
    vouches: DataFrame,
    privacy: DataFrame,
) -> tuple[VotingRights, DataFrame]

Compute voting rights

Parameters:

Name Type Description Default
users DataFrame
  • user_id (int, index)
  • trust_score (float)
required
entities DataFrame
  • entity_id (int, index)
required
vouches DataFrame
  • voucher (int)
  • vouchee (int)
  • vouch (float)
required
privacy DataFrame

privacy[user, entity] in { True, False, None }

required

Returns:

Name Type Description
voting_rights[user, entity] is the voting right

of a user on entity for criterion

entities DataFrame with columns
  • entity_id (int, index)

to_json

to_json()

AffineOvertrust

AffineOvertrust(
    privacy_penalty: float = 0.5,
    min_overtrust: float = 2.0,
    overtrust_ratio: float = 0.1,
)

Bases: VotingRightsAssignment

Initializes the AffineOvertrust model with the specified parameters.

Parameters:

Name Type Description Default
privacy_penalty float

Penalty on private comparisons.

0.5
min_overtrust float

Minimum overtrust amount to distribute over all users.

2.0
overtrust_ratio float

Trust ratio used to compute maximal allowed overtrust.

0.1

privacy_penalty

privacy_penalty = privacy_penalty

min_overtrust

min_overtrust = min_overtrust

overtrust_ratio

overtrust_ratio = overtrust_ratio

__call__

__call__(
    users: DataFrame,
    entities: DataFrame,
    vouches: DataFrame,
    privacy: PrivacySettings,
) -> tuple[VotingRights, DataFrame]

Compute voting rights for users on entities

Parameters:

Name Type Description Default
users DataFrame
  • user_id (int, index)
  • trust_score (float)
required
entities DataFrame
  • entity_id (int, index)
required
vouches DataFrame

This is not used by VotingRightsWithLimitedOvertrust

required
privacy PrivacySettings

privacy[user, entity] is the privacy setting of user for entity May be True, False or None

required

Returns:

Name Type Description
voting_rights[user, entity] is the voting right

of a user on entity for criterion

entities DataFrame with columns
  • entity_id (int, index)
  • cumulative_trust (float)
  • min_voting_right (float)
  • overtrust (float)

compute_entity_voting_rights

compute_entity_voting_rights(
    trust_scores: Series, privacy_weights: Series
) -> tuple[Series, float, float, float]

cumulative_trust

cumulative_trust(
    trust_scores: ndarray, privacy_weights: ndarray
) -> float

Returns the sum of trusts of raters of entity entity_id, weighted by their privacy setting.

Parameters:

Name Type Description Default
trust_scores ndarray
  • index "user_id (int, index)
  • values "trust_score" (float)
required
privacy_weights ndarray

privacy_weights[u] is the privacy weight of user u

required

Returns:

Name Type Description
out float

maximal_overtrust

maximal_overtrust(trust: float) -> float

Computes the maximal allowed overtrust of an entity, for a given total trust of the entity's raters.

Parameters:

Name Type Description Default
trust float

Cumulative trust received by the entity

required

Returns:

Name Type Description
out float

overtrust

overtrust(
    min_voting_right: float,
    trust_scores: ndarray,
    privacy_weights: ndarray,
) -> float

Returns the overtrust, if min_voting_right is enforced upon all raters.

Parameters:

Name Type Description Default
min_voting_right float

Overtrust for min_voting_right

required
trust_scores ndarray

values: trust_score (float)

required
privacy_weights ndarray

values: privacy weight of user

required

Returns:

Name Type Description
out float

min_voting_right

min_voting_right(
    max_overtrust: float,
    trust_scores: ndarray,
    privacy_weights: ndarray,
) -> float

Returns the minimal voting rights that corresponds to max_overtrust.

Parameters:

Name Type Description Default
max_overtrust float

Maximal overtrust allowed for entity_id

required
trust_scores ndarray

trust score values per user

required
privacy_weights ndarray

privacy weight per user

required

Returns:

Name Type Description
out float

to_json

to_json()