From 705981dd4bc5ad13e97f43f8e85aeb2a8a8a91a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Wed, 12 May 2021 12:53:01 +0200 Subject: [PATCH] Stub project --- .coveragerc | 13 +++++++++++ .github/workflows/main.yml | 36 ++++++++++++++++++++++++++++ .pre-commit-config.yaml | 35 +++++++++++++++++++++++++++ README.md | 6 ++++- cfs/Selection.py | 3 +++ cfs/__init__.py | 9 +++++++ cfs/tests/CFS_test.py | 16 +++++++++++++ cfs/tests/__init__.py | 3 +++ pyproject.toml | 16 +++++++++++++ requirements.txt | 1 + setup.py | 48 ++++++++++++++++++++++++++++++++++++++ 11 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 .coveragerc create mode 100644 .github/workflows/main.yml create mode 100644 .pre-commit-config.yaml create mode 100644 cfs/Selection.py create mode 100644 cfs/__init__.py create mode 100644 cfs/tests/CFS_test.py create mode 100644 cfs/tests/__init__.py create mode 100644 pyproject.toml create mode 100644 requirements.txt create mode 100644 setup.py diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..b08bab6 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,13 @@ +[run] +branch = True +source = cfs + +[report] +exclude_lines = + if self.debug: + pragma: no cover + raise NotImplementedError + if __name__ == .__main__.: +ignore_errors = True +omit = + cfs/__init__.py \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..8a4c6fd --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,36 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + workflow_dispatch: + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, ubuntu-latest] + python: [3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Install dependencies + run: | + pip install -q --upgrade pip + pip install -q -r requirements.txt + pip install -q --upgrade codecov coverage black flake8 codacy-coverage + - name: Lint + run: | + black --check --diff stree + flake8 --count stree + - name: Tests + run: | + coverage run -m unittest -v stree.tests + coverage xml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7152d26 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +repos: + - repo: https://github.com/ambv/black + rev: stable + hooks: + - id: black + language_version: python3.8 + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.4 + hooks: + - id: flake8 + #- repo: https://github.com/pre-commit/mirrors-mypy + # rev: 'v0.782' # Use the sha / tag you want to point at + # hooks: + # - id: mypy + # args: [--strict] + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.3.0 + hooks: + - id: trailing-whitespace + - id: check-case-conflict + - id: check-ast + - id: trailing-whitespace + + - repo: local + hooks: + - id: tests + name: tests + language: system + entry: coverage run -m unittest + pass_filenames: false + - id: coverage + name: coverage + language: system + entry: coverage report -m --fail-under=100 + pass_filenames: false diff --git a/README.md b/README.md index c9d7f30..24d415e 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ -# cfs \ No newline at end of file +# CFS + +## Correlation-based Feature Selection + +Based on the work of Mark Andrew Hall diff --git a/cfs/Selection.py b/cfs/Selection.py new file mode 100644 index 0000000..7402c62 --- /dev/null +++ b/cfs/Selection.py @@ -0,0 +1,3 @@ +class CFS: + def __init__(self, a): + self.a = a diff --git a/cfs/__init__.py b/cfs/__init__.py new file mode 100644 index 0000000..f5d4c56 --- /dev/null +++ b/cfs/__init__.py @@ -0,0 +1,9 @@ +from .Selection import CFS + +__version__ = "0.1" +__author__ = "Ricardo Montañana Gómez" +__author_email__ = "Ricardo.Montanana@alu.uclm.es" +__copyright__ = "Copyright 2021, Ricardo Montañana Gómez" +__license__ = "MIT License" + +__all__ = ["CFS"] diff --git a/cfs/tests/CFS_test.py b/cfs/tests/CFS_test.py new file mode 100644 index 0000000..e76aaff --- /dev/null +++ b/cfs/tests/CFS_test.py @@ -0,0 +1,16 @@ +import unittest + +from ..Selection import CFS + + +class CFS_test(unittest.TestCase): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # @classmethod + # def setup(cls): + # pass + + def test_initial(self): + cfs = CFS(a=1) + self.assertEqual(cfs.a, 1) diff --git a/cfs/tests/__init__.py b/cfs/tests/__init__.py new file mode 100644 index 0000000..9cbd6eb --- /dev/null +++ b/cfs/tests/__init__.py @@ -0,0 +1,3 @@ +from .CFS_test import CFS_test + +__all__ = ["CFS_test"] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9bd6669 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,16 @@ +[tool.black] +line-length = 79 +include = '\.pyi?$' +exclude = ''' +/( + \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist +)/ +''' \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b8202e2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +scikit-learn>0.24 \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7471f0b --- /dev/null +++ b/setup.py @@ -0,0 +1,48 @@ +import setuptools + + +def readme(): + with open("README.md") as f: + return f.read() + + +def get_data(field: str): + item = "" + with open("stree/__init__.py") as f: + for line in f.readlines(): + if line.startswith(f"__{field}__"): + delim = '"' if '"' in line else "'" + item = line.split(delim)[1] + break + else: + raise RuntimeError(f"Unable to find {field} string.") + return item + + +setuptools.setup( + name="CFS", + version=get_data("version"), + license=get_data("license"), + description="Correlation-based Feature Selection", + long_description=readme(), + long_description_content_type="text/markdown", + packages=setuptools.find_packages(), + url="https://github.com/Doctorado-ML/cfs#cfs", + project_urls={ + "Code": "https://github.com/Doctorado-ML/cfs", + }, + author=get_data("author"), + author_email=get_data("author_email"), + keywords="feature-selection", + classifiers=[ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: " + get_data("license"), + "Programming Language :: Python :: 3.8", + "Natural Language :: English", + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "Intended Audience :: Science/Research", + ], + install_requires=["scikit-learn"], + test_suite="cfs.tests", + zip_safe=False, +)