Maximum Likelihood¶
MLE Gaussian¶
-
class
embedded_voting.
RuleMLEGaussian
(embeddings_from_ratings=None, tol=1e-06)[source]¶ A rule that computes the scores of the candidates, assuming that the embeddings of the voters correspond to a covariance matrix.
For this rule, the embeddings must be a matrix n_voters * n_voters.
Examples
Consider a generating epistemic model, where the true value of each candidate is uniformly drawn in a given interval, and where the voters add a noise which is multivariate Gaussian.
>>> np.random.seed(42) >>> covariance_matrix = np.array([ ... [2.02, 1.96, 0.86, 0.81, 1.67], ... [1.96, 3.01, 1.46, 0.69, 1.59], ... [0.86, 1.46, 0.94, 0.39, 0.7 ], ... [0.81, 0.69, 0.39, 0.51, 0.9 ], ... [1.67, 1.59, 0.7 , 0.9 , 1.78] ... ]) >>> ratings_generator = RatingsGeneratorEpistemicMultivariate(covariance_matrix=covariance_matrix) >>> ratings = ratings_generator(n_candidates=2) >>> ratings_generator.ground_truth_ array([17.73956049, 14.3887844 ]) >>> ratings Ratings([[17.56232759, 14.51592899], [16.82544972, 15.78818081], [17.51952581, 14.44449175], [17.34964888, 14.4010885 ], [16.69480298, 14.9281998 ]])
If we know the covariance matrix of the noises, then RuleMLEGaussian is the maximum likelihood estimator of the ground truth:
>>> election = RuleMLEGaussian()(ratings, embeddings=covariance_matrix) >>> election.scores_ # doctest: +ELLIPSIS [268.6683142..., 221.5083075...]
Model Aware¶
-
class
embedded_voting.
RuleModelAware
(groups_sizes, groups_features, group_noise=1, independent_noise=0)[source]¶ A rule that is know the noise parameters of the model and use the maximum likelihood to select the best candidate.
Parameters: - groups_sizes (list of int) – The number of voters in each group.
- groups_features (np.ndarray of shape (n_groups, n_features)) – The features of each group.
- group_noise (float) – The value of the feature noise.
- independent_noise (float) – The value of the distinct noise.
Examples
>>> ratings = Ratings(np.array([[.5, .6, .3], [.7, 0, .2], [.2, 1, .8]])) >>> election = RuleModelAware([2, 1], [[1, 0], [0, 1]], group_noise=1, independent_noise=1)(ratings) >>> election.ranking_ [1, 2, 0] >>> election.scores_ [0.5, 0.7, 0.5666666...] >>> election.winner_ 1