Util Grade Profiles¶
Profiles of voters that each submit both a utility function over candidates and an assignment of grades from a fixed set to each candidate. The ballots for a UtilGradeProfile are Utilities and Grades.
UtilGradeProfile Class¶
- class pref_voting.util_grade_profile.UtilGradeProfile(utilities, grade_maps, grades, ucounts=None, candidates=None, cmap=None, gmap=None, grade_order=None)[source]¶
An anonymous profile of utilities and grades.
Each voter submits both a utility function over candidates and a grade assignment (e.g., approval/disapproval). This class packages both into a single object, combining the functionality of
UtilityProfileandGradeProfile.- Parameters:
utilities (list[dict] or list[Utility]) – List of utility dicts or
Utilityobjects.grade_maps (list[dict] or list[Grade]) – List of grade dicts or
Gradeobjects.grades (list) – List of possible grades.
ucounts (list[int], optional) – List of the number of voters associated with each utility/grade pair. If not provided, 1 per entry.
candidates (list, optional) – List of candidates. If not provided, discovered from the utilities and grade maps.
cmap (dict, optional) – Dictionary mapping candidates to display names.
gmap (dict, optional) – Dictionary mapping grades to display names.
grade_order (list, optional) – Grades listed from largest to smallest. If not provided, grades are sorted in descending numeric order.
- Example:
ugprof = UtilGradeProfile( [{"x": 5, "y": 3, "z": 1}, {"x": 2, "y": 4, "z": 4}], [{"x": 1, "y": 0, "z": 0}, {"x": 0, "y": 1, "z": 1}], [0, 1], candidates=["x", "y", "z"], gmap={0: "Not Approved", 1: "Approved"}, )
- candidates¶
Sorted list of candidates.
- cmap¶
Candidate display-name mapping.
- display(cmap=None, show_totals=False)[source]¶
Display the profile as an ASCII table showing utilities and grades.
- gmap¶
Grade display-name mapping.
- property grade_functions¶
Return the expanded list of grade functions (one per voter).
- grade_order¶
Grade ordering (largest to smallest).
- grades¶
List of possible grades.
- property grades_counts¶
Return
(grades_list, ucounts).
- median(c, use_lower=True, use_average=False)[source]¶
Return the median grade for
c, or None if ungraded.
- normalize_by_standard_score()[source]¶
Return a new profile with each utility normalized by standard score.
- num_cands¶
Number of candidates.
- num_voters¶
Total number of voters.
- proportion_with_higher_grade(cand, grade)[source]¶
Proportion of voters assigning strictly higher grade to
cand.
- proportion_with_lower_grade(cand, grade)[source]¶
Proportion of voters assigning strictly lower grade to
cand.
- remove_candidates(cands_to_ignore)[source]¶
Return a new profile with the specified candidates removed.
- property utilities¶
Return the expanded list of utility functions (one per voter).
- property utilities_counts¶
Return
(utilities_list, ucounts).