Skip to main content

Politcal science appointment and analysis in Python

Project description


PyPI Version Python Version GitHub

Politcal science appointment and analysis in Python

Jump to: AppointmentTo-Do

poli-sci-kit is a Python package for politcal science appointment and election analysis.

Installation via PyPi

pip install poli-sci-kit
import poli_sci_kit

Appointment

appointment/methods includes functions to allocate parliamentary seats based on population or vote shares. Along with deriving results for visualization and reporting, these functions allow the user to analyze outcomes given systematic or situational changes. The appointment/metrics module further provides diagnostics to analyze the results of elections, apportionments, and other politcal science scenarios.

An example of political appointment using poli-sci-kit is:

from poli_sci_kit import appointment

vote_counts = [250, 150, 100, 85, 75, 25]
seats_to_allocate = 50

# Huntington-Hill is the method used to allocate House of Represenatives seats to US states
ha_allocations = appointment.methods.highest_average(averaging_style='Huntington-Hill',
                                                     shares=vote_counts, 
                                                     total_alloc=seats_to_allocate, 
                                                     alloc_threshold=None, 
                                                     min_alloc=1, 
                                                     tie_break = 'majority', 
                                                     majority_bonus=False, 
                                                     modifier=None)

ha_allocations
# [18, 11, 7, 6, 6, 2]

# The Gallagher method is a measure of absolute difference similar to summing square residuals
disproportionality = appointmentmetrics.dispr_index(shares=vote_counts, 
                                                    allocations=ha_allocations, 
                                                    mertric_type='Gallagher')

disproportionality
# 0.01002

To-Do

  • Checks for the appointment method implementations
  • Creating and improving examples

References

Full list of references

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

poli_sci_kit-0.0.2-py3-none-any.whl (37.3 kB view hashes)

Uploaded Python 3

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