diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d4a2c44 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# http://editorconfig.org + +root = true + +[*] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true +charset = utf-8 +end_of_line = lf + +[*.bat] +indent_style = tab +end_of_line = crlf + +[LICENSE] +insert_final_newline = false + +[Makefile] +indent_style = tab diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..c57446e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,25 @@ +--- +name: Bug Report +about: Create a bug report to help us improve +labels: bug +--- + + + +### Environment Information + +- prosemble version: +- Python version: +- Operating System: + +### Description + +Describe what you were trying to get done. +Tell us what happened, what went wrong, and what you expected to happen. + +### What I Did + +``` +Paste the command(s) you ran and the output. +If there was a crash, please include the traceback here. +``` diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..15c9579 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,10 @@ +contact_links: + - name: Ask questions + url: https://github.com/naotoo1/prosemble/discussions/categories/q-a + about: Please ask and answer questions here. + - name: Ideas + url: https://github.com/naotoo1/prosemble/discussions/categories/ideas + about: Please share your ideas here. + - name: Ask questions from the GIS community + url: https://gis.stackexchange.com + about: To get answers from questions in the GIS community, please ask and answer questions here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..cf7acb9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,18 @@ +--- +name: Feature Request +about: Submit a feature request to help us improve +labels: Feature Request +--- + + + +### Description + +Describe the feature (e.g., new functions/tutorials) you would like to propose. +Tell us what can be achieved with this new feature and what's the expected outcome. + +### Source code + +``` +Paste your source code here if have sample code to share. +``` diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml new file mode 100644 index 0000000..0f03a62 --- /dev/null +++ b/.github/workflows/docs-build.yml @@ -0,0 +1,51 @@ +name: docs-build +on: + pull_request: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-python@v4 + with: + python-version: "3.8" + - name: Install GDAL + run: | + python -m pip install --upgrade pip + pip install --find-links=https://girder.github.io/large_image_wheels --no-cache GDAL pyproj + - name: Test GDAL installation + run: | + python -c "from osgeo import gdal" + gdalinfo --version + - name: Install dependencies + run: | + pip install --no-cache-dir Cython + pip install -r requirements.txt -r requirements_dev.txt -r requirements_docs.txt + pip install . + - name: Discover typos with codespell + run: codespell --skip="*.csv,*.geojson,*.json,*.js,*.html,*cff,*.pdf,./.git" --ignore-words-list="aci,acount,acounts,fallow,hart,hist,nd,ned,ois,wqs" + - name: PKG-TEST + run: | + python -m unittest discover tests/ + - name: Build docs + run: | + mkdocs build + # - name: Deploy to Netlify + # uses: nwtgck/actions-netlify@v2.0 + # with: + # publish-dir: "./site" + # production-branch: master + # github-token: ${{ secrets.GITHUB_TOKEN }} + # deploy-message: "Deploy from GitHub Actions" + # enable-pull-request-comment: true + # enable-commit-comment: false + # overwrites-pull-request-comment: true + # env: + # NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + # NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + # timeout-minutes: 10 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..f6d90e7 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,28 @@ +name: docs +on: + push: + branches: + - main +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --user --no-cache-dir Cython + pip install --user -r requirements.txt + pip install . + - name: Discover typos with codespell + run: | + pip install codespell + codespell --skip="*.csv,*.geojson,*.json,*.js,*.html,*cff,./.git" --ignore-words-list="aci,acount,acounts,fallow,hart,hist,nd,ned,ois,wqs,watermask" + - name: PKG-TEST + run: | + python -m unittest discover tests/ + - run: pip install -r requirements_docs.txt + - run: mkdocs gh-deploy --force diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..c78be81 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,38 @@ +on: + push: + branches: + - main + pull_request: + branches: + - main + +name: macOS build +jobs: + test-macOS: + runs-on: ${{ matrix.os }} + name: ${{ matrix.os }} (${{ matrix.python-version}}) + strategy: + fail-fast: false + matrix: + os: ["macOS-latest"] + python-version: ["3.7","3.8"] + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version}} + - name: Install GDAL + run: | + brew install gdal + - name: Test GDAL installation + run: | + gdalinfo --version + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --no-cache-dir Cython + pip install -r requirements.txt + pip install . diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..2bbb0c0 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,30 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: pypi + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERS }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 0000000..b077a50 --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,44 @@ +on: + push: + branches: + - main + pull_request: + branches: + - main + +name: Linux build +jobs: + py-check: + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.os }} (${{ matrix.config.py }}) + strategy: + fail-fast: false + matrix: + config: + - { os: ubuntu-latest, py: "3.7" } + - { os: ubuntu-latest, py: "3.8" } + steps: + - name: Checkout Code + uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.config.py }} + - name: Install GDAL + run: | + python -m pip install --upgrade pip + pip install --no-cache-dir Cython + pip install --find-links=https://girder.github.io/large_image_wheels --no-cache GDAL + - name: Test GDAL installation + run: | + python -c "from osgeo import gdal" + gdalinfo --version + - name: Install dependencies + run: | + pip install --user -r requirements.txt + pip install --user -r requirements_dev.txt + pip install . + - name: PKG-TEST + run: | + python -m unittest discover tests/ + diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..91d629c --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,61 @@ +on: + push: + branches: + - main + pull_request: + branches: + - main + +name: Windows build +# jobs: +# test-windows: +# runs-on: windows-latest +jobs: + test-windows: + runs-on: ${{ matrix.os }} + name: ${{ matrix.os }} (${{ matrix.python-version}}) + strategy: + fail-fast: false + matrix: + os: ["windows-latest"] + python-version: ["3.7","3.8"] + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version}} + - name: Install GDAL + run: | + brew install gdal + - name: Test GDAL installation + run: | + gdalinfo --version + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --no-cache-dir Cython + pip install -r requirements.txt + pip install . + + # steps: + # - uses: actions/checkout@v3 + # - name: Install miniconda + # uses: conda-incubator/setup-miniconda@v2 + # with: + # auto-activate-base: true + # python-version: "3.8" + # - name: Install GDAL + # run: conda install -c conda-forge gdal --yes + # - name: Test GDAL installation + # run: | + # python -c "from osgeo import gdal" + # gdalinfo --version + # - name: Install dependencies + # run: | + # python -m pip install --upgrade pip + # pip install --no-cache-dir Cython + # pip install -r requirements.txt + # pip install . diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..631004a --- /dev/null +++ b/.gitignore @@ -0,0 +1,106 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +private/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# 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/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# IDE settings +.vscode/ \ No newline at end of file diff --git a/LICENSE b/LICENSE index 1ba6805..05bd06a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,22 @@ -MIT License - -Copyright (c) [2022] [Nana Abeka Otoo] - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +MIT License + +Copyright (c) 2023, Nana Abeka Otoo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..89411aa --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,7 @@ +include LICENSE +include README.md +include requirements.txt + +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] + diff --git a/README.md b/README.md index 99190bb..788f0a6 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Prosemble [![python: 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-390/) -[![github](https://img.shields.io/badge/version-0.0.2-yellow.svg)](https://github.com/naotoo1/Prosemble) -[![pypi](https://img.shields.io/badge/pypi-0.0.2-orange.svg)](https://pypi.org/project/prosemble) +[![github](https://img.shields.io/badge/version-0.7.0-yellow.svg)](https://github.com/naotoo1/Prosemble) +[![pypi](https://img.shields.io/badge/pypi-0.7.0-orange.svg)](https://pypi.org/project/prosemble) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) -ML package for both prototype and non-prototype-based models +A python project for prototype-based machine learning models @@ -16,9 +16,19 @@ pip install prosemble ``` +If you have installed Prosemble before and want to upgrade to the latest version, you can run the following command in your terminal: +Prosemble can be installed using pip. +```python +pip install -U prosemble +``` +To install the development version from GitHub using Git, run the following command in your terminal: +```python +pip install git+https://github.com/naotoo1/prosemble +``` + ## Bibtex If you would like to cite the package, please use this: diff --git a/docs/changelog.md b/docs/changelog.md new file mode 100644 index 0000000..289e2c5 --- /dev/null +++ b/docs/changelog.md @@ -0,0 +1,11 @@ +# Changelog + +## v0.0.1 - Date + +**Improvement**: + +- TBD + +**New Features**: + +- TBD diff --git a/docs/common.md b/docs/common.md new file mode 100644 index 0000000..66f1dc8 --- /dev/null +++ b/docs/common.md @@ -0,0 +1,3 @@ +# common module + +::: prosemble.common \ No newline at end of file diff --git a/docs/contributing.md b/docs/contributing.md new file mode 100644 index 0000000..2e04954 --- /dev/null +++ b/docs/contributing.md @@ -0,0 +1,108 @@ +# Contributing + +Contributions are welcome, and they are greatly appreciated! Every +little bit helps, and credit will always be given. + +You can contribute in many ways: + +## Types of Contributions + +### Report Bugs + +Report bugs at . + +If you are reporting a bug, please include: + +- Your operating system name and version. +- Any details about your local setup that might be helpful in troubleshooting. +- Detailed steps to reproduce the bug. + +### Fix Bugs + +Look through the GitHub issues for bugs. Anything tagged with `bug` and +`help wanted` is open to whoever wants to implement it. + +### Implement Features + +Look through the GitHub issues for features. Anything tagged with +`enhancement` and `help wanted` is open to whoever wants to implement it. + +### Write Documentation + +prosemble could always use more documentation, +whether as part of the official prosemble docs, +in docstrings, or even on the web in blog posts, articles, and such. + +### Submit Feedback + +The best way to send feedback is to file an issue at +. + +If you are proposing a feature: + +- Explain in detail how it would work. +- Keep the scope as narrow as possible, to make it easier to implement. +- Remember that this is a volunteer-driven project, and that contributions are welcome :) + +## Get Started! + +Ready to contribute? Here's how to set up prosemble for local development. + +1. Fork the prosemble repo on GitHub. + +2. Clone your fork locally: + + ```shell + $ git clone git@github.com:your_name_here/prosemble.git + ``` + +3. Install your local copy into a virtualenv. Assuming you have + virtualenvwrapper installed, this is how you set up your fork for + local development: + + ```shell + $ mkvirtualenv prosemble + $ cd prosemble/ + $ python setup.py develop + ``` + +4. Create a branch for local development: + + ```shell + $ git checkout -b name-of-your-bugfix-or-feature + ``` + + Now you can make your changes locally. + +5. When you're done making changes, check that your changes pass flake8 + and the tests, including testing other Python versions with tox: + + ```shell + $ flake8 prosemble tests + $ python setup.py test or pytest + $ tox + ``` + + To get flake8 and tox, just pip install them into your virtualenv. + +6. Commit your changes and push your branch to GitHub: + + ```shell + $ git add . + $ git commit -m "Your detailed description of your changes." + $ git push origin name-of-your-bugfix-or-feature + ``` + +7. Submit a pull request through the GitHub website. + +## Pull Request Guidelines + +Before you submit a pull request, check that it meets these guidelines: + +1. The pull request should include tests. +2. If the pull request adds functionality, the docs should be updated. + Put your new functionality into a function with a docstring, and add + the feature to the list in README.rst. +3. The pull request should work for Python 3.5, 3.6, 3.7 and 3.8, and + for PyPy. Check and make sure that the tests pass for all + supported Python versions. diff --git a/docs/examples/intro.ipynb b/docs/examples/intro.ipynb new file mode 100644 index 0000000..ebd171a --- /dev/null +++ b/docs/examples/intro.ipynb @@ -0,0 +1,21 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('Hello World!')" + ] + } + ], + "metadata": { + "language_info": { + "name": "python" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/docs/faq.md b/docs/faq.md new file mode 100644 index 0000000..4514b4c --- /dev/null +++ b/docs/faq.md @@ -0,0 +1 @@ +# FAQ diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..69f1d0e --- /dev/null +++ b/docs/index.md @@ -0,0 +1,53 @@ +# Welcome to prosemble + + +[![image](https://img.shields.io/pypi/v/prosemble.svg)](https://pypi.python.org/pypi/prosemble) +[![python: 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-390/) +[![github](https://img.shields.io/badge/version-0.7.0-yellow.svg)](https://github.com/naotoo1/Prosemble) +[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) + + + +**A python project for prototype-based machine learning models** + + +- Free software: MIT license +- Documentation: + + +## Installation +Prosemble can be installed using pip. +```python +pip install prosemble +``` + + +If you have installed Prosemble before and want to upgrade to the latest version, you can run the following command in your terminal: +Prosemble can be installed using pip. +```python +pip install -U prosemble +``` + + + +To install the development version from GitHub using Git, run the following command in your terminal: +```python +pip install git+https://github.com/naotoo1/prosemble +``` + + +## Bibtex +If you would like to cite the package, please use this: +```python +@misc{Otoo_Prosemble_2022, +author = {Otoo, Nana Abeka}, +title = {Prosemble}, +year = {2022}, +publisher = {GitHub}, +journal = {GitHub repository}, +howpublished= {\url{https://github.com/naotoo1/Prosemble}}, +} +``` + + + diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 0000000..68b1f1d --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,21 @@ +# Installation + +## Stable release + +To install prosemble, run this command in your terminal: + +``` +pip install prosemble +``` + +This is the preferred method to install prosemble, as it will always install the most recent stable release. + +If you don't have [pip](https://pip.pypa.io) installed, this [Python installation guide](http://docs.python-guide.org/en/latest/starting/installation/) can guide you through the process. + +## From sources + +To install prosemble from sources, run this command in your terminal: + +``` +pip install git+https://github.com/naotoo1/prosemble +``` diff --git a/docs/overrides/main.html b/docs/overrides/main.html new file mode 100644 index 0000000..702c96b --- /dev/null +++ b/docs/overrides/main.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% block content %} +{% if page.nb_url %} + + {% include ".icons/material/download.svg" %} + +{% endif %} + +{{ super() }} +{% endblock content %} diff --git a/docs/prosemble.md b/docs/prosemble.md new file mode 100644 index 0000000..83eceb0 --- /dev/null +++ b/docs/prosemble.md @@ -0,0 +1,4 @@ + +# prosemble module + +::: prosemble.prosemble \ No newline at end of file diff --git a/docs/usage.md b/docs/usage.md new file mode 100644 index 0000000..cc7f29a --- /dev/null +++ b/docs/usage.md @@ -0,0 +1,7 @@ +# Usage + +To use prosemble in a project: + +``` +import prosemble +``` diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..1195535 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,86 @@ +site_name: prosemble +site_description: A python project for prototype-based machine learning models +site_author: naotoo1 +site_url: https://naotoo1.github.io/prosemble +repo_url: https://github.com/naotoo1/prosemble + +copyright: "Copyright © 2023 - 2023 Nana Abeka Otoo" + +theme: + palette: + - scheme: default + # primary: blue + # accent: indigo + toggle: + icon: material/toggle-switch-off-outline + name: Switch to dark mode + - scheme: slate + primary: indigo + accent: indigo + toggle: + icon: material/toggle-switch + name: Switch to light mode + name: material + icon: + repo: fontawesome/brands/github + # logo: assets/logo.png + # favicon: assets/favicon.png + features: + - navigation.instant + - navigation.tracking + - navigation.top + - search.highlight + - search.share + custom_dir: "docs/overrides" + font: + text: Google Sans + code: Regular + +plugins: + - search + - mkdocstrings + - git-revision-date + - git-revision-date-localized: + enable_creation_date: true + type: timeago + # - pdf-export + - mkdocs-jupyter: + include_source: True + ignore_h1_titles: True + execute: True + allow_errors: false + ignore: ["conf.py"] + execute_ignore: ["*ignore.ipynb"] + +markdown_extensions: + - admonition + - abbr + - attr_list + - def_list + - footnotes + - meta + - md_in_html + - pymdownx.superfences + - pymdownx.highlight: + linenums: true + - toc: + permalink: true + +# extra: +# analytics: +# provider: google +# property: UA-XXXXXXXXX-X + +nav: + - Home: index.md + - Installation: installation.md + - Usage: usage.md + - Contributing: contributing.md + - FAQ: faq.md + - Changelog: changelog.md + - Report Issues: https://github.com/naotoo1/prosemble/issues + - Examples: + - examples/intro.ipynb + - API Reference: + - prosemble module: prosemble.md + - common module: common.md diff --git a/prosemble/__init__.py b/prosemble/__init__.py index b58546e..6e14d06 100644 --- a/prosemble/__init__.py +++ b/prosemble/__init__.py @@ -4,5 +4,7 @@ from . import models from . import core -__version__ = "0.5.0" -__author__ = 'Nana Abeka Otoo' + +__author__ = """Nana Abeka Otoo""" +__email__ = 'nanaabekaotoo@gmail.com' +__version__ = '0.7.0' diff --git a/prosemble/models/__init__.py b/prosemble/models/__init__.py index 06039fa..4a44de9 100644 --- a/prosemble/models/__init__.py +++ b/prosemble/models/__init__.py @@ -18,6 +18,8 @@ from .kpcm import * from .kfpcm import * from .kpfcm import * +from .kipcm import * +from .kipcm2 import * from .npc import * from .som import * from .spectralclustering import * diff --git a/prosemble/models/kipcm.py b/prosemble/models/kipcm.py index be5eabf..1e5ebb6 100644 --- a/prosemble/models/kipcm.py +++ b/prosemble/models/kipcm.py @@ -19,7 +19,7 @@ ) -class KIPCM1: +class KIPCM: """ params: @@ -93,7 +93,7 @@ def __init__(self, self.model1 = FCM( data=self.data, c=self.num_clusters, - m=2, + m=self.fuzzifier, num_iter=self.num_iter, epsilon=self.epsilon, ord=self.ord diff --git a/requiremenst.txt b/requirements.txt similarity index 53% rename from requiremenst.txt rename to requirements.txt index 0b13d78..57d8e37 100644 --- a/requiremenst.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ -numpy +numpy==1.20.3 scikit-learn scipy matplotlib +pandas +neupy \ No newline at end of file diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..2a86222 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,12 @@ +black +black[jupyter] +pip +bump2version +wheel +watchdog +flake8 +tox +coverage +Sphinx +twine + diff --git a/requirements_docs.txt b/requirements_docs.txt new file mode 100644 index 0000000..bd75819 --- /dev/null +++ b/requirements_docs.txt @@ -0,0 +1,24 @@ +bump2version +coverage +flake8 +ipykernel +livereload +nbconvert +nbformat +pip +sphinx +tox +twine +watchdog +wheel +mkdocs +mkdocs-git-revision-date-plugin +mkdocs-git-revision-date-localized-plugin +mkdocs-jupyter>=0.24.0 +mkdocs-material>=9.1.3 +mkdocs-pdf-export-plugin +mkdocstrings +mkdocstrings-crystal +mkdocstrings-python-legacy +pygments +pymdown-extensions \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..57ad539 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,22 @@ +[bumpversion] +current_version = 0.7.0 +commit = True +tag = True + +[bumpversion:file:setup.py] +search = version='{current_version}' +replace = version='{new_version}' + +[bumpversion:file:prosemble/__init__.py] +search = __version__ = '{current_version}' +replace = __version__ = '{new_version}' + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs + +[aliases] +# Define setup.py command aliases here + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..439f135 --- /dev/null +++ b/setup.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +"""The setup script.""" + +import io +from os import path as op +from setuptools import setup, find_packages + +with open('README.md') as readme_file: + readme = readme_file.read() + +here = op.abspath(op.dirname(__file__)) + +# get the dependencies and installs +with io.open(op.join(here, "requirements.txt"), encoding="utf-8") as f: + all_reqs = f.read().split("\n") + +install_requires = [x.strip() for x in all_reqs if "git+" not in x] +dependency_links = [x.strip().replace("git+", "") for x in all_reqs if "git+" not in x] + +requirements = [ ] + +setup_requirements = [ ] + +test_requirements = [ ] + +setup( + author="Nana Abeka Otoo", + author_email='abekaotoo@gmail.com', + python_requires='>=3.7', + classifiers=[ + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + ], + description="A python project for prototype-based machine learning models", + install_requires=install_requires, + dependency_links=dependency_links, + license="MIT license", + long_description=readme, + long_description_content_type='text/markdown', + include_package_data=True, + keywords='prosemble', + name='prosemble', + packages=find_packages(include=['prosemble', 'prosemble.*']), + setup_requires=setup_requirements, + test_suite='tests', + tests_require=test_requirements, + url='https://github.com/naotoo1/prosemble', + version='0.7.0', + zip_safe=False, +) diff --git a/simulation/opt_m.py b/simulation/opt_m.py deleted file mode 100644 index a84f5df..0000000 --- a/simulation/opt_m.py +++ /dev/null @@ -1,101 +0,0 @@ -from sklearn.datasets import load_iris -from sklearn.preprocessing import StandardScaler -from sklearn.model_selection import train_test_split -from prosemble import Hybrid -import matplotlib.pyplot as plt -import numpy as np - - -def simulate_m(x, y_): - """ - - :param x: Test set - :param y_:list : set of possible fuzzifiers - :return: classification label securities based on the fuzzifiers - """ - security_dat1 = [glvq.get_security(x, i) for i in y_] - security_dat2 = [gmlvq.get_security_m(x, i) for i in y_] - security_dat3 = [celvq.get_security(x, i) for i in y_] - return security_dat1, security_dat2, security_dat3 - - -def optimise_m(x): - """ - :param x: int: model evaluation performance measure(eg average accuracy from CV) - :return: returns optimized fuzzier for the classification label securities - """ - m = round((1 / (x * x)) + 1) - return round(m) - - -def sim_mlist(x, y_, z): - """ - - :param x: Test set - :param y_:List : set of possible fuzzifiers - :param z: index of sample data from the test set - :return: list: Classification label securities for a sample data based on the set list of fuzzifiers - """ - simulated_mlist = [i_[1][1] for i_ in simulate_m(x, y_)[z]] - return simulated_mlist - - -def sim_m(): - """ - - :return: List: Optimized fuzzifiers based on simulated list of model performance evaluation measure. - """ - r = np.arange(0.4, 1.1, 0.1) - m_list = [optimise_m(i) for i in r] - return m_list, r - - -if __name__ == '__main__': - # Data_set and scaling - scaler = StandardScaler() - X, y = load_iris(return_X_y=True) - X = X[:, 0:2] - - X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2) - scaler.fit(X_train) - # X_train = scaler.fit_transform(X_train) - X_test = scaler.transform(X_test) - - # summary of input parameters - proto_classes = np.array([0, 1, 2]) - - # Transferred learned prototypes for glvq, gmlvq and celvq respectively - glvq_prototypes = np.array([[-1.092267, 0.9856019], [-0.29071018, -1.230379], [1.5310693, 0.08934504]]) - gmlvq_prototypes = np.array([[-0.97786397, 0.8252505], [-0.25761604, -0.49248296], [1.2729689, 0.05621301]]) - celvq_prototypes = np.array([[-1.654047, 1.1912421], [0.06487547, -1.4322541], [1.6647131, -0.4211262]]) - omega_matrix = np.array([[1.3414, -0.6254], [-0.5219, 0.2435]]) - - # object of the Hybrid class - glvq = Hybrid(model_prototypes=glvq_prototypes, proto_classes=proto_classes, mm=3, omega_matrix=None, matrix='n') - gmlvq = Hybrid(model_prototypes=gmlvq_prototypes, proto_classes=proto_classes, mm=3, omega_matrix=omega_matrix, matrix='y') - celvq = Hybrid(model_prototypes=celvq_prototypes,proto_classes=proto_classes, mm=3, omega_matrix=None, matrix='n') - - # simulate ensemble lvq based on transfer learning with glvq, gmlvq and celvq learned prototypes - ym = [2, 3, 4, 5, 6, 7, 8, 9, 10] - - a, b = sim_m() - glvq_sim_sec = sim_mlist(x=X_test, y_=ym, z=0) - gmlvq_sim_sec = sim_mlist(x=X_test, y_=ym, z=1) - celvq_sim_sec = sim_mlist(x=X_test, y_=ym, z=2) - - print(glvq_sim_sec) - print(a) - f = plt.figure(1) - plt.plot(ym, glvq_sim_sec, label='GLVQ') - plt.plot(ym, gmlvq_sim_sec, label='GMLVQ') - plt.plot(ym, celvq_sim_sec, label='CELVQ') - plt.xlabel('m') - plt.ylabel('classification label security') - plt.legend() - - p = plt.figure(2) - plt.plot(a, b) - plt.xlabel('optimised m') - plt.ylabel('Test accuracy') - - plt.show() diff --git a/simulation/smh2.png b/simulation/smh2.png deleted file mode 100644 index 134eb75..0000000 Binary files a/simulation/smh2.png and /dev/null differ diff --git a/simulation/test_iris1.py b/simulation/test_iris1.py deleted file mode 100644 index 62eb994..0000000 --- a/simulation/test_iris1.py +++ /dev/null @@ -1,89 +0,0 @@ -from sklearn.datasets import load_iris -from sklearn.preprocessing import StandardScaler -from sklearn.model_selection import train_test_split -from prosemble import Hybrid -import matplotlib.pyplot as plt -import numpy as np - -# Data_set and scaling -scaler = StandardScaler() -X, y = load_iris(return_X_y=True) -X = X[:, 0:2] - - -# select test set for the simulation -def select_(x, i_): - X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=i_) - scaler.fit(X_train) - # X_train = scaler.fit_transform(X_train) - X_test = scaler.transform(X_test) - return X_test, y_test - - -# summary of input parameters -proto_classes = np.array([0, 1, 2]) - -# Transferred learned prototypes for glvq, gmlvq and celvq respectively -glvq_prototypes = np.array([[-1.092267, 0.9856019], [-0.29071018, -1.230379], [1.5310693, 0.08934504]]) -gmlvq_prototypes = np.array([[-0.97786397, 0.8252505], [-0.25761604, -0.49248296], [1.2729689, 0.05621301]]) -celvq_prototypes = np.array([[-1.654047, 1.1912421], [0.06487547, -1.4322541], [1.6647131, -0.4211262]]) -omega_matrix = np.array([[1.3414, -0.6254], [-0.5219, 0.2435]]) - -# object of the Hybrid class -glvq = Hybrid(model_prototypes=glvq_prototypes, proto_classes=proto_classes, mm=3, omega_matrix=None, matrix='n') -gmlvq = Hybrid(model_prototypes=gmlvq_prototypes, proto_classe=proto_classes,mm=3, omega_matrix=omega_matrix, matrix='y') -celvq = Hybrid(model_prototypes=celvq_prototypes, proto_classes=proto_classes, mm=3, omega_matrix=None, matrix='n') - - -# simulate ensemble lvq based on transfer learning with glvq, gmlvq and celvq learned prototypes -def simulation(x): - """ - :param x: x_test - :return: - Simulated accuracy for both hard and soft voting - """ - accuracy_list1 = [] - simu_list1 = [] - accuracy_list = [] - simu_list = [] - # test_ss = np.arange(0.2, 1, 0.1) - for i in range(20): - a, b = select_(x, i_=0.2) - pred1 = glvq.predict(x_test=a) - pred2 = gmlvq.predict(x_test=a) - pred3 = celvq.predict(x_test=a) - sec1 = glvq.get_security(x=a, y=2) - sec2 = gmlvq.get_security_m(x=a, y=2) - sec3 = celvq.get_security(x=a, y=2) - all_pred = [pred1, pred2, pred3] - all_sec = [sec1, sec2, sec3] - final_pred1 = glvq.pred_sprob(x=a, y=all_sec) - accuracy1 = glvq.accuracy(x=b, y=final_pred1) - final_pred = glvq.pred_prob(x=a, y=all_pred) - accuracy = glvq.accuracy(x=b, y=final_pred) - accuracy_list1.append(accuracy1) - simu_list1.append(i) - accuracy_list.append(accuracy) - simu_list.append(i) - return accuracy_list, simu_list, accuracy_list1, simu_list1 - - -# simulation results -p, r, s, t = simulation(x=X) - -# summary simulation results for soft voting -simulated_accuracy1 = s -simulated_list1 = t - -# summary simulation results for hard voting -simulated_accuracy = p -simulated_list = r - -# plot simulated results of transfer learning in ensemble lvq -plt.plot(simulated_list1, simulated_accuracy1, label='soft voting', marker='o') -plt.plot(simulated_list, simulated_accuracy, label='hard voting', marker='v') - -plt.xlabel('Simulations') -plt.ylabel('Accuracy(%)') -plt.legend() -plt.show() diff --git a/simulation/test_wdbc1.py b/simulation/test_wdbc1.py deleted file mode 100644 index ce011d6..0000000 --- a/simulation/test_wdbc1.py +++ /dev/null @@ -1,89 +0,0 @@ -from sklearn.datasets import load_breast_cancer -from sklearn.preprocessing import StandardScaler -from sklearn.model_selection import train_test_split -from prosemble import Hybrid -import matplotlib.pyplot as plt -import numpy as np - -# Data_set and scaling -scaler = StandardScaler() -X, y = load_breast_cancer(return_X_y=True) -X = X[:, 0:2] - - -# select test set for the simulation -def select_(x, i_): - X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=i_) - scaler.fit(X_train) - # X_train = scaler.fit_transform(X_train) - X_test = scaler.transform(X_test) - return X_test, y_test - - -# summary of input parameters -proto_classes = np.array([0, 1]) - -# Transferred learned prototypes for glvq, gmlvq and celvq respectively -glvq_prototypes = np.array([[1.8459078, 0.7657392], [-0.7304492, -0.5764439]]) -gmlvq_prototypes = np.array([[1.1675262, 0.9516143], [-0.6120413, -0.51750517]]) -celvq_prototypes = np.array([[2.766608, 0.9153884], [-1.994142, -0.9101994]]) -omega_matrix = np.array([[1.4325, 0.7964], [0.3552, 0.1990]]) - -# object of the Hybrid class -glvq = Hybrid(model_prototypes=glvq_prototypes, proto_classes=proto_classes, mm=2, omega_matrix=None, matrix='n') -gmlvq = Hybrid(model_prototypes=gmlvq_prototypes, proto_classes=proto_classes, mm=2, omega_matrix=omega_matrix, matrix='y') -celvq = Hybrid(model_prototypes=celvq_prototypes, proto_classes=proto_classes, mm=2, omega_matrix=None, matrix='n') - - -# simulate ensemble lvq based on transfer learning with glvq, gmlvq and celvq learned prototypes -def simulation(x): - """ - :param x: x_test - :return: - Simulated accuracy for both hard and soft voting - """ - accuracy_list1 = [] - simu_list1 = [] - accuracy_list = [] - simu_list = [] - # test_ss = np.arange(0.2, 1, 0.1) - for i in range(20): - a, b = select_(x, i_=0.2) - pred1 = glvq.predict(x_test=a) - pred2 = gmlvq.predict(x_test=a) - pred3 = celvq.predict(x_test=a) - sec1 = glvq.get_security(x=a, y=2) - sec2 = gmlvq.get_security_m(x=a, y=2) - sec3 = celvq.get_security(x=a, y=2) - all_pred = [pred1, pred2, pred3] - all_sec = [sec1, sec2, sec3] - final_pred1 = glvq.pred_sprob(x=a, y=all_sec) - accuracy1 = glvq.accuracy(x=b, y=final_pred1) - final_pred = glvq.pred_prob(x=a, y=all_pred) - accuracy = glvq.accuracy(x=b, y=final_pred) - accuracy_list1.append(accuracy1) - simu_list1.append(i) - accuracy_list.append(accuracy) - simu_list.append(i) - return accuracy_list, simu_list, accuracy_list1, simu_list1 - - -# simulation results -p, r, s, t = simulation(x=X) - -# summary simulation results for soft voting -simulated_accuracy1 = s -simulated_list1 = t - -# summary simulation results for hard voting -simulated_accuracy = p -simulated_list = r - -# plot simulated results of transfer learning in ensemble lvq -plt.plot(simulated_list1, simulated_accuracy1, label='soft voting', marker='o') -plt.plot(simulated_list, simulated_accuracy, label='hard voting', marker='v') - -plt.xlabel('Simulations') -plt.ylabel('Accuracy(%)') -plt.legend() -plt.show() diff --git a/simulation/wdbc1.png b/simulation/wdbc1.png deleted file mode 100644 index 473605e..0000000 Binary files a/simulation/wdbc1.png and /dev/null differ diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..1bbcf9e --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +"""Unit test package for prosemble.""" diff --git a/tests/test_prosemble.py b/tests/test_prosemble.py new file mode 100644 index 0000000..e76a56b --- /dev/null +++ b/tests/test_prosemble.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +"""Tests for `prosemble` package.""" + + +import unittest + +# from prosemble import prosemble + + +class TestProsemble(unittest.TestCase): + """Tests for `prosemble` package.""" + + def setUp(self): + """Set up test fixtures, if any.""" + + def tearDown(self): + """Tear down test fixtures, if any.""" + + def test_000_something(self): + """Test something."""