Skip to main content

Implemenation of the Pokie from Sharief et al. 2025

Project description

Pokie: Posterior over k Inference Estimation

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

  1. Select a Ground Truth
  • Pick a truth sample $y^*_{j} \sim p(y | x^*, \mathcal{M}^*)$
  1. Draw Posterior Samples
  • Draw N samples ${ y_{i,j} }_{i=1}^N \sim p(y | x^*, \mathcal{M})$
  1. 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}$
  1. 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}]$
  1. Update Score
if k == 1:
    score += (n + 1) / (N + 2)
else:
    score += (N - n + 1) / (N + 2)
  1. 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


Download files

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

Source Distribution

pokie_score-0.1.2.dev0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

pokie_score-0.1.2.dev0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file pokie_score-0.1.2.dev0.tar.gz.

File metadata

  • Download URL: pokie_score-0.1.2.dev0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.18

File hashes

Hashes for pokie_score-0.1.2.dev0.tar.gz
Algorithm Hash digest
SHA256 10480e93046e9f0803457c1b312eb632be0bea482e17969c0f949b608de9b378
MD5 e1e58e4e603c5ca7c370395f396b9eb7
BLAKE2b-256 f27b8c1b9d3f79afc7e317cea2c58282aad7637485ca431db28004c30897837c

See more details on using hashes here.

File details

Details for the file pokie_score-0.1.2.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for pokie_score-0.1.2.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a7c83493845fe46c202c2e7786ad10e1c29372a580bad5b285c6bf8816cb5c3
MD5 6ddbcdb80a6d9b726b40c8d39e8cdb10
BLAKE2b-256 8e4cb8ab1812078b103a42539bd1b927185cb3375e2d97f17244d889a2648f5c

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