Skip to content

Commit

Permalink
Merge pull request #4 from alistairewj/gh_actions
Browse files Browse the repository at this point in the history
Add GH actions, improve usage
  • Loading branch information
alistairewj authored Jul 11, 2022
2 parents bbc0a65 + 17e2ced commit 89770f8
Show file tree
Hide file tree
Showing 7 changed files with 278 additions and 60 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Run tests on Python

on:
release:
types: [published]
branches: ["main"]
pull_request:
branches:
- main

jobs:
test:
name: Test pyroc
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- name: Checkout pyroc repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .
- name: Test with pytest
run: |
pytest tests
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Use:
print(auroc)
print(ci)

A usage.ipynb notebook is provided demonstrating common usage of the package (requires Jupyter: `pip install jupyter`).

Documentation
-------------

Expand Down
5 changes: 3 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ channels:
dependencies:
- matplotlib>=3.0.0
- numpy>=1.15.2
- pandas>=0.22.0
- python>=3.5.6
- pandas>=1.0.0
- scipy>=1.8.1
- python>=3.7.0
12 changes: 10 additions & 2 deletions pyroc.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,20 @@ def ci(self, alpha=0.05):

return ci

def compare(self, contrast, alpha=0.05):
def compare(self, contrast=None, alpha=0.05):
"""Compare predictions given a contrast
If no contrast is provided, and N classifiers are provided (C[0,N-1]),
all classifiers in C[1,N-1] is compared to C[0]
If there are two predictions, you can compare as:
roc.compare(contrast=[1, -1], alpha=0.05)
"""
# If no contrast is provided, and N classifiers are provided (C[0,N-1])
# compare classifiers C[1,N-1] to C[0]
if contrast is None:
contrast = -np.identity(self.K - 1)
contrast = np.insert(contrast, 0, np.ones(self.K - 1), axis=1)

# Validate alpha
if (alpha <= 0) | (alpha >= 1):
Expand Down Expand Up @@ -290,7 +298,7 @@ def _roc(self, pred):
(fpr, tpr)
np.ndarrays containing the false positive rate and the true
positive rate, respectively.
"""
# Transform to matrices
y_prob = np.array([pred])
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
matplotlib==3.5.2
numpy==1.23.0
pandas==1.4.3
scipy==1.8.1
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
url='https://github.com/alistairewj/pyroc',

# Author details
author='Alistair Johnson, Lucas Bulgarelli',
author='Alistair Johnson, Lucas Bulgarelli, Tom Pollard',
author_email='[email protected]',

# Choose your license
Expand All @@ -46,5 +46,5 @@
# your project is installed. For an analysis of "install_requires" vs pip's
# requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=['pandas>=0.22.0', 'numpy>=1.12.1', 'scipy>=0.18.1']
install_requires=['pandas>=1.0.0', 'numpy>=1.15.2', 'scipy>=1.8.1']
)
276 changes: 222 additions & 54 deletions usage.ipynb

Large diffs are not rendered by default.

0 comments on commit 89770f8

Please sign in to comment.