Last active
May 16, 2016 15:49
-
-
Save blole/3f689b3425ecd05bd142842f7caeacac to your computer and use it in GitHub Desktop.
Schulze non-proportional ordering of the Eurovision 2016 final results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# | |
# Schulze non-proportional ordering of the Eurovision 2016 final results. | |
# data from http://eurovisionworld.com/?eurovision=2016 | |
from pyvotecore.schulze_npr import SchulzeNPR | |
def transpose(matrix): | |
return map(list, zip(*matrix)) | |
countries = [ | |
'Ukraine', 'Australia', 'Russia', 'Bulgaria', 'Sweden', 'France', | |
'Armenia', 'Poland', 'Lithuania', 'Belgium', 'Netherlands', 'Malta', | |
'Austria', 'Israel', 'Latvia', 'Italy', 'Azerbaijan', 'Serbia', | |
'Hungary', 'Georgia', 'Cyprus', 'Spain', 'Croatia', | |
'United Kingdom', 'Czech Republic', 'Germany' | |
] | |
jury = [ | |
[0, 0, 2, 0, 10, 7, 3, 12, 0, 0, 0, 0, 12, 7, 0, 0, 12, 12, 7, 2, 0, 0, 0, 12, 10, 12, 8, 0, 12, 0, 3, 4, 12, 0, 12, 12, 12, 0, 0, 6, 0, 10], | |
[12,5, 0, 12, 7, 6, 12, 10, 8, 12, 10, 0, 10, 10, 8, 6, 8, 8, 6, 7, 12, 10, 0, 10, 6, 5, 12, 3, 10, 4, 12, 10, 10, 2, 0, 6, 6, 8, 12, 12, 5, 8 ], | |
[7, 2, 0, 3, 12, 12, 0, 5, 6, 6, 12, 0, 0, 0, 0, 1, 0, 0, 0, 12, 0, 8, 0, 0, 0, 7, 0, 4, 7, 8, 0, 0, 0, 0, 7, 1, 0, 4, 6, 0, 0, 0 ], | |
[4, 7, 8, 0, 8, 1, 6, 3, 0, 0, 0, 0, 6, 0, 0, 10, 10, 0, 0, 0, 0, 0, 10, 7, 0, 1, 2, 10, 0, 2, 0, 8, 3, 0, 0, 4, 10, 0, 0, 1, 1, 5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 0, 0, 0, 0, 0, 0 ], | |
[0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0 ] | |
] | |
# schulze ordering | |
ballots = [] | |
for voter in transpose(jury) + transpose(tele): | |
rating = {countries[i]: rate for (i, rate) in sorted(enumerate(voter), key=lambda (i, rate): rate) if rate > 0} | |
ballots.append({'ballot': rating}) | |
schulze = SchulzeNPR(ballots, ballot_notation="rating").as_dict()['order'] | |
# the ordinary ordering for 2016 | |
esc = [x[1] for x in sorted(zip([sum(row1)+sum(row2) for (row1,row2) in zip(jury,tele)], countries), reverse=True)] | |
print '# SchulzeNPR ESC2016 diff' | |
for (i, (s, e)) in enumerate(zip(schulze, esc)): | |
print '%2d. %-14s %-14s%s' % (i+1, s, e, ' *'*(s!=e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output