Skip to main content

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

Metadata

Release files for predikon 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for predikon 0.4
File Size Uploaded Provenance Actions
predikon-0.4.tar.gz 8.3 kB Without provenance Details for predikon-0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for predikon 0.4
File Interpreter ABI Platform Actions
predikon-0.4-py3-none-any.whl Python 3 none any Details for predikon-0.4-py3-none-any.whl

Total release size: 17.0 kB

Release files / predikon-0.4.tar.gz

Download URL predikon-0.4.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a20194a3078894c2ded94668dab3812434b72eafd3d8c15fee4c983f5d5ead55
BLAKE2b-256 checksum
How to use checksums
acf0b6dd36f28b47dadf88bef71732fc51a9ace40b76bc585598b60aa91dce92
Upload date
Uploaded using Trusted Publishing?
What is 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.59.0 CPython/3.9.2

Release files / predikon-0.4-py3-none-any.whl

Download URL predikon-0.4-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7733a832a731f2ed071c40609419b79eeca553598119a61e857bf7577b7c9e36
BLAKE2b-256 checksum
How to use checksums
a55d6be4b826316284b509e48abd65ebd3cc3ab009a08d0fa3436cc9497d576d
Upload date
Uploaded using Trusted Publishing?
What is 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.59.0 CPython/3.9.2

Security for predikon 0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page