flynn.gg

Christopher Flynn

Machine Learning
Systems Architect,
PhD Mathematician

Home
Projects
Open Source
Blog
Résumé

GitHub
LinkedIn

Blog


Voting Python package

2018-01-08 Feed

A little over a year ago, when I was working for Zynga on slots casino apps, I had spent a bit of time studying measures of disproportionality. The purpose was to create some measure of so-called whale behavior with respect to daily in-app purchase revenue. These heavy spenders, or whales, make up a significant proportion of revenue each day so I wanted some kind of metric to understand how much of our purchases were driven by whales, and how our day-to-day liveops decisions influenced whale behavior.

whales

I came up with a few clever metrics, which I won’t mention here, but along the way came across several measures of disproportionality that attempt to do the same thing. These metrics are typically applied to politics and democratic representation in legislation and government in general.

I was reading a bit about them again recently and learned that there are a few other simple metrics for measuring related concepts such as political diversity, calculating election quotas, and various algorithms for apportioning electoral seats across groups of voters. Putting all of these together would make a nice simple library containing these political calculations.

I did a bit of searching and didn’t find any that existed in Python. The only thing I could find was a library in R that did a few of these things.

The library I put together is called voting which is now on pypi. It’s written in pure Python and can be used with Python 2 or 3. Within the package are submodules for:

The library is simple, function-based and meant to be very easy to use. Check the documentation for more information and details on included functions and algorithms.

Further reading

Voting

Apportionment methods

Diversity measures

Disproportionality measures

Election quotas

Python Package Index

Back to the posts.