Skip to content

Instantly share code, notes, and snippets.

@KiaraGrouwstra
Last active July 19, 2023 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KiaraGrouwstra/02fcc11cd0b3dc67b5d35d8de2e445fc to your computer and use it in GitHub Desktop.
Save KiaraGrouwstra/02fcc11cd0b3dc67b5d35d8de2e445fc to your computer and use it in GitHub Desktop.
data-backed voting advice

voting advice applications:

data:

algorithm:

  • per motion calculate distance between parties
  • in a loop:
    • calculate mean fit per party based on filled motions
    • calculate distance between parties based on calculated mean scores
    • per motion calculate distance between parties for that motion / distance between them based on the user's calculated mean fit
    • per motion sum the above figure into a score expressing how well the motion helps distinguish best-fitting parties for the user
    • ask user to answer the unanswered motion with the highest score
    • maybe figure out some kind of confidence level to figure out when to advice the user to settle?
select id,
MAX(voted) FILTER (WHERE party_name = 'VVD') as VVD,
MAX(voted) FILTER (WHERE party_name = 'CDA') as CDA,
MAX(voted) FILTER (WHERE party_name = 'D66') as D66,
MAX(voted) FILTER (WHERE party_name = 'PVV') as PVV,
MAX(voted) FILTER (WHERE party_name = 'ChristenUnie') as ChristenUnie,
MAX(voted) FILTER (WHERE party_name = 'PvdD') as PvdD,
MAX(voted) FILTER (WHERE party_name = 'GroenLinks') as GroenLinks,
MAX(voted) FILTER (WHERE party_name = 'SP') as SP,
MAX(voted) FILTER (WHERE party_name = 'SGP') as SGP,
MAX(voted) FILTER (WHERE party_name = 'Brinkman') as Brinkman,
MAX(voted) FILTER (WHERE party_name = 'Verdonk') as Verdonk,
MAX(voted) FILTER (WHERE party_name = 'CDA') as CDA,
MAX(voted) FILTER (WHERE party_name = 'CDA') as CDA,
MAX(voted) FILTER (WHERE party_name = 'PvdA') as PvdA,
MAX(voted) FILTER (WHERE party_name = 'BIJ1') as BIJ1,
source_url,
title_short
from
(SELECT document_document.id,
document_document.source_url,
title_short,
party_name,
CASE
WHEN decision not in ('FO',
'AG') THEN NULL
WHEN (decision = 'FO') = is_mistake THEN 1
ELSE 0
END AS voted
FROM document_vote
JOIN document_voteparty ON document_vote.id = vote_ptr_id
JOIN document_voting ON voting_id = document_voting.id
JOIN document_decision ON document_decision.id = decision_id
JOIN document_kamerstuk ON document_voting.kamerstuk_id = document_kamerstuk.id
JOIN document_document ON document_kamerstuk.document_id = document_document.id
WHERE document_decision.status = 'BESLUIT'
AND text in ('Aangenomen',
'Verworpen')
) as sub
GROUP BY id,
source_url,
title_short;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment