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 by inheriting
UtilityProfile(the utility side) and composing aGradeProfile(the grade side). See the module docstring for the design.- 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"}, )
- display(cmap=None, show_totals=False)[source]¶
Display the profile as an ASCII table showing utilities and grades.
- normalize_by_standard_score()[source]¶
Return a new profile with each utility normalized by standard score.