rdaensemble
Redistricting ensembles
Installation
To clone the repository:
$ git clone https://github.com/rdatools/rdaensemble
$ cd rdaensemble
To run the scripts, install the dependencies:
pip install -r requirements.txt
To install the package in another project:
$ pip install rdaensemble
Usage
To generate an ensemble of plans, use one of the *_ensemble.py scripts:
rmfrst_ensemble.pyfor Random Maps from Random Spanning Trees (RMfRST)rmfrsp_ensemble.pyfor Random Maps from Random Starting Points (RMfRSP)recom_ensemble.pyfor ReCom
There are example calls in each file. Note: The resulting ensemble JSON files can be quite large--bigger than GitHub's 100 MB file size limit-- so we recommend that you write them to a directory which is not under source control.
To score the plans in an ensemble, use the score_ensemble.py script.
The other scripts are specific to our "trade-offs in redistricting" project and are not generally useful.
Notes
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
rdatools/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.
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.
When a scores CSV file is produced, a companion JSON file with metadata about the scoring is also generated.
Metadata
Release files for rdaensemble 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rdaensemble-2.0.2.tar.gz | 19.8 kB | Without provenance | Details for rdaensemble-2.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rdaensemble-2.0.2-py3-none-any.whl | Python 3 | none | any | Details for rdaensemble-2.0.2-py3-none-any.whl |
Total release size: 44.9 kB
Release files / rdaensemble-2.0.2.tar.gz
| Download URL | rdaensemble-2.0.2.tar.gz |
|---|---|
| Size | 19.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2631e258ab59bf2b3d24fc31849241bd548865fbc3f4d837d62f65066e1d24b0
|
|
BLAKE2b-256 checksum How to use checksums |
f7d490693e53ac537226e610a70623bdcf85cffddc79dd8bec34601f747df946
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / rdaensemble-2.0.2-py3-none-any.whl
| Download URL | rdaensemble-2.0.2-py3-none-any.whl |
|---|---|
| Size | 25.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
21af7a39318374a3a3a92d100b3a99c8821b0277d21e8e6aca2e84884466d1a2
|
|
BLAKE2b-256 checksum How to use checksums |
ceb1bb7c7bb03312799fb780183f1689d82ebbe066353bda35733ff28a1106e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Security for rdaensemble 2.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.