Embeddings From Ratings

class embedded_voting.EmbeddingsFromRatings[source]

An abstract class that convert ratings into embeddings using some function.

Random

class embedded_voting.EmbeddingsFromRatingsRandom(n_dim=0)[source]

Generates random normalized embeddings for the voters.

The embeddings of the voters are drawn uniformly at random on the part of the sphere where all coordinates are positive. These embeddings actually does not take the ratings into account.

Examples

>>> np.random.seed(42)
>>> ratings = np.array([[1, 0], [1, 1], [0, 1]])
>>> embeddings_from_ratings = EmbeddingsFromRatingsRandom(n_dim=5)
>>> embeddings_from_ratings(ratings)
Embeddings([[0.28396232, 0.07904315, 0.37027159, 0.87068807, 0.13386116],
            [0.12251149, 0.82631858, 0.40155802, 0.24565113, 0.28389299],
            [0.17359769, 0.1744638 , 0.09063981, 0.71672067, 0.64615953]])

Identity

class embedded_voting.EmbeddingsFromRatingsIdentity[source]

Use the identity matrix as the embeddings for the voters.

Intuitively, each voter is alone in her group. These embeddings actually does not take the ratings into account.

Examples

>>> ratings = np.array([[.4, .6], [.1, .9], [.7, .5]])
>>> embeddings_from_ratings = EmbeddingsFromRatingsIdentity()
>>> embeddings_from_ratings(ratings)
Embeddings([[1., 0., 0.],
            [0., 1., 0.],
            [0., 0., 1.]])

Self

class embedded_voting.EmbeddingsFromRatingsSelf(norm)[source]

Use the normalized ratings as the embeddings for the voters.

Parameters:norm (bool) – Whether the embeddings should be normalized.

Examples

>>> ratings = np.array([[1, 0], [1, 1], [0, 1]])
>>> embeddings_from_ratings = EmbeddingsFromRatingsSelf(norm=True)
>>> embeddings_from_ratings(ratings)
Embeddings([[1.        , 0.        ],
            [0.70710678, 0.70710678],
            [0.        , 1.        ]])