Skip to main content

roc-utils

image License CodeFactor DeepSource

This Python package provides tools to compute and visualize ROC curves, which are used to graphically assess the diagnostic ability of binary classifiers.

Use roc_utils to perform ROC analyses, including the calculation of the ROC-AUC (the area under the ROC curve) and the identification of optimal classification thresholds for different objective functions. In addition, it is possible to compute mean, tolerance interval (TI) and confidence interval (CI) for a set of (related) ROC curves. Finally, error bounds can be estimated and visualized by means of boostrap sampling.

Exemplary plots generated with roc_utils

Installation:

pip install roc-utils

Use the following commands for a quick verification of the installation.

python -c "import roc_utils; print(roc_utils.__version__)"
python -c "import roc_utils; roc_utils.demo_bootstrap()"

Usage:

See examples/tutorial.ipynb for step-by-step introduction.

import numpy as np
import matplotlib.pyplot as plt
import roc_utils as ru

# Construct a binary classification problem
x, y = ru.demo_sample_data(n1=300, mu1=0.0, std1=0.5,
                           n2=300, mu2=1.0, std2=0.7)

# Compute the ROC curve...
pos_label = True
roc = ru.compute_roc(X=x, y=y, pos_label=pos_label)

# ...and visualize it
ru.plot_roc(roc, label="Sample data", color="red")
plt.show()

# To perform a ROC analysis using bootstrapping
n_samples = 20
ru.plot_roc_bootstrap(X=x, y=y, pos_label=pos_label,
                      n_bootstrap=n_samples,
                      title="Bootstrap demo");
plt.show()

Build from source:

To fetch the project and run the tests or examples:

git clone https://github.com/hirsch-lab/roc-utils.git
cd roc-utils
python tests/test_all.py
python examples/examples.py

To create distribution packages (a source archive and a wheel):

python setup.py sdist bdist_wheel

To install the newly created Python package from the source archive:

pip uninstall roc-utils
pip cache remove roc_utils
pip install dist/roc_utils*.tar.gz

# Verify installation
python -c "import roc_utils; print(roc_utils.__version__)"
python -c "import roc_utils; roc_utils.demo_bootstrap()"

Metadata

Release files for roc-utils 0.2.2

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

Source distribution (sdist)

Source distribution for roc-utils 0.2.2
File Size Uploaded
roc_utils-0.2.2.tar.gz 765.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for roc-utils 0.2.2
File Interpreter ABI Platform
roc_utils-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 784.6 kB

Release files / roc_utils-0.2.2.tar.gz

Download URL roc_utils-0.2.2.tar.gz
Size 765.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f932c3cba50bad5a64b6cd1d483b30609a5ff7df93e34861c327900829e477af
BLAKE2b-256 checksum
How to use checksums
a707e5b99d491d279fcea9574361c73935057734f64c1b61af409fad4bc13a4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

Release files / roc_utils-0.2.2-py3-none-any.whl

Download URL roc_utils-0.2.2-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
585943c1b4d188ae7a3d7422a1a5f3fc3b01e7db2bf4cba08ec22bd54175f7cb
BLAKE2b-256 checksum
How to use checksums
ed6a07a2790ecd2e554167c8d1ff81768b34b99be8802b05d3e9308c4321b851
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

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