The accompanying blog post can be found here .
Want to dive right in? Find the accompanying blog post Go directly to the Getting started section!
A guide on how to gain insight in socio-economic and election data of U.S. counties using the Mapper algorithm implemented in Giotto-learn. See the accompanying blog post for further details.
The socio-economic data has been taken from the U.S. Bureau of Economic Analysis (BEA). The voting data is provided by the MIT Election Data and Science Lab (MEDSL).
Our study shows that we can divide the counties into five main regions based on economic indicators:
- High net worth
- High net worth per inhabitant
- High per capita retirement
- Elevated and average net worth
- Low net worth
When combined with election results, we find that in 2016, the high per capita retirement, and low net worth regions are strongholds for the Republicans. The remaining three regions vote predominantly Democrat with an exception for some clusters of elevated and medium net worth counties.
1. Linux / MacOS
If you have pip
and anaconda installed, it suffices to run the following commands in a terminal:
conda create --name mapper python=3.7 && conda activate mapper
conda install jupyter -y
pip install -r requirements.txt
pip install python-igraph
2. Windows
You first have to download from here the wheel corresponding to your Python version and architecture. Then, you need to run the following commands in a terminal:
conda create --name mapper python=3.7 && conda activate mapper
conda install jupyter -y
pip install -r requirements.txt
pip install python_igraph‑0.7.1.post6‑cp{YOUR_PYTHON_VERSION}‑cp{YOUR_PYTHON_VERSION}‑win_amd64.whl
To see the Plotly graphs in JupyterLab, some extra steps are required:
1. Linux / MacOS
# Avoid "JavaScript heap out of memory" errors during extension installation
export NODE_OPTIONS=--max-old-space-size=4096
# Jupyter widgets extension
jupyter labextension install @jupyter-widgets/[email protected] --no-build
# FigureWidget support
jupyter labextension install [email protected] --no-build
# and jupyterlab renderer support
jupyter labextension install [email protected] --no-build
# Build extensions (must be done to activate extensions since --no-build is used above)
jupyter lab build
# Unset NODE_OPTIONS environment variable
unset NODE_OPTIONS
2. Windows
# Avoid "JavaScript heap out of memory" errors during extension installation
set NODE_OPTIONS=--max-old-space-size=4096
# Jupyter widgets extension
jupyter labextension install @jupyter-widgets/[email protected] --no-build
# FigureWidget support
jupyter labextension install [email protected] --no-build
# and jupyterlab renderer support
jupyter labextension install [email protected] --no-build
# Build extensions (must be done to activate extensions since --no-build is used above)
jupyter lab build
# Unset NODE_OPTIONS environment variable
set NODE_OPTIONS=
After running these steps, deactivate and reactivate your conda environment before spinning up JupyterLab.