Skip to main content

A library for statistical model comparison using bootstrap.

Project description

StaMBO: Statistical model comparison with bootstrap

DOI Tests PyPI version docs License

This package is aimed to be a one-stop-shop for statistical testing in machine learning when it comes to evaluating models on a test set and comparing whether our improved model is really beating the baseline. That is, we cover the following very typical use-case in machine learning: usecase

Currently, we support the cases of classification, regresson, and semantic segmentation. We do not yet support the significance of ranking, as well as grouped data. It is coming in the future releases.

In practice

Install from PyPI:

pip install stambo

The use of the library is then straightforward:

import stambo
...
seed = 42
testing_result = stambo.compare_models(y_test, preds_1, preds_2, metrics=("ROCAUC", "AP", "QKappa", "BACC", "MCC"), seed=seed)
print(stambo.to_latex(testing_result))

The above will print a LaTeX table, which one can easily copy-paste. As an example, below is the rendered table, which was returned in notebooks/Classification.ipynb (Binder): Table

Note: From version 0.1.5 we support block-diagonal structure of the data. That is, if you have data from the same patient in the test set, it can easily be adjusted for by specifying the groups argument.

The regression example can be found at notebooks/Regression.ipynb (Binder )

For more advanced explanation, see the documentation. By default, binary, multi-class, and multi-label classification, as well as regression are supported.

One can also use the library to perform a simple two-sample test. For example, to compare the means of two distributions:

import stambo
...
seed = 42
res = stambo.two_sample_test(sample_1, sample_2, statistics={"Mean": lambda x: x.mean()})

A more detailed and full example of the above is shown here: notebooks/Two_sample_test.ipynb (Binder)

Contributing

To setup a dev environment, you should use uv and install the project as follows:

uv venv
uv pip install -e ".[dev]"

Author

Dr. Aleksei Tiulpin, PhD

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

stambo-0.1.5.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stambo-0.1.5-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file stambo-0.1.5.tar.gz.

File metadata

  • Download URL: stambo-0.1.5.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for stambo-0.1.5.tar.gz
Algorithm Hash digest
SHA256 2aee3a50b6fe39ab503c786fb4f40ef9920e384efd7f1b368d13fb212a2a32c9
MD5 8924abf3dc542631ab0c002d192e66c6
BLAKE2b-256 6d7a5d6ef85d9321e65d35ed58f83d650c3e954743e5010bcd0e4ce8a35e6e8d

See more details on using hashes here.

File details

Details for the file stambo-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: stambo-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for stambo-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 59fe798e4ca140960e356ebde7b0a5f81b99885c6c169a808b2d263b629f46f8
MD5 bb26ee1dcbabb223be7b053516ec9aea
BLAKE2b-256 8275db50a607de26ced762d7e0752dcbf7ebd88ec5f33b06259370661171e708

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