Implemenation of the Pokie from Sharief et al. 2025
Project description
Pokie: Posterior Accuracy and Model Comparison
Pokie is a Python package for evaluating the calibration and accuracy of posterior distributions through a sample-based, likelihood-free method. It enables Bayesian model comparison in simulation-based settings where the true posterior is unknown and standard metrics fail.
How Pokie Works
- Select a Ground Truth
- Pick a truth sample $y^*_{j} \sim p(y | x^*, \mathcal{M}^*)$
- Draw Posterior Samples
- Draw N samples ${ y_{i,j} }_{i=1}^N \sim p(y | x^*, \mathcal{M})$
- Repeat for Lr Random Regions:
- Sample a random center $c_{j,\ell} \in \mathbb{R}^q$
- Select a random posterior sample to define a radius: $r_{j,\ell} = | c_{j,\ell} - y_{i,j} |$
- Define a region $\mathcal{R}{j,\ell}$ as the hypersphere around $c_{j,\ell}$ with radius $r_{j,\ell}$
- Count Points
- Count how many posterior samples fall into the region: $n = \sum_i \mathbf{1}[y_{i,j} \in \mathcal{R}_{j,\ell}]$
- Check if the ground-truth sample falls inside: $k = \mathbf{1}[y^*j \in \mathcal{R}_{j,\ell}]$
- Update Score
if k == 1:
score += (n + 1) / (N + 2)
else:
score += (N - n + 1) / (N + 2)
- Final Pokie Score: $P_{\text{Pokie}}(\mathcal{M}) = \frac{\texttt{score}}{L \cdot L_r}$
Interpretation
- Well-calibrated posterior → Pokie score → ≈ 2/3
- Misaligned posterior → Pokie score → ≈ 1/2
Example Usage
import torch
from pokie import pokie
# Ground truth parameters (T samples in q-dim)
truth = torch.randn(T, q)
# Posterior samples from M models (M, T, S, q)
posterior = torch.randn(M, T, S, q)
# Run Pokie
score = pokie(truth, posterior, num_runs=100)
print(score) # Pokie scores for each model
Developing
If you're a developer then:
git clone git@github.com:SammyS15/Pokie.git
cd Pokie
git checkout -b my-new-branch
pip install -e .
But make an issue first so we can discuss implementation ideas.
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pokie_score-0.1.7.dev0.tar.gz.
File metadata
- Download URL: pokie_score-0.1.7.dev0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
341fdf8eb7d25713d2ef7832a64366cd854819a6ab416a326514ef00165c9510
|
|
| MD5 |
3b5dfaf8c96c674590b59851482a825b
|
|
| BLAKE2b-256 |
cd558dc03b1899c216b45ef6b584acd00ee692f77feb93652da12f869d5dd250
|
File details
Details for the file pokie_score-0.1.7.dev0-py3-none-any.whl.
File metadata
- Download URL: pokie_score-0.1.7.dev0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f3453f8e80ca5bcb6cd1a8315e58a7a3bf01ce1ba4bcef4e5c7a34dfa5dbf49
|
|
| MD5 |
3c644c2eceef1371806fef86b33945a6
|
|
| BLAKE2b-256 |
7393cae246f9828d0db8eefa334b95714b9a03b1c0805dc0ce2f091ce0a46945
|