Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/publish_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish Python Package

on:
release:
types: [published]
tags:
- 'v*'
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10" # Python version for building/uploading

- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine

# Optional: Generate version file from GitHub tag
# - name: Generate version file
# run: echo "__version__ = '${GITHUB_REF##refs/tags/}'" > your_package/_version.py

- name: Build package
run: python -m build

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*

36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Python Package CI

on:
push:
branches: [main,dev]
pull_request:
branches: [main,dev]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip, install build tools
run: |
python -m pip install --upgrade pip setuptools wheel build

- name: Install your package with test dependencies
run: |
pip install .[test] # assumes you’ve defined [project.optional-dependencies] in pyproject.toml

- name: Run pytest
run: |
pytest --disable-warnings --maxfail=1 --tb=short
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,5 @@ cython_debug/
.pypirc

#Project specific
output/
output/
version.py
380 changes: 190 additions & 190 deletions HEROS_Demo_Notebook.ipynb

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,20 @@ A schematic detailing how the HEROS algorithm works is given below:
***
<a id="item-two"></a>
## Installation
HEROS can currently only be installed by cloning this repository. Make sure that you have also installed all prerequisite packages included in requirements.txt prior to running (Note: this list may need updating - so if you get errors, check first that you have necessary packages installed).
HEROS can be installed with pip or by cloning this repository.

### Pip
HEROS can most easily be installed using the following pip command:
```
pip install skheros
```
In order to run the [HEROS_Demo_Notebook](https://github.com/UrbsLab/heros/blob/main/HEROS_Demo_Notebook.ipynb), download it and make sure to set the following notebook parameter to False in order to import HEROS from the above pip installation.
```
load_from_cloned_repo = False
```

### Clone Respository
To install/run HEROS from this cloned repository, run the following commands from the desired folder:
```
git clone --single-branch https://github.com/UrbsLab/heros
cd heros
Expand Down Expand Up @@ -62,7 +72,7 @@ Lastly, the fit() method can optionally be passed 'pop_df', a dataframe object,

### Demonstration Notebook
A Jupyter Notebooks has been included to demonstrate how HEROS (and it's functions) can be applied to train, evaluate, and apply models with a wide variety of saved outputs, visualizations and model prediction explanations. We strongly recommend exploring this demonstration notebook to get familiar with HEROS and its capabilities.
* [DEMO Notebook](https://github.com/UrbsLab/heros/blob/main/HEROS_Demo_Notebook.ipynb)
* [HEROS_Demo_Notebook](https://github.com/UrbsLab/heros/blob/main/HEROS_Demo_Notebook.ipynb)

This notebook is currently set up to run by cloning this repository and running the included notebook.

Expand Down
59 changes: 59 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "skheros"
version = "0.2.3"
description = "The Heuristic Evolutionary Rule Optimization System (HEROS) is a supervised rule-based machine learning algorithm designed to agnostically model diverse 'structured' data problems and yield compact human interpretable solutions. This implementation is scikit-learn compatible."
readme = "README.md"
requires-python = ">=3.8"
license = {file = "LICENSE" }
keywords = ["machine learning","rule-based","scikit-learn", "interpretable", "classification", "supervised learning", "evolutionary computation"]
authors = [{name = "Ryan Urbanowicz", email = "ryanurbanowicz@gmail.com"}]

classifiers = [
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"License :: Other/Academic Software License",
"Framework :: Scikit-Learn",
"Operating System :: OS Independent",
]

# dependencies = ["numpy>=2.3.0","pandas>=2.3.0","scikit-learn>=1.7.0","matplotlib>=3.10.3","seaborn>=0.13.2","scipy>=1.15.3","skrebate==0.7","networkx>=3.5"]

dependencies = [
"numpy",
"pandas",
"scikit-learn",
"matplotlib",
"seaborn",
"scipy",
"skrebate==0.7",
"networkx"]

[project.optional-dependencies]
test = [
"pytest>=7.0",
"pytest-cov",
"pytest-mock",
"flake8",
"mypy",
]

[project.urls]
"Source Code" = "https://github.com/UrbsLab/heros"

[tool.setuptools]
package-dir = {"" = "src"}

[tool.setuptools.packages.find]
where = ["src"]
include = ["heros*"]
exclude = ["tests*"]
Binary file modified requirements.txt
Binary file not shown.
4 changes: 0 additions & 4 deletions src/skheros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@
"""

from .heros import HEROS

__version__ = "0.0.1"
__author__ = 'Ryan Urbanowicz'
__credits__ = 'Cedars-Sinai Health Systems'
Empty file added tests/__init__.py
Empty file.
23 changes: 12 additions & 11 deletions src/test_heros.py → tests/test_heros.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import os
import pandas as pd
from skheros.heros import HEROS
from src.skheros.heros import HEROS
from sklearn.metrics import classification_report
from skrebate import MultiSURF # Install using: pip install skrebate==0.7

Expand Down Expand Up @@ -169,7 +170,7 @@ def test_multiclass():
print("HEROS Top Model Training Data Performance Report:")
print(classification_report(predictions, y, digits=8))


"""
def test_quantitative_outcome():
print("------------------------------------------------------")
print("Test: 6-bit MUX as quantiative outcome problem - binary features, No NA's")
Expand All @@ -190,14 +191,14 @@ def test_quantitative_outcome():
track_performance=1000,model_tracking=True,stored_rule_iterations=None,stored_model_iterations=None,random_state=42,verbose=True)
heros = heros.fit(X, y, None, cat_feat_indexes=cat_feat_indexes, ek=ek)
#Incomplete implementation


if __name__ == "__main__":
test_6mux()
test_na()
test_mixed_feature_types()
test_mixed_feature_types_na()
test_multiclass()
#test_quantitative_outcome() #incomplete
"""

#if __name__ == "__main__":
# test_6mux()
# test_na()
# test_mixed_feature_types()
# test_mixed_feature_types_na()
# test_multiclass()
# test_quantitative_outcome() #incomplete