Skip to main content

Redistricting ensembles

Project description

rdaensemble

Redistricting ensembles

Methods

This project supports several methods for generating ensembles of redistricting plans:

  • Random maps from random spanning trees (RMfRST)
  • Random maps from random starting points (RMfRSP)
  • ReCom -- TODO
  • Sequential Monte Carlo (SMC) -- TODO

Input Files

The inputs for generating & scoring ensembles are:

from rdascore import load_data, load_shapes, load_graph, load_metadata

data: Dict[str, Dict[str, int | str]] = load_data(data_path)
shapes: Dict[str, Any] = load_shapes(shapes_path)
graph: Dict[str, List[str]] = load_graph(graph_path)
metadata: Dict[str, Any] = load_metadata(state_code, data_path)

The precinct data, shapes, and graphs are all available in the companion repository rdabase in the data directory by state. They are named NC_2020_data.csv, NC_2020_shapes_simplified.json, and NC_2020_graph.json, for example.

Theoretically, these inputs can come from any source, but for simplicity, reproducibility, and apples-to-apples comparisons, it's best to use the input files in rdabase.

Output Files

Ensembles are saved as JSON files. A file contains metadata about the ensemble, including the method used to generate it, and then a plans key with a list of plans:

plans: List[Dict[str, str | float | Dict[str, int | str]]]

Each plan item has a name (str), an optional weight (float), and a plan (Dict[str, int | str]]) which represents the assignments as geoid: district_id key: value pairs.

Scores for the plans in an ensemble are saved as a CSV file, with one row per plan and one column per metric. The metrics are the same as those produced by rdatools/rdascore, except they also include the energy of the plan. The metric names are descriptive.

There is also a companion JSON file with metadata about the scores.

Naming Conventions

You can name ensemble and score files anything you want. To facilitate understanding the contents of these files without having to open them, we recommend the following the convention:

  • Ensemble example: NC20C_RMfRST_1000_plans.json
  • Scores example: NC20C_RMfRST_1000_scores.csv

where "NC" is the state code, "20" stands for the 2020 census cycle, "C" abbreviates "Congress" (as opposed to state upper or lower house), "RMfRST" is the method, 1000 is the number of plans in the ensemble, and "plans" and "scores" distinguish between the two types of files.

Note: The scores metadata file will be named the same as the scores file, except it will end _metadata.json instead of .csv, for example, NC20C_RMfRST_1000_scores_metadata.json.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rdaensemble-1.0.5.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

rdaensemble-1.0.5-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file rdaensemble-1.0.5.tar.gz.

File metadata

  • Download URL: rdaensemble-1.0.5.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for rdaensemble-1.0.5.tar.gz
Algorithm Hash digest
SHA256 01b63cf129de15719e5ea72f862bc63c3ae043167dfad4f22be9a4a4d6ca91f7
MD5 2d3e5adc4a3bfd5392f05c2812fbf1d0
BLAKE2b-256 ceea106c39b363d7abcb1ee17b45bd1517efc60dd254e3ab84e4187795f11043

See more details on using hashes here.

File details

Details for the file rdaensemble-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: rdaensemble-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for rdaensemble-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8cfb739d3c31b26699f536eb60d40d22d622d511d4be3bfa486ec26ab8ec848f
MD5 36ccaa2c1b786b1e305dfbdff85f2735
BLAKE2b-256 0e22780847eaa0bf5d50a04b001156fda78bdac217d9b8fe47185fc7c2fa7ce4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page