Confusion matrices with uncertainty quantification, experiment aggregation and significance testing.
Project description
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:
- Getting Started: a collection of small tutorials to help new users get started
- How To: more expansive guides on how to achieve specific things
- Reference: in-depth information about how to interface with the library
- 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:
- Package management:
uv - Linting:
ruff - Static Type-Checking:
basedpyright - Documentation:
zensical - 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:
- 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.
- Tötsch, N., & Hoffmann, D. (2021). Classifier uncertainty: evidence, potential impact, and probabilistic treatment. PeerJ Computer Science, 7, e398.
- Kruschke, J. K. (2013). Bayesian estimation supersedes the t test. Journal of Experimental Psychology: General, 142(2), 573.
- 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.
- Hill, T. (2011). Conflations of probability distributions. Transactions of the American Mathematical Society, 363(6), 3351-3372.
- 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}
}
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prob_conf_mat-0.4.0.tar.gz.
File metadata
- Download URL: prob_conf_mat-0.4.0.tar.gz
- Upload date:
- Size: 1.7 MB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f664da6432534ecb61146aa8331d46ce2ee7ed8ebaa4d6814f6d5742731ef03
|
|
| MD5 |
bfbffb61567f15c85c6310aeff634d15
|
|
| BLAKE2b-256 |
fadc0136d662df77ad0ecd6eb049ba7ed44547dae1bc4e2d612465cefa848547
|
File details
Details for the file prob_conf_mat-0.4.0-py3-none-any.whl.
File metadata
- Download URL: prob_conf_mat-0.4.0-py3-none-any.whl
- Upload date:
- Size: 95.5 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ea81ca49e23c0c490178dfca8f5efc278e0485e65f5d0916176e5066f83015d
|
|
| MD5 |
b01178c137b000811cd9b37d776fc77a
|
|
| BLAKE2b-256 |
6e5770039797547800ded0c421365b6629611cf4cbf4544d91a3cb5dc29c5ca6
|