Politcal science appointment and analysis in Python
Project description
Politcal science appointment and analysis in Python
Jump to: Appointment • To-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 = appointment.metrics.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
- https://github.com/crflynn/voting
- https://blogs.reading.ac.uk/readingpolitics/2015/06/29/electoral-disproportionality-what-is-it-and-how-should-we-measure-it/
- Balinski, M. L., and Young, H. P. (1982). Fair Representation: Meeting the Ideal of One Man, One Vote. New Haven, London: Yale University Press.
- Karpov, A. (2008). "Measurement of disproportionality in proportional representation systems". Mathematical and Computer Modelling, Vol. 48, pp. 1421-1438. URL: https://www.sciencedirect.com/science/article/pii/S0895717708001933.
- Kohler, U., and Zeh, J. (2012). “Apportionment methods”. The Stata Journal, Vol. 12, No. 3, pp. 375–392. URL: https://journals.sagepub.com/doi/pdf/10.1177/1536867X1201200303.
- Taagepera, R., and Grofman, B. (2003). "Mapping the Indices of Seats-Votes Disproportionality and Inter-Election Volatility". Party Politics, Vol. 9, No. 6, pp. 659–677. URL: https://escholarship.org/content/qt0m9912ff/qt0m9912ff.pdf.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for poli_sci_kit-0.0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c0f5086048f283e8b81f0bd83d6ebb9281fa79650ea5e84ec463ed4cd457c0f |
|
MD5 | a71122b5331ea9ad403a32c88a8b1e7c |
|
BLAKE2b-256 | 1b045e0aceead46b125979c00fce826fe6d8115d54d4079d16c89aef56178fc9 |