Skip to content

Commit

Permalink
semicart added and db_weights to calc what it needs and CI/CD added
Browse files Browse the repository at this point in the history
  • Loading branch information
abedinia committed Jul 19, 2024
1 parent bd94646 commit 39f3bbe
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 91 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/python_package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Python package

on:
push:
tags:
- 'v*.*.*'
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
pip install -r requirements.txt
- name: Build the package
run: |
python setup.py sdist bdist_wheel
- name: Install the package
run: |
pip install dist/*.whl
- name: Run tests
run: |
pip install pytest
pytest
release:
needs: build
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build the package
run: |
python setup.py sdist bdist_wheel
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m pip install --upgrade twine
twine upload dist/*
163 changes: 163 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea/
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
numpy==2.0.0
scikit-learn==1.5.1
scipy==1.14.0
joblib==1.4.2
db-weights==0.0.7
tqdm==4.66.4
1 change: 0 additions & 1 deletion semicart/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from .semicart import SemiCARTClassifier, tuning_params
from .weights import WeightCalculator
3 changes: 1 addition & 2 deletions semicart/semicart.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import numpy as np
from tqdm import tqdm
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score

from .weights import WeightCalculator
from db_weights.weights import WeightCalculator


class DecisionNode:
Expand Down
59 changes: 0 additions & 59 deletions semicart/weights.py

This file was deleted.

14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
description="Building semi-supervised decision trees with semi-cart algorithm",
long_description="SemiCart is an algorithm based on CART that uses the weights of test data to improve prediction accuracy. This algorithm employs calculation methods such as Nearest Neighbor and metrics like Euclidean and Mahalanobis distances to determine the weights, more infor: https://link.springer.com/article/10.1007/s13042-024-02161-z",
long_description_content_type="text/markdown",
url="https://github.com/abedinia/semicart",
url="https://github.com/WeightedBasedAI/semicart",
packages=find_packages(),
install_requires=[
'numpy',
'scikit-learn',
'scipy',
'joblib',
'logging',
'tqdm'
'numpy==2.0.0',
'scikit-learn==1.5.1',
'scipy==1.14.0',
'joblib==1.4.2',
'db-weights==0.0.7',
'tqdm==4.66.4'
],
classifiers=[
"Programming Language :: Python :: 3",
Expand Down
22 changes: 0 additions & 22 deletions tests/test_weight.py

This file was deleted.

0 comments on commit 39f3bbe

Please sign in to comment.