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.4.dev0.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.4.dev0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pokie_score-0.1.4.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

Hashes for pokie_score-0.1.4.dev0.tar.gz
Algorithm Hash digest
SHA256 b81fff38b23bbef165cc72d48bbffebd268694445b1709cbad46f9068b3cb0cb
MD5 f3be76648030b8ee203366b1e1ad728f
BLAKE2b-256 7b5d05da40eea58240506971c8e42840d1bd15e480fd49e336e19b065d1cd75c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pokie_score-0.1.4.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 08e99813b552bb1af5b7549dd6c7f2b6721049402efcb601cdd34bf066d9a650
MD5 29cd3d576b79c9ea7ded79520878ec15
BLAKE2b-256 0df1adf0efdf2aeb819cb180461d924c1930b64c05b16f3043001cef246a7bf1

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