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.1.dev9.tar.gz (8.5 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.1.dev9-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file pokie_score-0.1.1.dev9.tar.gz.

File metadata

  • Download URL: pokie_score-0.1.1.dev9.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for pokie_score-0.1.1.dev9.tar.gz
Algorithm Hash digest
SHA256 2010eb860d443b4775c8eefd4a9ce71fd0f46704db74441ba87e9bf15429bb61
MD5 5b74b23174efdb639046725e214a8256
BLAKE2b-256 9cd6f207d9fd15f7bce205f12da537c82b32aa99c23b6d4d7460496d3e42c744

See more details on using hashes here.

File details

Details for the file pokie_score-0.1.1.dev9-py3-none-any.whl.

File metadata

File hashes

Hashes for pokie_score-0.1.1.dev9-py3-none-any.whl
Algorithm Hash digest
SHA256 ab3d02464b59c9226abf3ee9a6db7e1a6e665600baa37c7fe36529bb744d7851
MD5 0947304402af28738646d987a5eae10d
BLAKE2b-256 7fd1eb49663b6ee24b1795d7ec199e1a2d3c90a30f5eeab1fc34e70150b28aff

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