1.9 Analysing political distance by voting behaviour alone.
===========================================================
2023-01-10
During the last years I've been refining the approach that I've
started: using _exclusively_ published (and official) data on how
political parties vote, determine the relative distance between them and
create some helpful descriptive analytics:
*Proximidades e distâncias: análise da actividade parlamentar*
(
https://fsmunoz.github.io/parlamento/html/intro.html) (in Portuguese).
I've used Jupyter Book (
https://jupyterbook.org/en/stable/intro.html)
to improve the readability and make it easier to use, without removing
access to details (including code).
now I have the following features:
• Parsing of votes and creation of voting heatmaps.
-========================------============------=======-===-=======
*##################************############*******######******######.
+******************=+=+=+******************############*******#####*
*###########*******######*******#***#******#########################
*###################***#*******#######****#******#%%%%%%%%%%%%%%%%%#.
*##################******######*******************############******
+******************######*******************###########*+***+*#####*
*######************************############******######*******#####*
*#*######################******############*******#################*
*#################*******###########################################
*##################******#####################################******
*######%%%%%#############******############******##################*
******###################******############******###################
*#####************#######******###############################******
*##################******************#############*#################
*#################*++++++******##############################%%%%%%%.
******###################******###################%%%%%#*###########
*#*###*******####**************#########################******######
*#######################*******############*******############%%%%%%.
+******##################******++++++++++++*******############******
+***********#############*******************####*#######******++++++
*########################******#############%%%%#%%%%%%%%%%%%%%%%%%%.
*######***********#######******#########################*###*#%%%%%%.
*#*######################******++++++++++++*****************#*------
*########################******##################******#######++++++
*########################******#######*****#%%%%%%%%%%%%############.
*####################################******#%#%%#%#%%%#%%%%%%%######.
*###################################################################
*########################****#*#############%%%%%###################.
*###################################################################.
*###################################################################.
*########################************#######*****#%%%%%%%%%%%#******
+*****#############******************######*************************
• Determination of the pairwise distance between all parties.
• Using a clustermap to determine the relative distances between
parties, and how they are grouped.
@@@@@@@@@@@@@@@@%@@@@@@@@%%%@@@@@@%%@@%%@%%@@@@@@%@@@%@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@%##%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@***%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@++=#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@=--*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@:::+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@##*%@@@@@@@@@#*#*####%%%#%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@-.:::..-=======%@%%%%%@%%%%%%%@%%%%%%@%%%%%%%@%%%%%%@@@@
@@@@@@@@@@@@@@-::-:::=+=+++==%@%#%@%@%%%#%@%@%@%%@%@@%%#%@%@%@%%@%@@%@
@@@@@@@@@@@@@@-::::::=+++++++%@%@%%%@@%%@%%@@%%@@%%@@%%@%%@@%%@%%%@@%@
@@@@@@@@@@@@@@+=======-------#@%@@@%@@@@@@@@@%@@@@%@@@@@@@@@@@@@@%@@@@
@@@@@@@@@@@@@@*=+++=+=:::::::#@%%%%%@%%%%%%%@%%%%%%@%%%%%%%@%%%%%%@@@@
@@@@@@@@@@@@@@+==++===:::::::#@@%%@@@@@%%%@@@%@%%@%@@%%%%@@@%%%%%%@@%@
@@@@@@@@@@@@@@*+++++++-------#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@%@@%%@@%@
@@@@@@@@@@@@@@@%%%%%%%%%%%%%@=::::::=**********************%@%@@%%@@@@
@@@@@@@@@@@@@@@%@#%@%@@@%#%%@=::::::-**********************%@%%#@%@@@@
@@@@@@@@@@@@@@@%%%%%%@%%%%%%@=.::::.-**********************%@%%%%%@@%@
@@@@@@@@@@@@@@@%@@@@@@@@@@@%@+-======+++++++***************%@%@@@%@@@@
@@@@@@@@@@@@@@@%%%%%%@%%%%%%@#*******:::::::=======++======#@%%%%%@@@@
@@@@@@@@@@@@@@@%%#%@%@%%%#%%@#*******:::-:::===++==++==++==#@%%#@%@@%@
@@@@@@@@@@@@@@@%%%%%%@%%%%%%@#*******:::::::=+++++++++++++=%@%%%%%@@@@
@@@@@@@@@@@@@@@%@@@@@@@@@@@%@#*******========------========#@%@@@%@@@@
@@@@@@@@@@@@@@@%%%%%%@%%%%%%@#*******+++++=+-::::::--------#@%%%%%@@@@
@@@@@@@@@@@@@@@%%%%%%@%%%%%%@#*******===++=+-::::::----=---#@%%%%%@@%@
@@@@@@@@@@@@@@@%%@@%%@@%@@@%@#*******+++++++=::::::--------#@%%@%%@@@@
@@@@@@@@@@@@@@@%%@@%%@@%@@@%@#*******+++++++=------=-::::::*%#####%@@@
@@@@@@@@@@@@@@@%%%%@%@%%%#%%@#*******+=+++=+=--==--=:::-:::*###*##%@@@
@@@@@@@@@@@@@@@%%%%%%@%%%%%%@#*******========:----:-::::::.*%#####%@%@
@@@@@@@@@@@@@@@%@@@@@@@@@@@%@########********+++++++=======*******#@@@
@@@@@@@@@@@@@@@%%%%%%@%%%%%%%@@@@@@@@@@@@@@@@@@@@@@@%#####%=.::::.-@@@
@@@@@@@@@@@@@@@%%#%@%@%@%#%%%@%@%#%%@%%%#%%%@%%%#%%%###*###=:::-::=@@@
@@@@@@@@@@@@@@@%%%%%%@%%%%%%%@%%%%%%@%%%%%%%@%%%%%%%#######=.::::.-@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%@@%##**###@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%@@@@@@@%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
• Appliying DBSCAN and Spectral Clustering to further determine
clustering.
• Use Multi-dimensional Scaling to reduce dimensions to 2 and 3D, for
interactive visualisation.
@@@@@%%%%%%@%%%@%%%%%%%%%%%@%%%%%%@%%@%%%%@%%%%%%%%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@@@@@@@@@@@@@@@@@@#=#@@@@@@%
@@@@@@%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%#@@@@@@@%
@@@@@@%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#%%@@@@@@@@@@@@@@%
@@@@@@%@@@@@@@@#+%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@++@@@@@@@@@@@@@@@%
@@%@@@%@@@@@@@@%*%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%
@@@@@@%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%
@@@@@@%%@@@@@@@@@%%%@@@@@@@@%%%@@@@@@@@@%%@@@@@@@@@%%%@@@@@@@@@%%@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
• Determine who supported who in terms of proposals, and how many
were approved or rejected.
=****:.++++-.+++++ ==+++.-++++::++++-.++++= +=+++ =+==+.-+=++::++===
#@@@@+-####*.####%.%###%:*####-=%###+:%####.%###%.#####:+####=-%%###
=#**#-.++++=.+++++ +++++.=++++::++++-.++++=.+++++ =+=++.-++++::*+++=
-++++::****= +++++ +++++.=++++::+=++-.++++= +++++ =+==+.-++++::++===
+####=-@@@@#.####%.%###%.*%###-=####+:%####.%###%.#####:+####=-%%###
-++++::****= +++++ +=+++.-++++::+=++-.+=++= +=+++ =+==+.-+=++::++===
-++++::++++=.*#*#* +++++.=++++::++++-.++++= +++++ =+==+.-++++::++===
+####=-####*.@@@@@.%###%.*%###-=####+:%####.%###%.#####:+####=-%%###
-++++:.++++-.***** ==+++.-++++::+=++-.++++= +=+++ =+==+.-+=++::++===
=++++::++++=.+=+++ *####.=++++::*+++-.+++++ *++++ =++++.-*+++:.++++=
*####=-####*.####%.@@@@@.*####-=%###+:#####.%%##%.#####:+%###=:#####
-+==+::+===-.+==== +****.-===+::+==+-.+==== ++==+ ====+.-+===:.=====
.=*++- =*++= =*+++ -=+++.+####:-++++-.-++++.=.*++ ++++*.-+-++::**++=
:*%##= *%### +%##%.++%#%.#@@@@==####+.=####.*:%#%.##*##:+#=##=-%%#**
.====: ====- -+=== :-+=+.=****::====-.:==== -.+== =====.-=:==:.++==-
. =**-: *+= +*+.- ***. .*+*:-####= *++.::*+* - .**.- =**-:#-:*+
: +%#=-. ##* ##%.= ###. :%##-+@@@@*. .###.-:%#%.+ .##:= +%#=-@=:%#
. -==:.. ==- === : ===. .===::*++*- === :.+== - .==.: -==:.+:.+=
=****-:****=.*****.+****.=****:-*++*-:##%%*.***** +****.=****-:****+
+####=-####*.####%.####%.*####-=####+:@@@@@.%###%.#####:+####=-%%###
-====:.====- ===== =====.-====::====:.++++= ===== =====.-====:.+===-
=*++*-:*++*=.*++**.*****.=++**:-#*+*=.*++*+.%%%%% +++**:=****-:#**++
*%###=-%###*.%###%.%###%.*####-=%###+:%####.@@@@@.#####:+####=-%%###
-====:.====- ===== ===== -====.:====:.====- +++++ -====.:====:.====-
=#***-:#*+*+.#****.*****.+#+**:-****=.#***+.*****.*%%%%:=****-:#***+
+%###=-%###*.%###%.%%##%.*%###-=####+:%####.%###%.%@@@@:+####=-%%###
-====:.==-=- ===== ===== -=-==.:====:.====- ===== =++++.:====:.====-
=#***-:#***+.#****.*#***.+#***:-#***=.#***+.*****.*#***:+%%%%-:##**+
+%###=-%###*.%###%.%%##%.*%*#%-=%###+:%####.####%.#%###:*@@@@=-%%###
-=--=:.=--=- ==-== ==-== -=--=.:=-==:.==-=- =-=== -====.-++++:.====-
=#--#-:#+:#+.#*:**.#-:##.+#*----+-#*=.#+:#+.==#*#.++#*#:-+***--%%%%#
+%==%=-%*:%*.%#-#%.%-:%#.*%#==-=*=%#+:%*:%#.++%#%.**###:=*%##=-@@@@%
:-..-..-:.-: --.-- -..-- :--....:.--: -:.-: ::--- ::---..:---..====-
• Track distances through time, both by general agreements in terms
of votes and by explicit support for proposals put forward by each
party.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
There are more things to come, I have received some good feedback on
the analysis and also suggestions that are very doable using the
dataset, exciting times.