Skip to content

microraptor/wahlomat_analysis

Repository files navigation

Wahl-O-Mat Analysis

This script analyses www.wahl-o-mat.de German political party data.

It generates a correlation matrix and a principal component analysis map, where also clusters are marked. This project is inspired by Reddit users /u/d_loose/ and /u/askLubich/. Pull request and other improvements are welcome.

Bundestagswahl 2021

Correlation Matrix    Principal Component Analysis    Principal Component Influences

Click on the plots to see them in full size.

Explanation

For an overview of how to interpret the analysis check out askLubich's repo or his German explanation.

Interestingly, the first principal component (PC1), which is plotted on the X-axis, usually corresponds mostly to the common left and right wing classification. PC2 on the Y-axis can often be partly interpreted as how authoritarian a party is.

Running the Script

Binder

You can open the notebook in your browser by clicking the badge above. Then you can click the run button repeatedly to run each cell. It takes a moment for the plots to pop up. Similarly, you can also run the whole thing on Google's cloud: Google Colaboratory

The .py and .ipynb files in this repo do the same thing and have almost identical code.

Dependencies for Local Execution

See requirement.txt or environment.yml.

Installing the Dependencies

This script requires to have Python 3.8+.

pip install -r requirements.txt
# On Ubuntu:
pip3 install -r requirements.txt

Alternatively, with Anaconda (Replace base with your environment of choice):

conda env update -n base --file environment.yml