Skip to content

Jmilk3/UCS_Voting_Repo

Repository files navigation

UCS_Voting_Repo

A repository that stores the programs used to examine and analyze how election results might change with different methods of Proportional Representation. This is part of the UCS voting project, meant to help inform people about Proportional Representation, examining different methods and how they might influence the outcome of elections.

See our report on our findings here: LINK TO REPORT

Navigating the Repository

This repository contains the input data we used for our simulations, the results of those simulations, and the code we used to run the simulations. The following subsections will explain where different things are located and how they are organized.

Input Data

The data we used for running ER and defining our simulations can be found in the folders 'Raw Data' and 'Clean Data'.

The 'Raw Data' folder contains the complete data files that we downloaded from the North Carolina election website and from the ACS website. We converted most of this data from a tab seperated format to a comma seperated format, but the data is otherwise unmodified. The data in this folder is organized into subfolders by what type of data it is.

The 'Clean Data' folder contains the cleaned and seperated data files which we acutally used as inputs for ER and our simulations. The data is organized by type and location. Of particular note is the subfolder named 'Merged Education and Income Shapefiles', which contains an intermediate form of the education and income data we used. This data was generated by merging precinct shapefiles with county level demographic data, so we included it in its complete form in addition to the final form we used.

Results

The results of our work can be found in the folders 'ER_Results' and 'Simulation_Results'.

The 'ER_Results' folder contains the output generated by running Beysian ER on our various contests and candidates with each of our demographics of interest. These results are organized by city, and are available as an ER graph or as a text output.

The 'Simulation_Results' folder contains the output csv files generated by our simulation program. Each simulation produced three ballot files and three election result files, one for each of the ballot generators we used. These files are seperated by city, and have the election and the demographic group in their name. The files in the Orignal Test Set folder are from an arbitrary set of simulation parameters which we used to test the functionallity of the simulation code, and can safely be ignored when evaluating our results.

Code

The 'Code' folder stores all of the code for this project. The code is split by purpose, with a subfolder for cleaning our data, a subfolder for running ER, and a subfolder for defining and running simulations. Please note that in the process of making the repository easier to navigate, we moved a lot of our csv files around. Any csv that is named in a script is still present in the repository, but the file path may no longer be correct. Please update the file paths of any existing file prior to using the code. It is also worth noting that many functions will output all files in the same place. These output files will need to be sorted manually after being generated.

Running the Code

Setting up the Python environment

We used Anaconda to install and manage packages. The following instructions explain how to setup the environment so that you can run our code locally.

  1. Install the Anaconda distribution from https://www.anaconda.com/. You will need to make an account or sign in with google in order to download it.
    • You can use either miniconda or the full distribution. The full distribution will let you create environments more quickly but will take longer to install and uses more memory.
  2. Open the Anaconda terminal, or activate Anaconda in your default terminal
  3. Navigate to the UCS Voting repo folder, where the environment.yaml file is stored.
  4. Run the command "conda env create --name UCS_Voting --file environment.yaml" in your terminal
  5. Activate the environment with the command "conda activate UCS_Voting", then you can run our python scripts from the command line

A Note on calculating simulation parameters

In order to calculate simulation parameters from ER results, we used the following method:

  • The bloc names are defined as the demographic being studied and other voters
  • The bloc size is the fraction of the population belonging to each demographic
  • The candidates are assigned to whichever bloc had a larger percentage of votes for them. If all of the candidates have more support from a given bloc, the candidate with the lowest percentage is assigned to the other bloc
  • For each candidate, the preference values are given as a pair of values defining the lower and upper bounds of the confidence interval from the ER results for the bloc's support of that candidate. In each iteration, we sample a value from this range for each candidate, then normalize the values to get the set of preferences for that iteration.
  • The number of seats is set to the number of seats up for election in the actual contest.
  • The number of ballots is set to 1000, as this provides a good mix of runtime and accuracy.

About

A repository that stores the programs used to examine and analyze how election results might change with different methods of Proportional Representation. This is part of the UCS voting project, meant to help inform people about Proportional Representation, examining different methods and how they might influence the outcome of elections.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages