• Stars
    star
    130
  • Rank 275,946 (Top 6 %)
  • Language
    Python
  • License
    Other
  • Created over 6 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use MCMC to analyze districting plans and gerrymanders

GerryChain

Build Status Code Coverage Documentation Status PyPI Package conda-forge Package

GerryChain is a Python library for building ensembles of districting plans using Markov chain Monte Carlo. It is developed and maintained by the Metric Geometry and Gerrymandering Group and our network of volunteers. It is distributed under the 3-Clause BSD License.

The basic workflow is to start with the geometry of an initial plan and generate a large collection of sample plans for comparison. Usually, we will constrain these sampled plans in such a way that they perform at least as well as the initial plan according to traditional districting principles, such as population balance or compactness. Comparing the initial plan to the ensemble provides quantitative tools for measuring whether or not it is an outlier among the sampled plans.

Getting started

See our Getting started guide for the basics of using GerryChain.

We also highly recommend the resources prepared by Daryl R. DeFord of MGGG for the 2019 MIT IAP course Computational Approaches for Political Redistricting.

Useful links

Installation

Using pip

To install GerryChain from PyPI, run pip install gerrychain from the command line.

If you plan on using GerryChain's GIS functions, such as computing adjacencies or reading in shapefiles, then run pip install gerrychain[geo] from the command line.

This approach sometimes fails due to compatibility issues between our different Python GIS dependencies, like geopandas, pyproj, fiona, and shapely. For this reason, we recommend installing from conda-forge for users that encounter difficulty with PyPI.

Using conda

To install GerryChain from conda-forge using conda, run

conda install -c conda-forge gerrychain

For this command to work as intended, you will first need to activate the conda environment that you want to install GerryChain in. If the environment you want to activate is called vrdi (for example), then you can do this by running

conda activate vrdi

If this command causes problems, make sure conda is up-to-date by running

conda update conda
conda init

For more information on using conda to install packages and manage dependencies, see Getting started with conda.

More Repositories

1

maup

The geospatial toolkit for redistricting data.
Jupyter Notebook
65
star
2

ohio-precincts

Shapefile of voting precincts in Ohio (as of 2016) merged with election returns
R
30
star
3

ecological-inference

Ecological inference, in Python
Jupyter Notebook
25
star
4

GerryChainJulia

A high-performance implementation of GerryChain in Julia
Julia
19
star
5

VoteKit

A Swiss Army Knife for computational social choice research
Python
9
star
6

DiscreteCompactness

Data and code for computing discrete compactness measures on congressional districts.
Python
6
star
7

TDA-redistricting

Applying persistent homology to redistricting
Jupyter Notebook
4
star
8

chicago

Data and code used in MGGG's Study of Reform Proposals for Chicago City Council.
Jupyter Notebook
4
star
9

covid-analysis

Supporting code and data for our Campus Coronavirus Response analysis
Jupyter Notebook
4
star
10

census-diff-privacy

Code for "Census TopDown: The Impacts of Differential Privacy on Redistricting"
Jupyter Notebook
4
star
11

gerrytools

Tools for evaluating districting plans.
Jupyter Notebook
3
star
12

rcv-webapp

A Web Application for simulating RCV elections and visualizing their impact on proportional representation
JavaScript
3
star
13

mggg.github.io

MGGG's website.
Mathematica
2
star
14

Alaska

Replication code and data for analyzing district pairings in Alaska
Jupyter Notebook
2
star
15

covid-scheduling

Models for assigning people to COVID surveillance testing schedules
Jupyter Notebook
2
star
16

mggg-states-qa

Jupyter notebook for mggg-states data quality assurance. Includes a Wikipedia election dataset creation notebook
Jupyter Notebook
2
star
17

pcompress

Efficient, streamable binary representation of districting plans intended for enabling fast interoperability between various ReCom MCMC impls and real-time step logging/replaying. Used for gerrymandering analysis.
Jupyter Notebook
2
star
18

benchmarks

Markov chain benchmarking (Mai Nguyen's 2021 GSoC project)
Julia
1
star
19

rcv

A Python package for tabulating ranked-choice elections.
Python
1
star
20

FairVote-FRA

Code and data for replicating results in the FairVote FRA study.
Python
1
star
21

gerrydb-client-py

Python client library for MGGG's redistricting analytics platform 🐍
Jupyter Notebook
1
star
22

capy

[WIP] Novel metrics to measure geospatial segregation
Python
1
star