Skip to main content

Predikon: Sub-Matrix Factorization for Real-Time Vote Prediction

Project description

Predikon

Sub-Matrix Factorization for Real-Time Vote Prediction

Build Status Coverage Status PyPI Downloads

The predikon library is the Python library for the algorithm proposed in

Alexander Immer*, Victor Kristof*, Matthias Grossglauser, Patrick Thiran, Sub-Matrix Factorization for Real-Time Vote Prediction, KDD 2020

The predikon algorithm enables you to predict aggregate vote outcomes (e.g., national) from partial outcomes (e.g., regional) that are revealed sequentially. See the usage documentation more details on how to use this library or read the paper linked above for more details on how the algorithm works.

It is the algorithm powering predikon.ch, a platform for real-time vote prediction in Switzerland.

Installation

To install the Predikon library from PyPI, run

pip install predikon

Getting Started

Given a dataset Y of historical vote results collected in an array of R regions and V votes, given a vector y of partial results, and given an optional weighting w per region (e.g., the number of valid votes in each region), it is easy to predict the unobserved entries of y after observing at least one regional result (one entry of y) of an ongoing referendum or election:

from predikon import LogisticSubSVD
model = LogisticSubSVD(Y, w)
pred = model.fit_predict(y)
# All unobserved entries in `y` are now filled in.

You can then obtain a prediction for the aggregate outcome (assuming the weights are the number of valid votes in this example) as:

N = w.sum()  # Total number of votes.
ypred = pred.dot(w) / N
ytrue = y.dot(w) / N
print(abs(ypred - ytrue))

Have a look at the example notebook for a complete example of how to use the predikon library (with Swiss referenda).

Going Further

You can find further information in:

And don't hesitate to reach out us if you have questions or to open issues!

Requirements

Project details


Download files

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

Source Distribution

predikon-0.3.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

predikon-0.3-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file predikon-0.3.tar.gz.

File metadata

  • Download URL: predikon-0.3.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for predikon-0.3.tar.gz
Algorithm Hash digest
SHA256 84651fb2e6b2eb59f805a2fe3577a52824c56c5aaaa343d2ca797d9953f3e995
MD5 9c7579c0d17f9535e61ae061c3ceb1ca
BLAKE2b-256 26e863502e23b012e9b6513f1ee0758050d27c28ee015ea0147d64bd82c578d5

See more details on using hashes here.

File details

Details for the file predikon-0.3-py3-none-any.whl.

File metadata

  • Download URL: predikon-0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for predikon-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3724a83076db51f7901c48d8fb8756dfbe8028335dae8b7867904fbf320a0b76
MD5 3febc94d3b1a8a365d4651b287118f67
BLAKE2b-256 669186fa11ef5ce375939fa6d066893167369ed38441d599773673715b5f0c61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page