Skip to main content

Tools to compute and visualize ROC curves.

Project description

roc-utils

image License CodeFactor DeepSource

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

Installation:

pip install roc-utils

To quickly test the installation, use the following cals

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

Usage:

import numpy as np
import matplotlib.pyplot as plt
from roc_utils import *

def sample_data(n1, mu1, std1, n2, mu2, std2, seed=42):
    rng = np.random.RandomState(seed)
    #  sample size, mean, std
    x1 = rng.normal(mu1, std1, n1)
    x2 = rng.normal(mu2, std2, n2)
    y1 = np.zeros(n1, dtype=bool)
    y2 = np.ones(n2, dtype=bool)
    x = np.concatenate([x1,x2])
    y = np.concatenate([y1,y2])
    return x, y

x, y = sample_data(n1=300, mu1=0.0, std1=0.5,
                   n2=300, mu2=1.0, std2=0.7)
pos_label = True
roc = compute_roc(X=x, y=y, pos_label=pos_label)
plot_roc(roc, label="Sample data", color="red")
plt.show()

See examples/tutorial.ipynb for a more detailed introduction.

Build

To build the package, use the following

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

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

roc_utils-0.2.1.tar.gz (765.1 kB view hashes)

Uploaded Source

Built Distribution

roc_utils-0.2.1-py3-none-any.whl (18.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page