Kotze-Pereira transformation: Difference between revisions

Added details of simplest implementation
m (Add Kotze reference and voting theory category)
(Added details of simplest implementation)
Line 4:
The '''Kotze-Pereira transformation''' ('''KP transform''') converts scored ballots into Approval ballots, which allows any Approval PR method to be run on scored ballots. The transformation was independently invented by Kotze in 2011<ref>{{cite web |url=https://www.revleft.space/vb/threads/143429-Voting-with-ratings?s=f9288911a893930199498f370d9e4825&p=2030744#post2030744 |date=2011-02-23 |access-date=2020-02-10 |title=Voting with ratings|author=Kotze}}</ref> and [[Toby Pereira]].{{citation needed}} <!-- needs date of invention and reference to it, e.g. mailing list post -->
 
==Explanation==
For example, a voter whose scores are (with the max score being 10) A=10 B=6 C=4, would have their 1 ballot transformed into 0.4 ABC, 0.2 AB, and 0.4 A Approval ballots. This is because the lowest score they gave to any candidate is a 4 out of 10, which is 40% support, so a corresponding 40% portion of their ballot is treated as approving all candidates scored a 4/10 or higher (Candidates A, B, and C); the next-lowest score they gave was a 6/10, 60% support, but because 40% of the ballot was already converted into Approval ballots, only the remaining 60% - 40% = 20% portion is converted, and all candidates scored a 6 out of 10 or higher (Candidates A and B) are treated as approved in this 20% portion; finally, within the remaining 40% portion of the ballot, the next-lowest score the voter gave is a 10/10, so all candidates scored a 10 or higher (Candidate A) are considered approved on this portion of the ballot.
 
For example, aA voter whose scores are (with the max score being 10) A=10 B=6 C=4, would have their 1 ballot transformed into 0.4 ABC, 0.2 AB, and 0.4 A Approval ballots. This is because the lowest score they gave to any candidate is a 4 out of 10, which is 40% support, so a corresponding 40% portion of their ballot is treated as approving all candidates scored a 4/10 or higher (Candidates A, B, and C); the next-lowest score they gave was a 6/10, 60% support, but because 40% of the ballot was already converted into Approval ballots, only the remaining 60% - 40% = 20% portion is converted, and all candidates scored a 6 out of 10 or higher (Candidates A and B) are treated as approved in this 20% portion; finally, within the remaining 40% portion of the ballot, the next-lowest score the voter gave is a 10/10, so all candidates scored a 10 or higher (Candidate A) are considered approved on this portion of the ballot.
 
To avoid having fractional approval ballots, some suggest that the KP transform should be done in such a way that one voter's score ballot always produces the smallest number of approval ballots such that they all are integer amounts; with the above example, this would mean multiplying the number of Approval ballots in each set by 5, yielding 2 ABC, 1 AB, and 2 A Approval ballots.
 
==The formal definition:==
 
{{definition|
Line 28 ⟶ 30:
 
Note that the Approval ballots yielded by the KP transform can be converted into ranked ballots by considering all approved candidates on a ballot as ranked co-1st, and all disapproved candidates as ranked co-equal last. With the above example of 0.4 ABC, 0.2 AB, and 0.4 A Approval ballots, this would converted into 0.4 A=B=C, 0.2 A=B(>C), and 0.4 A(>B=C) ranked ballots. This allows ranked PR methods to be done on rated ballots.
 
==Whole Ballot formulation==
 
In the whole ballot formulation there is never any farctional approval ballots. All score ballots are turned into the same number of whole approval ballots. The number of ballots is the same as the maximum score.
===Example Ballot===
 
An illustrative ballot for a max score 5 system is.
A:1 B:3 C:4 D:0
 
The KP-Transform turns this into 5 approval ballots.
 
 
{| class="wikitable"
|-
! Ballot !! A !! B !! C !! D
|-
| 1 || 1 || 1 || 1 || 0
|-
| 2 || 0 || 1 || 1 || 0
|-
| 3 || 0 || 1 || 1 || 0
|-
| 4 || 0 || 0 || 1 || 0
|-
| 5 || 0 || 0 || 0 || 0
|}
 
===Python Implementation===
 
The whole ballot formulation is particularly simple computationally. Given a Pandas dataframe '''S''' with columns representing candidates and rows representing voters the entries would encode the score of all the ballots. For a max score of '''K''' and an output set of approval ballots '''A'''.
 
<source lang="python">
import pandas as pd
import numpy as np
 
groups = []
for threshold in range(K):
groups.append(np.where(S.values > threshold, 1, 0))
A = pd.DataFrame(np.concatenate(groups), columns=S.columns)
 
</source>
 
==Further Reading==
765

edits