Skip to main content
Logo

Probabilistic Confusion Matrices

prob_conf_mat is a Python package for performing statistical inference with confusion matrices. It quantifies the amount of uncertainty present, aggregates semantically related experiments into experiment groups, and compares experiments against each other for significance.

Installation

Installation can be done using from pypi can be done using pip:

pip install prob_conf_mat

Or, if you're using uv, simply run:

uv add prob_conf_mat

The project currently depends on the following packages:

Dependency tree
prob-conf-mat
├── jaxtyping
├── matplotlib
├── numpy
├── scipy
└── tabulate

Additionally, pandas is an optional dependency for some reporting functions.

Development Environment

This project was developed using uv. To install the development environment, simply clone this github repo:

git clone https://github.com/ioverho/prob_conf_mat.git

And then run the uv sync --dev command:

uv sync --dev

The development dependencies should automatically install into the .venv folder.

Quick Start

from prob_conf_mat import Study

study = Study(seed=0, num_samples=10000, ci_probability=0.95)

study.add_experiment(
  experiment_name="baseline",
  confusion_matrix=[[50, 2, 1], [3, 45, 4], [0, 5, 40]]
)

study.add_metric("f1@macro")

print(study.report_metric_summaries(metric="f1@macro", table_fmt="github"))
Group Experiment Observed Median Mode 95.0% HDI MU Skew Kurt
baseline baseline 0.8992 0.9001 0.9043 [0.8507, 0.9448] 0.0941 -0.4361 0.3485

Rather than a single point estimate, you get a distribution of plausible macro F1 score, which we summarize using a variety of statistics.

See the Getting Started tutorials and the worked-example notebooks in docs/getting_started/examples for more.

Documentation

For more information about the package, motivation, how-to guides and implementation, please see the documentation website. We try to use Daniele Procida's structure for Python documentation.

The documentation is broadly divided into 4 sections:

  1. Getting Started: a collection of small tutorials to help new users get started
  2. How To: more expansive guides on how to achieve specific things
  3. Reference: in-depth information about how to interface with the library
  4. Explanation: explanations about why things are the way they are
Learning Coding
Practical Getting Started How-To Guides
Theoretical Explanation Reference

Development

This project was developed using the following (amazing) tools:

  1. Package management: uv
  2. Linting: ruff
  3. Static Type-Checking: basedpyright
  4. Documentation: zensical
  5. Pre-commit: prek

Most of the common development commands are included in ./Makefile. If make is installed, you can immediately run the following commands:

Usage:
  make <target>

Utility
  help             Display this help
  hello-world      Tests uv and make
  clean            Clean up caches and build artifacts

Environment
  install          Install default dependencies
  install-dev      Install dev dependencies
  upgrade          Upgrade installed dependencies
  export           Export uv to requirements.txt file

Testing, Linting, Typing & Formatting
  test             Runs all tests
  coverage         Checks test coverage
  lint             Run linting
  type             Run static typechecking
  commit           Run pre-commit checks
  commit-log       Run pre-commit checks in verbose mode and log output to external file

Documentation
  docs-build       Update the docs
  docs-serve       Serve documentation site

Credits

The following are some packages and libraries which served as inspiration for aspects of this project: arviz, bayestestR, BERTopic, jaxtyping, mici, , python-ci, statsmodels.

A lot of the approaches and methods used in this project come from published works. Some especially important works include:

  1. Goutte, C., & Gaussier, E. (2005). A probabilistic interpretation of precision, recall and F-score, with implication for evaluation. In European conference on information retrieval (pp. 345-359). Berlin, Heidelberg: Springer Berlin Heidelberg.
  2. Tötsch, N., & Hoffmann, D. (2021). Classifier uncertainty: evidence, potential impact, and probabilistic treatment. PeerJ Computer Science, 7, e398.
  3. Kruschke, J. K. (2013). Bayesian estimation supersedes the t test. Journal of Experimental Psychology: General, 142(2), 573.
  4. Makowski, D., Ben-Shachar, M. S., Chen, S. A., & Lüdecke, D. (2019). Indices of effect existence and significance in the Bayesian framework. Frontiers in psychology, 10, 2767.
  5. Hill, T. (2011). Conflations of probability distributions. Transactions of the American Mathematical Society, 363(6), 3351-3372.
  6. Chandler, J., Cumpston, M., Li, T., Page, M. J., & Welch, V. J. H. W. (2019). Cochrane handbook for systematic reviews of interventions. Hoboken: Wiley, 4.

Citation

@software{ioverho_prob_conf_mat,
    author = {Verhoeven, Ivo},
    license = {MIT},
    title = {{prob\_conf\_mat}},
    url = {https://github.com/ioverho/prob_conf_mat}
}

Metadata

Release files for prob-conf-mat 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prob-conf-mat 0.4.0
File Size Uploaded Provenance Actions
prob_conf_mat-0.4.0.tar.gz 1.7 MB Without provenance Details for prob_conf_mat-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prob-conf-mat 0.4.0
File Interpreter ABI Platform Actions
prob_conf_mat-0.4.0-py3-none-any.whl Python 3 none any Details for prob_conf_mat-0.4.0-py3-none-any.whl

Total release size: 1.7 MB

Release files / prob_conf_mat-0.4.0.tar.gz

Download URL prob_conf_mat-0.4.0.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
8f664da6432534ecb61146aa8331d46ce2ee7ed8ebaa4d6814f6d5742731ef03
BLAKE2b-256 checksum
How to use checksums
fadc0136d662df77ad0ecd6eb049ba7ed44547dae1bc4e2d612465cefa848547
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / prob_conf_mat-0.4.0-py3-none-any.whl

Download URL prob_conf_mat-0.4.0-py3-none-any.whl
Size 95.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ea81ca49e23c0c490178dfca8f5efc278e0485e65f5d0916176e5066f83015d
BLAKE2b-256 checksum
How to use checksums
6e5770039797547800ded0c421365b6629611cf4cbf4544d91a3cb5dc29c5ca6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for prob-conf-mat 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page