Approval Rules

class embedded_voting.RuleApprovalProduct(embeddings_from_ratings=None)[source]

Voting rule in which the score of a candidate is the number of approval (vote greater than 0) that it gets. Ties are broken by the product of the positive ratings.

More precisely, her score is a tuple whose components are:

  • The number of her nonzero ratings.
  • The product of her nonzero ratings.

Note that this rule is well suited only if ratings are nonnegative.

No embeddings are used for this rule.

Parameters:embeddings_from_ratings (EmbeddingsFromRatings) – If no embeddings are specified in the call, this EmbeddingsFromRatings object is use to generate the embeddings from the ratings. Default: EmbeddingsFromRatingsIdentity().

Examples

>>> ratings = Ratings(np.array([[.5, .6, .3], [.7, 0, .2], [.2, 1, .8]]))
>>> election = RuleApprovalProduct()(ratings)
>>> election.scores_
[(3, 0.06999999999999999), (2, 0.6), (3, 0.048)]
>>> election.ranking_
[0, 2, 1]
>>> election.winner_
0
>>> election.welfare_
[1.0, 0.0, 0.6857142857142858]
class embedded_voting.RuleApprovalSum(embeddings_from_ratings=None)[source]

Voting rule in which the score of a candidate is the number of approval (vote greater than 0) that it gets. Ties are broken by sum of score (range voting).

More precisely, her score is a tuple whose components are:

  • The number of her nonzero ratings.
  • The sum of her ratings.

No embeddings are used for this rule.

Parameters:embeddings_from_ratings (EmbeddingsFromRatings) – If no embeddings are specified in the call, this EmbeddingsFromRatings object is use to generate the embeddings from the ratings. Default: EmbeddingsFromRatingsIdentity().

Examples

>>> ratings = Ratings(np.array([[.5, .6, .3], [.7, 0, .2], [.2, 1, .8]]))
>>> election = RuleApprovalSum()(ratings)
>>> election.ranking_
[0, 2, 1]
>>> election.scores_
[(3, 1.4), (2, 1.6), (3, 1.3)]
>>> election.winner_
0
>>> election.welfare_
[1.0, 0.0, 0.9285714285714287]
class embedded_voting.RuleApprovalRandom(embeddings_from_ratings=None)[source]

Voting rule in which the score of a candidate is the number of approval (vote greater than 0) that it gets. Ties are broken at random.

More precisely, her score is a tuple whose components are:

  • The number of her nonzero ratings.
  • A random value.

No embeddings are used for this rule.

Parameters:embeddings_from_ratings (EmbeddingsFromRatings) – If no embeddings are specified in the call, this EmbeddingsFromRatings object is use to generate the embeddings from the ratings. Default: EmbeddingsFromRatingsIdentity().

Examples

>>> np.random.seed(42)
>>> ratings = Ratings(np.array([[.5, .6, .3], [.7, 0, .2], [.2, 1, .8]]))
>>> election = RuleApprovalRandom()(ratings)
>>> election.ranking_
[2, 0, 1]
>>> election.scores_
[(3, 0.3745401188473625), (2, 0.9507143064099162), (3, 0.7319939418114051)]
>>> election.winner_
2
>>> election.welfare_
[0.5116710637256354, 0.0, 1.0]