Aggregator

class embedded_voting.Aggregator(rule=None, embeddings_from_ratings=None, default_train=True, name='aggregator', default_add=True)[source]

A class for an election generator with memory.

You can run an election by calling it with the matrix of ratings.

Parameters:
  • rule (Rule) – The aggregation rule you want to use in your elections. Default is RuleFastNash
  • 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: EmbeddingsFromRatingsCorrelation(preprocess_ratings=center_and_normalize).
  • default_train (bool) – If True, then by default, train the embeddings at each election.
  • name (str, optional) – Name of the aggregator.
  • default_add (bool) – If True, then by default, add the ratings to the history.
ratings_history

The history of all ratings given by the voters.

Type:np.ndarray
embeddings

The current embeddings of the voters.

Type:Embeddings

Examples

>>> aggregator = Aggregator()
>>> results = aggregator([[7, 5, 9, 5, 1, 8], [7, 5, 9, 5, 2, 7], [6, 4, 2, 4, 4, 6], [3, 8, 1, 3, 7, 8]])
>>> results.embeddings_
Embeddings([[ 1.        ,  0.98602958,  0.01549503, -0.43839669],
            [ 0.98602958,  1.        , -0.09219821, -0.54916602],
            [ 0.01549503, -0.09219821,  1.        ,  0.43796787],
            [-0.43839669, -0.54916602,  0.43796787,  1.        ]])
>>> results.ranking_
[5, 0, 1, 3, 4, 2]
>>> results.winner_
5
>>> results = aggregator([[2, 4, 8], [9, 2, 1], [0, 2, 5], [4, 5, 3]])
>>> results.ranking_
[2, 1, 0]
reset()[source]

Reset the variables ratings_history and embeddings.

Returns:The object itself.
Return type:Aggregator
train()[source]

Update the variable embeddings, based on ratings_history.

Returns:The object itself.
Return type:Aggregator