Implemenation of the PQMass two sample test from Lemos et al. 2024
Project description
PQMass: Probabilistic Assessment of the Quality of Generative Models using Probability Mass Estimation
Implementation of the PQMass two sample test from Lemos et al. 2024 here
Install
Just do:
pip install pqm
Usage
This is the main use case:
from pqm import pqm_pvalue, pqm_chi2
import numpy as np
x_sample = np.random.normal(size = (500, 10))
y_sample = np.random.normal(size = (400, 10))
# To get pvalues from PQMass
pvalues = pqm_pvalue(x_sample, y_sample, num_refs = 100, re_tessellation = 50)
print(np.mean(pvalues), np.std(pvalues))
# To get chi^2 from PQMass
chi2_stat = pqm_chi2(x_sample, y_sample, num_refs = 100, re_tessellation = 50)
print(np.mean(chi2_stat), np.std(chi2_stat))
If your two samples are drawn from the same distribution, then the p-value should be drawn from the random uniform(0,1) distribution. This means that if you get a very small value (i.e., 1e-6), then you have failed the null hypothesis test, and the two samples are not drawn from the same distribution.
For the chi^2 metric, given your two sets of samples, if they come from the same distribution, the histogram of your chi² values should follow the chi² distribution. The peak of this distribution will be at DoF - 2, and the standard deviation will be √(2 * DoF). If your histogram shifts to the right of the expected chi² distribution, it suggests that the samples are out of distribution. Conversely, if the histogram shifts to the left, it indicates potential duplication or memorization (particularly relevant for generative models).
Developing
If you're a developer then:
git clone git@github.com:Ciela-Institute/PQM.git
cd PQM
git checkout -b my-new-branch
pip install -e .
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
File details
Details for the file pqm-0.4.0.tar.gz
.
File metadata
- Download URL: pqm-0.4.0.tar.gz
- Upload date:
- Size: 288.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d2d33d4841c6ca3b0a1a39f5d3cfc34560d9aa5a0c0f054f6cf492ed85c0cb3 |
|
MD5 | cecd44fb00c3bb3d67ef166bb72b4b6c |
|
BLAKE2b-256 | 237bcb1bfeb234789674cccd610d32a9dadfad667eb05d98e602f0264257e609 |
File details
Details for the file pqm-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: pqm-0.4.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be671abd6fbdfa5de7a4ed4f9efacdfb9c986ed11fb07a628ae0590783453fd6 |
|
MD5 | 373be7d155f0751f1d682e5bc866ff0f |
|
BLAKE2b-256 | d63bf05d6353a3cace8e8ed77faa00ba8daa8d4f2833f3612600afdd1dbe2b95 |