From d3607ef1341a017804b2aa825ccaaf38f331fc8d Mon Sep 17 00:00:00 2001 From: Xin Han Date: Wed, 5 Mar 2025 18:20:00 +1100 Subject: [PATCH 1/5] fix format --- .github/workflows/pypi.yml | 215 ++++++------- pixi.lock | 234 +------------- pyikt/__init__.py | 30 +- pyikt/anomaly/__init__.py | 2 +- pyikt/anomaly/_idkd.py | 4 +- pyikt/anomaly/_iforest.py | 6 +- pyikt/anomaly/_inne.py | 6 +- pyikt/anomaly/tests/test_idkd.py | 3 +- pyikt/anomaly/tests/test_inne.py | 4 +- pyikt/cluster/__init__.py | 4 +- pyikt/cluster/_idkc.py | 6 +- pyikt/cluster/_ikahc.py | 7 +- pyikt/cluster/_kcluster.py | 3 +- pyikt/cluster/_pskc.py | 8 +- pyikt/cluster/_utils.py | 2 +- pyikt/cluster/tests/test_idkc.py | 3 +- pyikt/cluster/tests/test_ikahc.py | 1 + pyikt/cluster/tests/test_pskc.py | 1 + pyikt/graph/__init__.py | 2 +- pyikt/graph/_ikgod.py | 16 +- pyikt/graph/_isographkernel.py | 8 +- pyikt/graph/tests/test_ikgod.py | 7 +- pyikt/graph/tests/test_isographkernel.py | 5 +- pyikt/graph/utils.py | 3 +- pyikt/group/anomaly/_ikgad.py | 5 +- pyikt/group/tests/test_Ikgad.py | 1 + pyikt/group/utils.py | 3 +- pyikt/kernel/__init__.py | 2 +- pyikt/kernel/_ik_iforest.py | 7 - pyikt/kernel/_isodiskernel.py | 2 + pyikt/kernel/_isokernel.py | 6 +- pyikt/kernel/tests/test_isodiskernel.py | 3 +- pyikt/kernel/tests/test_isokernel.py | 3 +- pyikt/stream/changedetect/_icid.py | 23 +- pyikt/stream/cluster/_inode.py | 2 +- pyikt/stream/cluster/_streakhc.py | 10 +- pyikt/stream/cluster/utils/Graphviz.py | 254 +++++++++++---- pyikt/stream/cluster/utils/__init__.py | 7 +- pyikt/stream/cluster/utils/deltasep_utils.py | 292 ++++++++++-------- .../stream/cluster/utils/dendrogram_purity.py | 34 +- .../cluster/utils/dendrogram_purity_pool.py | 56 ++-- pyikt/stream/cluster/utils/file_utils.py | 15 +- pyikt/stream/cluster/utils/logger.py | 50 +-- pyikt/stream/cluster/utils/serialize_trees.py | 82 +++-- pyikt/stream/tests/test_icid.py | 3 +- pyikt/stream/tests/test_streakhc.py | 5 +- pyikt/timeseries/__init__.py | 1 - pyikt/timeseries/anomaly/_iktod.py | 7 +- pyikt/timeseries/tests/test_iktod.py | 1 + pyikt/trajectory/__init__.py | 1 - pyikt/trajectory/anomaly/_ikat.py | 4 +- pyikt/trajectory/cluster/_tidkc.py | 6 +- pyikt/trajectory/dataloader/_sheepdogs.py | 6 +- pyikt/trajectory/dataloader/base.py | 1 - pyikt/trajectory/tests/test_ikat.py | 3 +- pyikt/trajectory/tests/test_tidkc.py | 1 + pyikt/trajectory/utils.py | 3 +- pyproject.toml | 2 +- 58 files changed, 731 insertions(+), 750 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index ecc07d8..f2b9d8c 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -1,119 +1,110 @@ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI -on: push +on: + push: + branches: [main] + tags: ['v*'] # Only run on version tags + pull_request: + branches: [main] jobs: - build: - name: Build distribution 📦 - runs-on: ubuntu-latest + build: + name: Build distribution 📦 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + cache: 'pip' # Enable pip caching + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build wheel + - name: Build a binary wheel and a source tarball + run: python -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + retention-days: 7 # Set a reasonable retention period - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.x" - - name: Install pypa/build - run: >- - python3 -m - pip install - build - --user - - name: Build a binary wheel and a source tarball - run: python3 -m build - - name: Store the distribution packages - uses: actions/upload-artifact@v4 - with: - name: python-package-distributions - path: dist/ + publish-to-testpypi: + name: Publish to TestPyPI + needs: [build] + runs-on: ubuntu-latest + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + environment: + name: testpypi + url: https://test.pypi.org/p/pyikt # Update to your actual package name + permissions: + id-token: write + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ - publish-to-pypi: - name: >- - Publish Python 🐍 distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes - needs: - - build - runs-on: ubuntu-latest - environment: - name: pypi - url: https://pypi.org/p/pyikt # Replace pyikt with your PyPI project name - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing + publish-to-pypi: + name: Publish to PyPI + needs: [build] + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + environment: + name: pypi + url: https://pypi.org/p/pyikt # Update to your actual package name + permissions: + id-token: write + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 - steps: - - name: Download all the dists - uses: actions/download-artifact@v4 - with: - name: python-package-distributions - path: dist/ - - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - - github-release: - name: >- - Sign the Python 🐍 distribution 📦 with Sigstore - and upload them to GitHub Release - needs: - - publish-to-pypi - runs-on: ubuntu-latest - - permissions: - contents: write # IMPORTANT: mandatory for making GitHub Releases - id-token: write # IMPORTANT: mandatory for sigstore - - steps: - - name: Download all the dists - uses: actions/download-artifact@v4 - with: - name: python-package-distributions - path: dist/ - - name: Sign the dists with Sigstore - uses: sigstore/gh-action-sigstore-python@v3.0.0 - with: - inputs: >- - ./dist/*.tar.gz - ./dist/*.whl - - name: Create GitHub Release - env: - GITHUB_TOKEN: ${{ github.token }} - run: >- - gh release create - "$GITHUB_REF_NAME" - --repo "$GITHUB_REPOSITORY" - --notes "" - - name: Upload artifact signatures to GitHub Release - env: - GITHUB_TOKEN: ${{ github.token }} - # Upload to GitHub Release using the `gh` CLI. - # `dist/` contains the built packages, and the - # sigstore-produced signatures and certificates. - run: >- - gh release upload - "$GITHUB_REF_NAME" dist/** - --repo "$GITHUB_REPOSITORY" - - publish-to-testpypi: - name: Publish Python 🐍 distribution 📦 to TestPyPI - needs: - - build - runs-on: ubuntu-latest - - environment: - name: testpypi - url: https://test.pypi.org/p/pyikt - - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing - - steps: - - name: Download all the dists - uses: actions/download-artifact@v4 - with: - name: python-package-distributions - path: dist/ - - name: Publish distribution 📦 to TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ \ No newline at end of file + github-release: + name: Create GitHub Release + needs: [publish-to-pypi] + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + permissions: + contents: write + id-token: write + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v3.0.0 + with: + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: Extract release notes + id: extract-release-notes + run: | + version=${GITHUB_REF_NAME#v} + echo "version=$version" >> $GITHUB_OUTPUT + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: | + gh release create "$GITHUB_REF_NAME" \ + --repo "$GITHUB_REPOSITORY" \ + --title "Release $GITHUB_REF_NAME" \ + --notes "Release $GITHUB_REF_NAME" + - name: Upload artifacts to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: gh release upload "$GITHUB_REF_NAME" dist/** --repo "$GITHUB_REPOSITORY" diff --git a/pixi.lock b/pixi.lock index 2d73ec1..9e1e677 100644 --- a/pixi.lock +++ b/pixi.lock @@ -2428,8 +2428,6 @@ packages: - libgcc >=13 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: @@ -2444,8 +2442,6 @@ packages: - cffi >=1.0.1 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: @@ -2461,8 +2457,6 @@ packages: - python >=3.10,<3.11.0a0 - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: @@ -2479,8 +2473,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: MIT license_family: MIT purls: @@ -2548,8 +2540,6 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - tomli >=1.1.0 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: @@ -2568,8 +2558,6 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - tomli >=1.1.0 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: @@ -2589,8 +2577,6 @@ packages: - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - tomli >=1.1.0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: @@ -2609,8 +2595,6 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - tomli >=1.1.0 - arch: x86_64 - platform: win license: MIT license_family: MIT purls: @@ -2936,8 +2920,6 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - tomli - arch: x86_64 - platform: linux license: Apache-2.0 license_family: APACHE purls: @@ -2952,8 +2934,6 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - tomli - arch: x86_64 - platform: osx license: Apache-2.0 license_family: APACHE purls: @@ -2969,8 +2949,6 @@ packages: - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - tomli - arch: arm64 - platform: osx license: Apache-2.0 license_family: APACHE purls: @@ -2987,8 +2965,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: Apache-2.0 license_family: APACHE purls: @@ -3015,8 +2991,6 @@ packages: - libstdcxx >=13 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: @@ -3031,8 +3005,6 @@ packages: - libcxx >=18 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: @@ -3048,8 +3020,6 @@ packages: - python >=3.10,<3.11.0a0 - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: @@ -3065,8 +3035,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: MIT license_family: MIT purls: @@ -3201,8 +3169,6 @@ packages: depends: - libgcc-ng >=12 - libstdcxx-ng >=12 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: [] @@ -3211,8 +3177,6 @@ packages: - conda: https://conda.anaconda.org/conda-forge/osx-64/icu-73.2-hf5e326d_0.conda sha256: f66362dc36178ac9b7c7a9b012948a9d2d050b3debec24bbd94aadbc44854185 md5: 5cc301d759ec03f28328428e28f65591 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: [] @@ -3221,8 +3185,6 @@ packages: - conda: https://conda.anaconda.org/conda-forge/osx-arm64/icu-73.2-hc8870d7_0.conda sha256: ff9cd0c6cd1349954c801fb443c94192b637e1b414514539f3c49c56a39f51b1 md5: 8521bd47c0e11c5902535bb1a17c565f - arch: arm64 - platform: osx license: MIT license_family: MIT purls: [] @@ -3233,8 +3195,6 @@ packages: md5: 5eb22c1d7b3fc4abb50d92d621583137 depends: - __osx >=11.0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: [] @@ -3608,8 +3568,6 @@ packages: - python_abi 3.10.* *_cp310 - pywin32 >=300 - traitlets >=5.3 - arch: x86_64 - platform: win license: BSD-3-Clause license_family: BSD purls: @@ -3700,8 +3658,6 @@ packages: md5: 30186d27e2c9fa62b45fb1476b7200e3 depends: - libgcc-ng >=10.3.0 - arch: x86_64 - platform: linux license: LGPL-2.1-or-later purls: [] size: 117831 @@ -3716,8 +3672,6 @@ packages: - libgcc-ng >=12 - libstdcxx-ng >=12 - openssl >=3.3.1,<4.0a0 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: [] @@ -3732,8 +3686,6 @@ packages: - libedit >=3.1.20191231,<3.2.0a0 - libedit >=3.1.20191231,<4.0a0 - openssl >=3.3.1,<4.0a0 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: [] @@ -3748,8 +3700,6 @@ packages: - libedit >=3.1.20191231,<3.2.0a0 - libedit >=3.1.20191231,<4.0a0 - openssl >=3.3.1,<4.0a0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: [] @@ -3763,8 +3713,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: MIT license_family: MIT purls: [] @@ -3939,8 +3887,6 @@ packages: - __glibc >=2.17,<3.0.a0 - libgcc >=13 - ncurses >=6.5,<7.0a0 - arch: x86_64 - platform: linux license: BSD-2-Clause license_family: BSD purls: [] @@ -3953,8 +3899,6 @@ packages: - ncurses - __osx >=10.13 - ncurses >=6.5,<7.0a0 - arch: x86_64 - platform: osx license: BSD-2-Clause license_family: BSD purls: [] @@ -3967,8 +3911,6 @@ packages: - ncurses - __osx >=11.0 - ncurses >=6.5,<7.0a0 - arch: arm64 - platform: osx license: BSD-2-Clause license_family: BSD purls: [] @@ -4144,8 +4086,6 @@ packages: depends: - __glibc >=2.17,<3.0.a0 - libgcc >=13 - arch: x86_64 - platform: linux license: LGPL-2.1-only purls: [] size: 713084 @@ -4155,8 +4095,6 @@ packages: md5: 6283140d7b2b55b6b095af939b71b13f depends: - __osx >=10.13 - arch: x86_64 - platform: osx license: LGPL-2.1-only purls: [] size: 669052 @@ -4166,8 +4104,6 @@ packages: md5: 450e6bdc0c7d986acf7b8443dce87111 depends: - __osx >=11.0 - arch: arm64 - platform: osx license: LGPL-2.1-only purls: [] size: 681804 @@ -4490,8 +4426,6 @@ packages: md5: a587892d3c13b6621a6091be690dbca2 depends: - libgcc-ng >=12 - arch: x86_64 - platform: linux license: ISC purls: [] size: 205978 @@ -4501,8 +4435,6 @@ packages: md5: 6af4b059e26492da6013e79cbcb4d069 depends: - __osx >=10.13 - arch: x86_64 - platform: osx license: ISC purls: [] size: 210249 @@ -4512,8 +4444,6 @@ packages: md5: a7ce36e284c5faaf93c220dfc39e3abd depends: - __osx >=11.0 - arch: arm64 - platform: osx license: ISC purls: [] size: 164972 @@ -4525,8 +4455,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: ISC purls: [] size: 202344 @@ -4651,8 +4579,6 @@ packages: - libiconv >=1.17,<2.0a0 - libzlib >=1.2.13,<2.0a0 - xz >=5.2.6,<6.0a0 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: [] @@ -4669,8 +4595,6 @@ packages: - libzlib >=1.3.1,<2.0a0 constrains: - icu <0.0a0 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: [] @@ -4685,8 +4609,6 @@ packages: - libiconv >=1.17,<2.0a0 - libzlib >=1.2.13,<2.0a0 - xz >=5.2.6,<6.0a0 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: [] @@ -4702,8 +4624,6 @@ packages: - libzlib >=1.3.1,<2.0a0 constrains: - icu <0.0a0 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: [] @@ -4718,8 +4638,6 @@ packages: - libiconv >=1.17,<2.0a0 - libzlib >=1.2.13,<2.0a0 - xz >=5.2.6,<6.0a0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: [] @@ -4734,8 +4652,6 @@ packages: - libiconv >=1.17,<2.0a0 - liblzma >=5.6.3,<6.0a0 - libzlib >=1.3.1,<2.0a0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: [] @@ -4775,8 +4691,6 @@ packages: depends: - libgcc-ng >=12 - libxml2 >=2.12.1,<3.0.0a0 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: [] @@ -4787,8 +4701,6 @@ packages: md5: a6e0cec6b3517ffc6b5d36a920fc9312 depends: - libxml2 >=2.12.1,<3.0.0a0 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: [] @@ -4799,8 +4711,6 @@ packages: md5: 560c9cacc33e927f55b998eaa0cb1732 depends: - libxml2 >=2.12.1,<3.0.0a0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: [] @@ -4814,8 +4724,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: MIT license_family: MIT purls: [] @@ -5081,8 +4989,6 @@ packages: - libzlib >=1.2.13,<2.0.0a0 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: linux license: BSD-3-Clause and MIT-CMU purls: - pkg:pypi/lxml?source=hash-mapping @@ -5099,8 +5005,6 @@ packages: - libzlib >=1.3.1,<2.0a0 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: linux license: BSD-3-Clause and MIT-CMU purls: - pkg:pypi/lxml?source=hash-mapping @@ -5116,8 +5020,6 @@ packages: - libzlib >=1.2.13,<2.0.0a0 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: osx license: BSD-3-Clause and MIT-CMU purls: - pkg:pypi/lxml?source=hash-mapping @@ -5133,8 +5035,6 @@ packages: - libzlib >=1.3.1,<2.0a0 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: osx license: BSD-3-Clause and MIT-CMU purls: - pkg:pypi/lxml?source=hash-mapping @@ -5151,8 +5051,6 @@ packages: - python >=3.10,<3.11.0a0 - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - arch: arm64 - platform: osx license: BSD-3-Clause and MIT-CMU purls: - pkg:pypi/lxml?source=hash-mapping @@ -5169,8 +5067,6 @@ packages: - python >=3.10,<3.11.0a0 - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - arch: arm64 - platform: osx license: BSD-3-Clause and MIT-CMU purls: - pkg:pypi/lxml?source=hash-mapping @@ -5188,8 +5084,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: BSD-3-Clause and MIT-CMU purls: - pkg:pypi/lxml?source=hash-mapping @@ -5207,8 +5101,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: BSD-3-Clause and MIT-CMU purls: - pkg:pypi/lxml?source=hash-mapping @@ -5300,8 +5192,6 @@ packages: - python_abi 3.10.* *_cp310 constrains: - jinja2 >=3.0.0 - arch: x86_64 - platform: linux license: BSD-3-Clause license_family: BSD purls: @@ -5317,8 +5207,6 @@ packages: - python_abi 3.10.* *_cp310 constrains: - jinja2 >=3.0.0 - arch: x86_64 - platform: osx license: BSD-3-Clause license_family: BSD purls: @@ -5335,8 +5223,6 @@ packages: - python_abi 3.10.* *_cp310 constrains: - jinja2 >=3.0.0 - arch: arm64 - platform: osx license: BSD-3-Clause license_family: BSD purls: @@ -5354,8 +5240,6 @@ packages: - vc14_runtime >=14.29.30139 constrains: - jinja2 >=3.0.0 - arch: x86_64 - platform: win license: BSD-3-Clause license_family: BSD purls: @@ -6538,8 +6422,6 @@ packages: - conda: https://conda.anaconda.org/conda-forge/linux-64/pandoc-3.6.3-ha770c72_0.conda sha256: a7392b0d5403676b0b3ab9ff09c1e65d8ab9e1c34349bba9be605d76cf622640 md5: 16ff7c679250dc09f9732aab14408d2c - arch: x86_64 - platform: linux license: GPL-2.0-or-later license_family: GPL purls: [] @@ -6548,8 +6430,6 @@ packages: - conda: https://conda.anaconda.org/conda-forge/osx-64/pandoc-3.6.3-h694c41f_0.conda sha256: 1133230f40d30e3eaa03e209800800751423360193fdc7e6523771125b72daa8 md5: eb1ef420766e7f9bd8f61a2bc7c2961d - arch: x86_64 - platform: osx license: GPL-2.0-or-later license_family: GPL purls: [] @@ -6558,8 +6438,6 @@ packages: - conda: https://conda.anaconda.org/conda-forge/osx-arm64/pandoc-3.6.3-hce30654_0.conda sha256: 2013114d2405b4a4e9d9b62522eb09111e1b9e3cd2e902a42e7ccc8a88a2b05a md5: 41603d280df06636257acd79ea326be9 - arch: arm64 - platform: osx license: GPL-2.0-or-later license_family: GPL purls: [] @@ -6568,8 +6446,6 @@ packages: - conda: https://conda.anaconda.org/conda-forge/win-64/pandoc-3.6.3-h57928b3_0.conda sha256: ffdb8fd1da7419f6625c8b2339a12f9669a705ada4177b763cc796c60763f734 md5: 9b999036cccf0d5a94ed3c0b0edbb905 - arch: x86_64 - platform: win license: GPL-2.0-or-later license_family: GPL purls: [] @@ -6725,8 +6601,6 @@ packages: - libgcc >=13 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: linux license: BSD-3-Clause license_family: BSD purls: @@ -6740,8 +6614,6 @@ packages: - __osx >=10.13 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: osx license: BSD-3-Clause license_family: BSD purls: @@ -6756,8 +6628,6 @@ packages: - python >=3.10,<3.11.0a0 - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - arch: arm64 - platform: osx license: BSD-3-Clause license_family: BSD purls: @@ -6773,8 +6643,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: BSD-3-Clause license_family: BSD purls: @@ -6848,12 +6716,12 @@ packages: timestamp: 1736243563082 - pypi: . name: pyikt - version: 0.0.0 - sha256: 44d7e5a7a3d3f511455889d8501dba6f9e58c8a36da7fb2806c84ec4fcb68883 + version: 0.1.dev151 + sha256: 0e602c12a91f83e11fd62e4d2ea842e14106dceb1d6c4bbee50a3f79903faf86 requires_dist: - - numpy<=1.22 - - pandas>=1.5 - scikit-learn>=1.2 + - pandas>=1.5 + - numpy<=1.22 - numba>=0.54 - tqdm>=4.62.3 requires_python: '>=3.9' @@ -6880,8 +6748,6 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - setuptools - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: @@ -6898,8 +6764,6 @@ packages: - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - setuptools - arch: arm64 - platform: osx license: MIT license_family: MIT purls: @@ -6915,8 +6779,6 @@ packages: - pyobjc-core 11.0.* - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: @@ -6933,8 +6795,6 @@ packages: - python >=3.10,<3.11.0a0 - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: @@ -7286,8 +7146,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: PSF-2.0 license_family: PSF purls: @@ -7304,8 +7162,6 @@ packages: - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - winpty - arch: x86_64 - platform: win license: MIT license_family: MIT purls: @@ -7321,8 +7177,6 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - yaml >=0.2.5,<0.3.0a0 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: @@ -7337,8 +7191,6 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - yaml >=0.2.5,<0.3.0a0 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: @@ -7354,8 +7206,6 @@ packages: - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - yaml >=0.2.5,<0.3.0a0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: @@ -7372,8 +7222,6 @@ packages: - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - yaml >=0.2.5,<0.3.0a0 - arch: x86_64 - platform: win license: MIT license_family: MIT purls: @@ -7403,8 +7251,6 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - zeromq >=4.3.5,<4.4.0a0 - arch: x86_64 - platform: linux license: BSD-3-Clause license_family: BSD purls: @@ -7421,8 +7267,6 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - zeromq >=4.3.5,<4.4.0a0 - arch: x86_64 - platform: osx license: BSD-3-Clause license_family: BSD purls: @@ -7440,8 +7284,6 @@ packages: - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - zeromq >=4.3.5,<4.4.0a0 - arch: arm64 - platform: osx license: BSD-3-Clause license_family: BSD purls: @@ -7459,8 +7301,6 @@ packages: - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - zeromq >=4.3.5,<4.3.6.0a0 - arch: x86_64 - platform: win license: BSD-3-Clause license_family: BSD purls: @@ -7521,8 +7361,6 @@ packages: - libgcc >=13 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: linux license: Python-2.0 license_family: PSF purls: @@ -7536,8 +7374,6 @@ packages: - __osx >=10.13 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: osx license: Python-2.0 license_family: PSF purls: @@ -7552,8 +7388,6 @@ packages: - python >=3.10,<3.11.0a0 - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - arch: arm64 - platform: osx license: Python-2.0 license_family: PSF purls: @@ -7569,8 +7403,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: Python-2.0 license_family: PSF purls: @@ -7604,8 +7436,6 @@ packages: - python_abi 3.10.* *_cp310 constrains: - __glibc >=2.17 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: @@ -7621,8 +7451,6 @@ packages: - python_abi 3.10.* *_cp310 constrains: - __osx >=10.13 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: @@ -7639,8 +7467,6 @@ packages: - python_abi 3.10.* *_cp310 constrains: - __osx >=11.0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: @@ -7659,8 +7485,6 @@ packages: - vc14_runtime >=14.29.30139 - ucrt >=10.0.20348.0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: win license: MIT license_family: MIT purls: @@ -7675,8 +7499,6 @@ packages: - libstdcxx-ng >=12 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: @@ -7693,8 +7515,6 @@ packages: - python_abi 3.10.* *_cp310 constrains: - __osx >=10.12 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: @@ -7712,8 +7532,6 @@ packages: - python_abi 3.10.* *_cp310 constrains: - __osx >=11.0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: @@ -7729,8 +7547,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: MIT license_family: MIT purls: @@ -8152,8 +7968,6 @@ packages: - libgcc >=13 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: linux license: Apache-2.0 license_family: Apache purls: @@ -8167,8 +7981,6 @@ packages: - __osx >=10.13 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: osx license: Apache-2.0 license_family: Apache purls: @@ -8183,8 +7995,6 @@ packages: - python >=3.10,<3.11.0a0 - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - arch: arm64 - platform: osx license: Apache-2.0 license_family: Apache purls: @@ -8200,8 +8010,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: Apache-2.0 license_family: Apache purls: @@ -8213,7 +8021,7 @@ packages: version: 4.67.1 sha256: 26445eca388f82e72884e0d580d5464cd801a3ea01e63e5601bdff9ba6a48de2 requires_dist: - - colorama ; platform_system == 'Windows' + - colorama ; sys_platform == 'win32' - pytest>=6 ; extra == 'dev' - pytest-cov ; extra == 'dev' - pytest-timeout ; extra == 'dev' @@ -8288,8 +8096,6 @@ packages: - libstdcxx >=13 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: @@ -8305,8 +8111,6 @@ packages: - libcxx >=17 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: @@ -8323,8 +8127,6 @@ packages: - python >=3.10,<3.11.0a0 - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: @@ -8341,8 +8143,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: MIT license_family: MIT purls: @@ -8431,8 +8231,6 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - pyyaml >=3.10 - arch: x86_64 - platform: linux license: Apache-2.0 license_family: APACHE purls: @@ -8447,8 +8245,6 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - pyyaml >=3.10 - arch: x86_64 - platform: osx license: Apache-2.0 license_family: APACHE purls: @@ -8464,8 +8260,6 @@ packages: - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - pyyaml >=3.10 - arch: arm64 - platform: osx license: Apache-2.0 license_family: APACHE purls: @@ -8479,8 +8273,6 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - pyyaml >=3.10 - arch: x86_64 - platform: win license: Apache-2.0 license_family: APACHE purls: @@ -8660,8 +8452,6 @@ packages: md5: 4cb3ad778ec2d5a7acbdf254eb1c42ae depends: - libgcc-ng >=9.4.0 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: [] @@ -8670,8 +8460,6 @@ packages: - conda: https://conda.anaconda.org/conda-forge/osx-64/yaml-0.2.5-h0d85af4_2.tar.bz2 sha256: 5301417e2c8dea45b401ffee8df3957d2447d4ce80c83c5ff151fc6bfe1c4148 md5: d7e08fcf8259d742156188e8762b4d20 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: [] @@ -8680,8 +8468,6 @@ packages: - conda: https://conda.anaconda.org/conda-forge/osx-arm64/yaml-0.2.5-h3422bc3_2.tar.bz2 sha256: 93181a04ba8cfecfdfb162fc958436d868cc37db504c58078eab4c1a3e57fbb7 md5: 4bb3f014845110883a3c5ee811fd84b4 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: [] @@ -8693,8 +8479,6 @@ packages: depends: - vc >=14.1,<15.0a0 - vs2015_runtime >=14.16.27012 - arch: x86_64 - platform: win license: MIT license_family: MIT purls: [] @@ -8709,8 +8493,6 @@ packages: - libgcc >=13 - libsodium >=1.0.20,<1.0.21.0a0 - libstdcxx >=13 - arch: x86_64 - platform: linux license: MPL-2.0 license_family: MOZILLA purls: [] @@ -8724,8 +8506,6 @@ packages: - krb5 >=1.21.3,<1.22.0a0 - libcxx >=18 - libsodium >=1.0.20,<1.0.21.0a0 - arch: x86_64 - platform: osx license: MPL-2.0 license_family: MOZILLA purls: [] @@ -8739,8 +8519,6 @@ packages: - krb5 >=1.21.3,<1.22.0a0 - libcxx >=18 - libsodium >=1.0.20,<1.0.21.0a0 - arch: arm64 - platform: osx license: MPL-2.0 license_family: MOZILLA purls: [] @@ -8755,8 +8533,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: MPL-2.0 license_family: MOZILLA purls: [] diff --git a/pyikt/__init__.py b/pyikt/__init__.py index e04b09a..55027d2 100644 --- a/pyikt/__init__.py +++ b/pyikt/__init__.py @@ -8,31 +8,15 @@ work. If not, see . """ -from .kernel import IsoKernel -from .kernel import IsoDisKernel - -from .anomaly import IDKD -from .anomaly import INNE - -from .cluster import IDKC -from .cluster import PSKC -from .cluster import IKAHC - -from .graph import IsoGraphKernel -from .graph import IKGOD - +from ._version import __version__ +from .anomaly import IDKD, INNE +from .cluster import IDKC, IKAHC, PSKC +from .graph import IKGOD, IsoGraphKernel from .group import IKGAD - - -from .trajectory import IKAT -from .trajectory import TIDKC - -from .stream import ICID -from .stream import STREAMKHC - +from .kernel import IsoDisKernel, IsoKernel +from .stream import ICID, STREAMKHC from .timeseries import IKTOD - -from ._version import __version__ +from .trajectory import IKAT, TIDKC __all__ = [ "IsoDisKernel", diff --git a/pyikt/anomaly/__init__.py b/pyikt/anomaly/__init__.py index eb83102..5cf941e 100644 --- a/pyikt/anomaly/__init__.py +++ b/pyikt/anomaly/__init__.py @@ -9,7 +9,7 @@ """ from ._idkd import IDKD -from ._inne import INNE from ._iforest import IForest +from ._inne import INNE __all__ = ["IDKD", "INNE", "IForest"] diff --git a/pyikt/anomaly/_idkd.py b/pyikt/anomaly/_idkd.py index d7a8cd1..a0b0f56 100644 --- a/pyikt/anomaly/_idkd.py +++ b/pyikt/anomaly/_idkd.py @@ -10,11 +10,13 @@ import numbers from warnings import warn + import numpy as np from sklearn.base import BaseEstimator, OutlierMixin -from sklearn.utils.validation import check_is_fitted from sklearn.utils import check_array from sklearn.utils.extmath import safe_sparse_dot +from sklearn.utils.validation import check_is_fitted + from pyikt.kernel import IsoKernel diff --git a/pyikt/anomaly/_iforest.py b/pyikt/anomaly/_iforest.py index 067a4cf..22d9a98 100644 --- a/pyikt/anomaly/_iforest.py +++ b/pyikt/anomaly/_iforest.py @@ -10,9 +10,9 @@ import numpy as np from sklearn.base import BaseEstimator, OutlierMixin -from sklearn.utils.validation import check_is_fitted -from sklearn.utils import check_array from sklearn.ensemble import IsolationForest +from sklearn.utils import check_array +from sklearn.utils.validation import check_is_fitted MAX_INT = np.iinfo(np.int32).max MIN_FLOAT = np.finfo(float).eps @@ -112,7 +112,7 @@ def __init__( random_state=None, verbose=0, ): - self.contamination=contamination + self.contamination = contamination self.n_estimators = n_estimators self.max_samples = max_samples self.max_features = max_features diff --git a/pyikt/anomaly/_inne.py b/pyikt/anomaly/_inne.py index 1feeca4..6487f90 100644 --- a/pyikt/anomaly/_inne.py +++ b/pyikt/anomaly/_inne.py @@ -10,12 +10,13 @@ import numbers from warnings import warn + import numpy as np from sklearn.base import BaseEstimator, OutlierMixin from sklearn.metrics import euclidean_distances -from sklearn.utils.validation import check_is_fitted, check_random_state -from sklearn.utils import check_array from sklearn.metrics._pairwise_distances_reduction import ArgKmin +from sklearn.utils import check_array +from sklearn.utils.validation import check_is_fitted, check_random_state MAX_INT = np.iinfo(np.int32).max MIN_FLOAT = np.finfo(float).eps @@ -161,7 +162,6 @@ def fit(self, X, y=None): return self def _fit(self, X): - n_samples, n_features = X.shape self._centroids = np.empty([self.n_estimators, self.max_samples_, n_features]) self._ratio = np.empty([self.n_estimators, self.max_samples_]) diff --git a/pyikt/anomaly/tests/test_idkd.py b/pyikt/anomaly/tests/test_idkd.py index 32f3938..ccd2c84 100644 --- a/pyikt/anomaly/tests/test_idkd.py +++ b/pyikt/anomaly/tests/test_idkd.py @@ -4,9 +4,10 @@ license that can be found in the LICENSE file. """ -from sklearn.datasets import load_iris import numpy as np import pytest +from sklearn.datasets import load_iris + from pyikt.anomaly import IDKD method = ["inne", "anne"] diff --git a/pyikt/anomaly/tests/test_inne.py b/pyikt/anomaly/tests/test_inne.py index 243ff9d..4c7436d 100644 --- a/pyikt/anomaly/tests/test_inne.py +++ b/pyikt/anomaly/tests/test_inne.py @@ -6,11 +6,11 @@ import numpy as np import pytest -from pyikt.anomaly import INNE from sklearn.datasets import ( load_diabetes, load_iris, ) +from sklearn.ensemble import IsolationForest from sklearn.metrics import roc_auc_score from sklearn.model_selection import ParameterGrid from sklearn.utils import check_random_state @@ -19,7 +19,7 @@ ignore_warnings, ) -from sklearn.ensemble import IsolationForest +from pyikt.anomaly import INNE rng = check_random_state(0) diff --git a/pyikt/cluster/__init__.py b/pyikt/cluster/__init__.py index 020f895..183df1b 100644 --- a/pyikt/cluster/__init__.py +++ b/pyikt/cluster/__init__.py @@ -2,8 +2,8 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. -from ._pskc import PSKC -from ._ikahc import IKAHC from ._idkc import IDKC +from ._ikahc import IKAHC +from ._pskc import PSKC __all__ = ["PSKC", "IKAHC", "IDKC"] diff --git a/pyikt/cluster/_idkc.py b/pyikt/cluster/_idkc.py index 4633341..0275ee4 100644 --- a/pyikt/cluster/_idkc.py +++ b/pyikt/cluster/_idkc.py @@ -10,11 +10,13 @@ import numpy as np import scipy.sparse as sp -from sklearn.utils.extmath import safe_sparse_dot from sklearn.base import BaseEstimator, ClusterMixin -from sklearn.utils.validation import check_random_state, check_array from sklearn.metrics._pairwise_distances_reduction import ArgKmin +from sklearn.utils.extmath import safe_sparse_dot +from sklearn.utils.validation import check_array, check_random_state + from pyikt.kernel import IsoKernel + from ._kcluster import KCluster diff --git a/pyikt/cluster/_ikahc.py b/pyikt/cluster/_ikahc.py index 9c4f30b..6e68e87 100644 --- a/pyikt/cluster/_ikahc.py +++ b/pyikt/cluster/_ikahc.py @@ -8,13 +8,13 @@ work. If not, see . """ -from typing import Optional, Union, Literal, Any +from typing import Any, Literal, Optional, Union import numpy as np -from scipy.cluster.hierarchy import linkage, fcluster +from scipy.cluster.hierarchy import fcluster, linkage from sklearn.base import BaseEstimator, ClusterMixin -from sklearn.utils.validation import check_is_fitted from sklearn.utils import check_array +from sklearn.utils.validation import check_is_fitted from pyikt.kernel import IsoKernel @@ -233,7 +233,6 @@ def _extract_flat_cluster( else: return fcluster(self.dendrogram_, t=n_clusters, criterion="maxclust") - def fit_transform(self, X: np.ndarray, y: Any = None) -> np.ndarray: """Fit algorithm to data and return the dendrogram. diff --git a/pyikt/cluster/_kcluster.py b/pyikt/cluster/_kcluster.py index 9673a6e..a48d537 100644 --- a/pyikt/cluster/_kcluster.py +++ b/pyikt/cluster/_kcluster.py @@ -9,8 +9,9 @@ """ from collections.abc import Iterable -from scipy import sparse as sp + import numpy as np +from scipy import sparse as sp class KCluster(object): diff --git a/pyikt/cluster/_pskc.py b/pyikt/cluster/_pskc.py index ede2f27..9182b0b 100644 --- a/pyikt/cluster/_pskc.py +++ b/pyikt/cluster/_pskc.py @@ -9,12 +9,13 @@ """ import numpy as np -from pyikt.kernel import IsoKernel -from sklearn.utils.extmath import safe_sparse_dot from sklearn.base import BaseEstimator, ClusterMixin -from sklearn.utils.validation import check_is_fitted from sklearn.utils import check_array +from sklearn.utils.extmath import safe_sparse_dot +from sklearn.utils.validation import check_is_fitted + from pyikt.cluster._kcluster import KCluster +from pyikt.kernel import IsoKernel class PSKC(BaseEstimator, ClusterMixin): @@ -192,7 +193,6 @@ def _update_cluster( point_indices = np.delete(point_indices, x_id) return c_k, point_indices - def _get_labels(self, X): """Get cluster labels for all points in the dataset.""" n_samples = X.shape[0] diff --git a/pyikt/cluster/_utils.py b/pyikt/cluster/_utils.py index 7cae759..95cb052 100644 --- a/pyikt/cluster/_utils.py +++ b/pyikt/cluster/_utils.py @@ -8,9 +8,9 @@ work. If not, see . """ +import numpy as np import scipy from scipy import sparse -import numpy as np def delete_row_csr(mat, i): diff --git a/pyikt/cluster/tests/test_idkc.py b/pyikt/cluster/tests/test_idkc.py index 19a7b94..e8f61c8 100644 --- a/pyikt/cluster/tests/test_idkc.py +++ b/pyikt/cluster/tests/test_idkc.py @@ -9,9 +9,10 @@ """ import numpy as np +from sklearn import metrics from sklearn.datasets import make_blobs + from pyikt.cluster import IDKC -from sklearn import metrics def test_IDKC(): diff --git a/pyikt/cluster/tests/test_ikahc.py b/pyikt/cluster/tests/test_ikahc.py index 92efbf4..64175c4 100644 --- a/pyikt/cluster/tests/test_ikahc.py +++ b/pyikt/cluster/tests/test_ikahc.py @@ -9,6 +9,7 @@ import numpy as np import pytest + from pyikt.cluster import IKAHC diff --git a/pyikt/cluster/tests/test_pskc.py b/pyikt/cluster/tests/test_pskc.py index 4fbbee1..8104099 100644 --- a/pyikt/cluster/tests/test_pskc.py +++ b/pyikt/cluster/tests/test_pskc.py @@ -7,6 +7,7 @@ import numpy as np import pytest from sklearn.datasets import make_blobs + from pyikt.cluster import PSKC diff --git a/pyikt/graph/__init__.py b/pyikt/graph/__init__.py index e80aa95..6f91a99 100644 --- a/pyikt/graph/__init__.py +++ b/pyikt/graph/__init__.py @@ -8,8 +8,8 @@ work. If not, see . """ -from ._isographkernel import IsoGraphKernel from ._ikgod import IKGOD +from ._isographkernel import IsoGraphKernel __all__ = [ "IsoGraphKernel", diff --git a/pyikt/graph/_ikgod.py b/pyikt/graph/_ikgod.py index 3cbb970..98b4dda 100644 --- a/pyikt/graph/_ikgod.py +++ b/pyikt/graph/_ikgod.py @@ -8,17 +8,18 @@ work. If not, see . """ -import numbers import copy +import numbers from warnings import warn + import numpy as np import scipy.sparse as sp from sklearn.base import BaseEstimator -from sklearn.utils.validation import check_is_fitted from sklearn.utils import check_array from sklearn.utils.extmath import safe_sparse_dot -from pyikt.graph.utils import get_degrees, get_neighbors, check_format +from sklearn.utils.validation import check_is_fitted +from pyikt.graph.utils import check_format, get_degrees, get_neighbors from pyikt.kernel import IsoKernel @@ -300,12 +301,9 @@ def _wlembedding(self, adjacency, X): neighbors = get_neighbors(adjacency, i) if degrees[i] > 0: # Avoid division by zero updated_embedding[i] = ( - ( - tmp_embedding[neighbors].sum(axis=0) / degrees[i] - + tmp_embedding[i] - ) - / 2 - ) + tmp_embedding[neighbors].sum(axis=0) / degrees[i] + + tmp_embedding[i] + ) / 2 else: updated_embedding[i] = tmp_embedding[i] diff --git a/pyikt/graph/_isographkernel.py b/pyikt/graph/_isographkernel.py index 28d3940..293dda0 100644 --- a/pyikt/graph/_isographkernel.py +++ b/pyikt/graph/_isographkernel.py @@ -9,16 +9,18 @@ """ import copy +from typing import Optional, Union from warnings import warn -from typing import Union, Optional + import numpy as np import scipy.sparse as sp from sklearn.base import BaseEstimator from sklearn.utils import check_array -from sklearn.utils.validation import check_is_fitted from sklearn.utils.extmath import safe_sparse_dot +from sklearn.utils.validation import check_is_fitted + +from pyikt.graph.utils import check_format, get_degrees, get_neighbors from pyikt.kernel import IsoKernel -from pyikt.graph.utils import get_degrees, get_neighbors, check_format class IsoGraphKernel(BaseEstimator): diff --git a/pyikt/graph/tests/test_ikgod.py b/pyikt/graph/tests/test_ikgod.py index 73b6a29..e38f938 100644 --- a/pyikt/graph/tests/test_ikgod.py +++ b/pyikt/graph/tests/test_ikgod.py @@ -1,10 +1,9 @@ -import pytest import numpy as np +import pytest +import scipy.sparse as sp from sklearn.datasets import make_blobs -from sklearn.utils.estimator_checks import check_estimator -from pyikt.graph import IKGOD -import scipy.sparse as sp +from pyikt.graph import IKGOD def test_ikgod_initialization(): diff --git a/pyikt/graph/tests/test_isographkernel.py b/pyikt/graph/tests/test_isographkernel.py index d14a16b..77cc162 100644 --- a/pyikt/graph/tests/test_isographkernel.py +++ b/pyikt/graph/tests/test_isographkernel.py @@ -1,9 +1,8 @@ -import pytest import numpy as np -from pyikt.graph import IsoGraphKernel - import scipy.sparse as sp +from pyikt.graph import IsoGraphKernel + def test_isographkernel_initialization(): """Test IsoGraphKernel initialization with default and custom parameters.""" diff --git a/pyikt/graph/utils.py b/pyikt/graph/utils.py index 2eb5efd..59ec0f9 100644 --- a/pyikt/graph/utils.py +++ b/pyikt/graph/utils.py @@ -8,9 +8,10 @@ work. If not, see . """ +from typing import Union + import numpy as np import scipy.sparse as sp -from typing import Union def get_degrees(input_matrix: sp.csr_matrix, transpose: bool = False) -> np.ndarray: diff --git a/pyikt/group/anomaly/_ikgad.py b/pyikt/group/anomaly/_ikgad.py index ea41300..24ac279 100644 --- a/pyikt/group/anomaly/_ikgad.py +++ b/pyikt/group/anomaly/_ikgad.py @@ -10,10 +10,11 @@ import numpy as np from sklearn.base import BaseEstimator, OutlierMixin -from sklearn.utils.validation import check_is_fitted from sklearn.utils.extmath import safe_sparse_dot -from pyikt.kernel import IsoKernel +from sklearn.utils.validation import check_is_fitted + from pyikt.group.utils import check_format +from pyikt.kernel import IsoKernel class IKGAD(OutlierMixin, BaseEstimator): diff --git a/pyikt/group/tests/test_Ikgad.py b/pyikt/group/tests/test_Ikgad.py index ccc7085..9a49c3f 100644 --- a/pyikt/group/tests/test_Ikgad.py +++ b/pyikt/group/tests/test_Ikgad.py @@ -10,6 +10,7 @@ import numpy as np import pytest + from pyikt.group import IKGAD diff --git a/pyikt/group/utils.py b/pyikt/group/utils.py index 2957c0c..a6592d2 100644 --- a/pyikt/group/utils.py +++ b/pyikt/group/utils.py @@ -8,8 +8,9 @@ work. If not, see . """ +from typing import Any, List, Optional, Union + import numpy as np -from typing import Union, List, Any, Optional from sklearn.utils.validation import check_array diff --git a/pyikt/kernel/__init__.py b/pyikt/kernel/__init__.py index 8e37672..4757639 100644 --- a/pyikt/kernel/__init__.py +++ b/pyikt/kernel/__init__.py @@ -8,8 +8,8 @@ work. If not, see . """ -from ._isokernel import IsoKernel from ._isodiskernel import IsoDisKernel +from ._isokernel import IsoKernel __all__ = [ "IsoDisKernel", diff --git a/pyikt/kernel/_ik_iforest.py b/pyikt/kernel/_ik_iforest.py index 91c3c47..8f5b8e1 100644 --- a/pyikt/kernel/_ik_iforest.py +++ b/pyikt/kernel/_ik_iforest.py @@ -8,14 +8,8 @@ work. If not, see . """ -import numbers -from warnings import warn - import numpy as np from sklearn.base import BaseEstimator, TransformerMixin -from sklearn.metrics import euclidean_distances -from sklearn.utils import check_array -from sklearn.utils.validation import check_is_fitted, check_random_state MAX_INT = np.iinfo(np.int32).max MIN_FLOAT = np.finfo(float).eps @@ -65,5 +59,4 @@ class IK_IForest(TransformerMixin, BaseEstimator): """ def __init__(self): - pass diff --git a/pyikt/kernel/_isodiskernel.py b/pyikt/kernel/_isodiskernel.py index c6ee633..c01f782 100644 --- a/pyikt/kernel/_isodiskernel.py +++ b/pyikt/kernel/_isodiskernel.py @@ -9,11 +9,13 @@ """ import math + import numpy as np import scipy.sparse as sp from sklearn.base import BaseEstimator, TransformerMixin from sklearn.utils import check_array from sklearn.utils.validation import check_is_fitted + from pyikt.kernel import IsoKernel diff --git a/pyikt/kernel/_isokernel.py b/pyikt/kernel/_isokernel.py index 05cb78a..5d05b74 100644 --- a/pyikt/kernel/_isokernel.py +++ b/pyikt/kernel/_isokernel.py @@ -10,11 +10,13 @@ import numbers from warnings import warn + import scipy.sparse as sp +from sklearn.base import BaseEstimator, TransformerMixin from sklearn.utils import check_array -from sklearn.utils.validation import check_is_fitted from sklearn.utils.extmath import safe_sparse_dot -from sklearn.base import BaseEstimator, TransformerMixin +from sklearn.utils.validation import check_is_fitted + from pyikt.kernel._ik_anne import IK_ANNE from pyikt.kernel._ik_iforest import IK_IForest from pyikt.kernel._ik_inne import IK_INNE diff --git a/pyikt/kernel/tests/test_isodiskernel.py b/pyikt/kernel/tests/test_isodiskernel.py index 69d9df9..74f371a 100644 --- a/pyikt/kernel/tests/test_isodiskernel.py +++ b/pyikt/kernel/tests/test_isodiskernel.py @@ -4,9 +4,10 @@ license that can be found in the LICENSE file. """ +import pytest from sklearn.datasets import load_iris + from pyikt.kernel import IsoDisKernel -import pytest method = ["inne", "anne"] diff --git a/pyikt/kernel/tests/test_isokernel.py b/pyikt/kernel/tests/test_isokernel.py index 0854154..6fd858d 100644 --- a/pyikt/kernel/tests/test_isokernel.py +++ b/pyikt/kernel/tests/test_isokernel.py @@ -4,9 +4,10 @@ license that can be found in the LICENSE file. """ +import pytest from sklearn.datasets import load_iris + from pyikt import IsoKernel -import pytest method = ["inne", "anne"] diff --git a/pyikt/stream/changedetect/_icid.py b/pyikt/stream/changedetect/_icid.py index 0df2c9e..5b3de24 100644 --- a/pyikt/stream/changedetect/_icid.py +++ b/pyikt/stream/changedetect/_icid.py @@ -9,21 +9,22 @@ """ import numpy as np +from scipy.stats import entropy from sklearn.base import BaseEstimator -from sklearn.utils.validation import check_is_fitted from sklearn.utils import check_array +from sklearn.utils.validation import check_is_fitted + from pyikt.kernel import IsoDisKernel -from scipy.stats import entropy class ICID(BaseEstimator): """Isolate Change Interval Detection for monitoring data stream distribution changes. - ICID (Isolate Change Interval Detection) is designed to detect intervals in a data stream - where significant distribution changes occur. It leverages isolation-based methods to - measure similarity between consecutive data windows, identifying points where the - underlying distribution shifts. The algorithm adaptively selects the best sampling - parameters for isolation kernels based on stability metrics. + ICID (Isolate Change Interval Detection) is designed to detect intervals in a data + stream where significant distribution changes occur. It leverages isolation-based + methods to measure similarity between consecutive data windows, identifying points + where the underlying distribution shifts. The algorithm adaptively selects the best + sampling parameters for isolation kernels based on stability metrics. Parameters ---------- @@ -93,7 +94,7 @@ class ICID(BaseEstimator): >>> X_anomaly = np.random.randn(10, 2) * 5 + 10 # Different distribution >>> X_normal2 = np.random.randn(20, 2) >>> X = np.vstack([X_normal1, X_anomaly, X_normal2]) - >>> icid = ICID( n_estimators=50, max_samples_list=[4, 8], window_size=10, random_state=42) + >>> icid = ICID(n_estimators=50, max_samples_list=[4, 8], window_size=10, random_state=42) >>> # Batch predictions >>> icid.fit_predict_batch(X) array([ 1, 1, 1, 1, -1, -1, 1]) @@ -177,9 +178,9 @@ def fit_predict_batch(self, X): self.fit(X) is_inlier = np.ones(len(self.interval_score_), dtype=int) threshold = self._determine_anomaly_bounds() - is_inlier[self.interval_score_ > threshold] = ( - -1 - ) # Higher scores indicate change + is_inlier[ + self.interval_score_ > threshold + ] = -1 # Higher scores indicate change return is_inlier def predict_online(self, X): diff --git a/pyikt/stream/cluster/_inode.py b/pyikt/stream/cluster/_inode.py index 328185d..482e649 100644 --- a/pyikt/stream/cluster/_inode.py +++ b/pyikt/stream/cluster/_inode.py @@ -12,7 +12,7 @@ import random import string from collections import defaultdict, deque -from typing import List, Tuple, Dict, Optional, Any, Union, Set +from typing import Dict, List, Optional, Tuple import numpy as np from numba import jit diff --git a/pyikt/stream/cluster/_streakhc.py b/pyikt/stream/cluster/_streakhc.py index ce9e00d..d110c3d 100644 --- a/pyikt/stream/cluster/_streakhc.py +++ b/pyikt/stream/cluster/_streakhc.py @@ -10,13 +10,15 @@ from __future__ import annotations -from sklearn.base import BaseEstimator, ClusterMixin -from sklearn.utils.validation import check_is_fitted, check_X_y, check_array -from typing import Optional, Union, Any, Literal +from typing import Literal, Optional, Union + import numpy as np +from sklearn.base import BaseEstimator, ClusterMixin +from sklearn.utils.validation import check_array, check_is_fitted, check_X_y -from ._inode import INODE from pyikt.kernel import IsoKernel + +from ._inode import INODE from .utils.dendrogram_purity import dendrogram_purity from .utils.Graphviz import Graphviz from .utils.serialize_trees import serliaze_tree_to_file diff --git a/pyikt/stream/cluster/utils/Graphviz.py b/pyikt/stream/cluster/utils/Graphviz.py index 9fd756c..01dedf3 100644 --- a/pyikt/stream/cluster/utils/Graphviz.py +++ b/pyikt/stream/cluster/utils/Graphviz.py @@ -2,40 +2,141 @@ class Graphviz(object): def __init__(self): self.internal_color = "lavenderblush4" self.colors = [ - "aquamarine", "bisque", "blue", "blueviolet", "brown", "cadetblue", - "chartreuse", "coral", "cornflowerblue", "crimson", "darkgoldenrod", - "darkgreen", "darkkhaki", "darkmagenta", "darkorange", "darkred", - "darksalmon", "darkseagreen", "darkslateblue", "darkslategrey", - "darkviolet", "deepskyblue", "dodgerblue", "firebrick", - "forestgreen", "gainsboro", "ghostwhite", "gold", "goldenrod", - "gray", "grey", "green", "greenyellow", "honeydew", "hotpink", - "indianred", "indigo", "ivory", "khaki", "lavender", - "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", - "lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", - "lightgreen", "lightgrey", "lightpink", "lightsalmon", - "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey", - "lightsteelblue", "lightyellow", "limegreen", "linen", "magenta", - "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", - "mediumpurple", "mediumseagreen", "mediumslateblue", - "mediumturquoise", "midnightblue", "mintcream", "mistyrose", - "moccasin", "navajowhite", "navy", "oldlace", "olive", "olivedrab", - "orange", "orangered", "orchid", "palegoldenrod", "palegreen", - "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", - "pink", "powderblue", "purple", "red", "rosybrown", "royalblue", - "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", - "sienna", "silver", "skyblue", "slateblue", "slategray", - "slategrey", "snow", "springgreen", "steelblue", "tan", "teal", - "thistle", "tomato", "violet", "wheat", "burlywood", "chocolate"] + "aquamarine", + "bisque", + "blue", + "blueviolet", + "brown", + "cadetblue", + "chartreuse", + "coral", + "cornflowerblue", + "crimson", + "darkgoldenrod", + "darkgreen", + "darkkhaki", + "darkmagenta", + "darkorange", + "darkred", + "darksalmon", + "darkseagreen", + "darkslateblue", + "darkslategrey", + "darkviolet", + "deepskyblue", + "dodgerblue", + "firebrick", + "forestgreen", + "gainsboro", + "ghostwhite", + "gold", + "goldenrod", + "gray", + "grey", + "green", + "greenyellow", + "honeydew", + "hotpink", + "indianred", + "indigo", + "ivory", + "khaki", + "lavender", + "lavenderblush", + "lawngreen", + "lemonchiffon", + "lightblue", + "lightcoral", + "lightcyan", + "lightgoldenrodyellow", + "lightgray", + "lightgreen", + "lightgrey", + "lightpink", + "lightsalmon", + "lightseagreen", + "lightskyblue", + "lightslategray", + "lightslategrey", + "lightsteelblue", + "lightyellow", + "limegreen", + "linen", + "magenta", + "maroon", + "mediumaquamarine", + "mediumblue", + "mediumorchid", + "mediumpurple", + "mediumseagreen", + "mediumslateblue", + "mediumturquoise", + "midnightblue", + "mintcream", + "mistyrose", + "moccasin", + "navajowhite", + "navy", + "oldlace", + "olive", + "olivedrab", + "orange", + "orangered", + "orchid", + "palegoldenrod", + "palegreen", + "paleturquoise", + "palevioletred", + "papayawhip", + "peachpuff", + "peru", + "pink", + "powderblue", + "purple", + "red", + "rosybrown", + "royalblue", + "saddlebrown", + "salmon", + "sandybrown", + "seagreen", + "seashell", + "sienna", + "silver", + "skyblue", + "slateblue", + "slategray", + "slategrey", + "snow", + "springgreen", + "steelblue", + "tan", + "teal", + "thistle", + "tomato", + "violet", + "wheat", + "burlywood", + "chocolate", + ] self.color_map = {} self.color_counter = 0 def format_id(self, ID): if not ID.startswith("id"): - return ("id%s" % ID).replace('-', '')\ - .replace('#', '_HASH_').replace('.', '_DOT_') + return ( + ("id%s" % ID) + .replace("-", "") + .replace("#", "_HASH_") + .replace(".", "_DOT_") + ) else: - return ("%s" % ID).replace('-', '')\ - .replace('#', '_HASH_').replace('.', '_DOT_') + return ( + ("%s" % ID) + .replace("-", "") + .replace("#", "_HASH_") + .replace(".", "_DOT_") + ) def clean_label(self, s): return s.replace("[/:.]", "_") @@ -43,19 +144,19 @@ def clean_label(self, s): def get_node_label(self, node): lbl = [] lbl.append(self.format_id(node.id)) - lbl.append('
') - lbl.append('num pts: %d' % len(node.leaves())) - lbl.append('
') + lbl.append("
") + lbl.append("num pts: %d" % len(node.leaves())) + lbl.append("
") try: - lbl.append('purity: %f' % node.purity()) + lbl.append("purity: %f" % node.purity()) except Exception: pass try: - lbl.append('
') - lbl.append('across: %s' % node.best_across_debug) + lbl.append("
") + lbl.append("across: %s" % node.best_across_debug) except Exception: pass - return ''.join(lbl) + return "".join(lbl) def get_color(self, lbl): if lbl in self.color_map: @@ -71,59 +172,82 @@ def format_graphiz_node(self, node): color = self.internal_color try: if node.purity() == 1.0: - if hasattr(node, 'pts'): + if hasattr(node, "pts"): curr_node = node while curr_node.pts == None: curr_node = curr_node.children[0] - if len(curr_node.pts)>0: + if len(curr_node.pts) > 0: w_gt = [x for x in curr_node.pts if x[1] and x[1] != "None"] if w_gt: color = self.get_color(w_gt[0][0]) else: - color = self.get_color('None') + color = self.get_color("None") except Exception: pass - shape = 'point' + shape = "point" if node.parent is None: s.append( - '\n%s[shape=%s;style=filled;width=1;color=%s;label=<%s
%s
>]' - % (self.format_id(node.id), shape, color, - self.get_node_label(node), color)) - s.append( - '\nROOTNODE[shape=star;style=filled;color=gold;label=]') - s.append('\nROOTNODE->%s' % self.format_id(node.id)) + "\n%s[shape=%s;style=filled;width=1;color=%s;label=<%s
%s
>]" + % ( + self.format_id(node.id), + shape, + color, + self.get_node_label(node), + color, + ) + ) + s.append("\nROOTNODE[shape=star;style=filled;color=gold;label=]") + s.append("\nROOTNODE->%s" % self.format_id(node.id)) else: - leaf_m = '' - if hasattr(node, 'pts') and node.pts and len(node.pts) > 0: - if hasattr(node.pts[0][0], 'mid'): - leaf_m = '%s|%s' % (node.pts[0][0].mid, node.pts[0][0].gt) \ - if node.is_leaf() else '' + leaf_m = "" + if hasattr(node, "pts") and node.pts and len(node.pts) > 0: + if hasattr(node.pts[0][0], "mid"): + leaf_m = ( + "%s|%s" % (node.pts[0][0].mid, node.pts[0][0].gt) + if node.is_leaf() + else "" + ) else: - leaf_m = '%s|%s' % (node.pts[0][1], node.pts[0][0]) \ - if node.is_leaf() else '' - s.append('\n%s[shape=%s;style=filled;width=1;color=%s;label=<%s
' - '%s
%s
>]' - % (self.format_id(node.id), shape, color, - self.get_node_label(node), color, leaf_m)) - s.append('\n%s->%s' % (self.format_id(node.parent.id), - self.format_id(node.id))) - return ''.join(s) + leaf_m = ( + "%s|%s" % (node.pts[0][1], node.pts[0][0]) + if node.is_leaf() + else "" + ) + s.append( + "\n%s[shape=%s;style=filled;width=1;color=%s;label=<%s
" + "%s
%s
>]" + % ( + self.format_id(node.id), + shape, + color, + self.get_node_label(node), + color, + leaf_m, + ) + ) + s.append( + "\n%s->%s" % (self.format_id(node.parent.id), self.format_id(node.id)) + ) + return "".join(s) - def graphviz_tree(self, root,): + def graphviz_tree( + self, + root, + ): """Return a graphviz tree as a string.""" s = [] - s.append('digraph TreeStructure {\n') + s.append("digraph TreeStructure {\n") s.append(self.format_graphiz_node(root)) for d in root.descendants(): s.append(self.format_graphiz_node(d)) - s.append('\n}') - return ''.join(s) + s.append("\n}") + return "".join(s) @staticmethod - def write_tree(root,filename): + def write_tree(root, filename): """Write a graphviz tree to a file.""" gv = Graphviz() tree = gv.graphviz_tree(root) - with open(filename, 'w') as fout: + with open(filename, "w") as fout: fout.write(tree) diff --git a/pyikt/stream/cluster/utils/__init__.py b/pyikt/stream/cluster/utils/__init__.py index 9dbb6fa..a6323bd 100644 --- a/pyikt/stream/cluster/utils/__init__.py +++ b/pyikt/stream/cluster/utils/__init__.py @@ -1,14 +1,13 @@ # Copyright 2021 hanxin -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - diff --git a/pyikt/stream/cluster/utils/deltasep_utils.py b/pyikt/stream/cluster/utils/deltasep_utils.py index 8913f35..7beb7b7 100644 --- a/pyikt/stream/cluster/utils/deltasep_utils.py +++ b/pyikt/stream/cluster/utils/deltasep_utils.py @@ -13,7 +13,6 @@ limitations under the License. """ - """ Utilities for creating delta separated data sets. """ @@ -50,7 +49,6 @@ def gen_k_centers(k, dim): return centers, delta - def create_dataset(dims, size, num_clusters=20): """Create a delta separated data set. @@ -111,187 +109,223 @@ def gen_4_normal(): Returns: A list of the four cluster centers. """ - return [np.random.multivariate_normal(mean=np.array([1.0, 1.0]), - cov=np.array([[1.0, 0.0], [0.0, 1.0]])), - np.random.multivariate_normal(mean=np.array([1.0, -1.0]), - cov=np.array([[1.0, 0.0], [0.0, 1.0]])), - np.random.multivariate_normal(mean=np.array([-1.0, -1.0]), - cov=np.array([[1.0, 0.0], [0.0, 1.0]])), - np.random.multivariate_normal(mean=np.array([-1.0, 1.0]), - cov=np.array([[1.0, 0.0], [0.0, 1.0]]))] + return [ + np.random.multivariate_normal( + mean=np.array([1.0, 1.0]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ), + np.random.multivariate_normal( + mean=np.array([1.0, -1.0]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ), + np.random.multivariate_normal( + mean=np.array([-1.0, -1.0]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ), + np.random.multivariate_normal( + mean=np.array([-1.0, 1.0]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ), + ] def _4_normal_spread(): - """Create 4 cluster centers. + """Create 4 cluster centers. - Create gaussians centered at (10,10), (10,-10), (-10,-10) and (-10,10). - Each has standard covariance. + Create gaussians centered at (10,10), (10,-10), (-10,-10) and (-10,10). + Each has standard covariance. - Args: - None + Args: + None - Returns: - A list of the four cluster centers. - """ - return [np.random.multivariate_normal(mean=np.array([10.0, 10.0]), - cov=np.array([[1.0, 0.0], [0.0, 1.0]])), - np.random.multivariate_normal(mean=np.array([10.0, -10.0]), - cov=np.array([[1.0, 0.0], [0.0, 1.0]])), - np.random.multivariate_normal(mean=np.array([-10.0, -10.0]), - cov=np.array([[1.0, 0.0], [0.0, 1.0]])), - np.random.multivariate_normal(mean=np.array([-10.0, 10.0]), - cov=np.array([[1.0, 0.0], [0.0, 1.0]]))] + Returns: + A list of the four cluster centers. + """ + return [ + np.random.multivariate_normal( + mean=np.array([10.0, 10.0]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ), + np.random.multivariate_normal( + mean=np.array([10.0, -10.0]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ), + np.random.multivariate_normal( + mean=np.array([-10.0, -10.0]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ), + np.random.multivariate_normal( + mean=np.array([-10.0, 10.0]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ), + ] def _5x5_grid_clusters(): - """Create a 5x5 grid of cluster centers. + """Create a 5x5 grid of cluster centers. - Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a - gaussian with standard covariance + Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a + gaussian with standard covariance - Args: - None + Args: + None - Returns: - A list of cluster centers. - """ - return [np.random.multivariate_normal(mean=np.array([i, j]), cov=np.array([[1.0, 0.0], - [0.0, 1.0]])) - for i in range(5) - for j in range(5)] + Returns: + A list of cluster centers. + """ + return [ + np.random.multivariate_normal( + mean=np.array([i, j]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ) + for i in range(5) + for j in range(5) + ] def _5x5_grid_clusters_spread(): - """Create a 5x5 grid of cluster centers. + """Create a 5x5 grid of cluster centers. - Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a - gaussian with standard covariance + Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a + gaussian with standard covariance - Args: - None + Args: + None - Returns: - A list of cluster centers. - """ - return [np.random.multivariate_normal(mean=np.array([i * 25, j * 25]), cov=np.array([[1.0, 0.0], - [0.0, 1.0]])) - for i in range(5) - for j in range(5)] + Returns: + A list of cluster centers. + """ + return [ + np.random.multivariate_normal( + mean=np.array([i * 25, j * 25]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ) + for i in range(5) + for j in range(5) + ] def _5x5_grid_clusters_close(): - """Create a 5x5 grid of cluster centers. + """Create a 5x5 grid of cluster centers. - Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a - gaussian with standard covariance + Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a + gaussian with standard covariance - Args: - None + Args: + None - Returns: - A list of cluster centers. - """ - return [np.random.multivariate_normal(mean=np.array([i * 5, j * 5]), cov=np.array([[1.0, 0.0], - [0.0, 1.0]])) - for i in range(5) - for j in range(5)] + Returns: + A list of cluster centers. + """ + return [ + np.random.multivariate_normal( + mean=np.array([i * 5, j * 5]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ) + for i in range(5) + for j in range(5) + ] def _2x3_grid_clusters_close(): - """Create a 3x3 grid of cluster centers. + """Create a 3x3 grid of cluster centers. - Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a - gaussian with standard covariance + Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a + gaussian with standard covariance - Args: - None + Args: + None - Returns: - A list of cluster centers. - """ - return [np.random.multivariate_normal(mean=np.array([i * 5, j * 5]), cov=np.array([[1.0, 0.0], - [0.0, 1.0]])) - for i in range(2) - for j in range(3)] + Returns: + A list of cluster centers. + """ + return [ + np.random.multivariate_normal( + mean=np.array([i * 5, j * 5]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ) + for i in range(2) + for j in range(3) + ] def _2x3_grid_clusters_spread(): - """Create a 3x3 grid of cluster centers. + """Create a 3x3 grid of cluster centers. - Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a - gaussian with standard covariance + Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a + gaussian with standard covariance - Args: - None + Args: + None - Returns: - A list of cluster centers. - """ - return [np.random.multivariate_normal(mean=np.array([i * 25, j * 25]), cov=np.array([[1.0, 0.0], - [0.0, 1.0]])) - for i in range(2) - for j in range(3)] + Returns: + A list of cluster centers. + """ + return [ + np.random.multivariate_normal( + mean=np.array([i * 25, j * 25]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ) + for i in range(2) + for j in range(3) + ] def _10x10_grid_clusters_close(): - """Create a 3x3 grid of cluster centers. + """Create a 3x3 grid of cluster centers. - Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a - gaussian with standard covariance + Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a + gaussian with standard covariance - Args: - None + Args: + None - Returns: - A list of cluster centers. - """ - return [np.random.multivariate_normal(mean=np.array([i * 5, j * 5]), cov=np.array([[1.0, 0.0], - [0.0, 1.0]])) - for i in range(10) - for j in range(10)] + Returns: + A list of cluster centers. + """ + return [ + np.random.multivariate_normal( + mean=np.array([i * 5, j * 5]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ) + for i in range(10) + for j in range(10) + ] def _10x10_grid_clusters_spread(): - """Create a 3x3 grid of cluster centers. + """Create a 3x3 grid of cluster centers. - Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a - gaussian with standard covariance + Create 25 cluster centers on the grid I^{[0, 4] x [0,4]}. Each center is a + gaussian with standard covariance - Args: - None + Args: + None - Returns: - A list of cluster centers. - """ - return [np.random.multivariate_normal(mean=np.array([i * 25, j * 25]), cov=np.array([[1.0, 0.0], - [0.0, 1.0]])) - for i in range(10) - for j in range(10)] + Returns: + A list of cluster centers. + """ + return [ + np.random.multivariate_normal( + mean=np.array([i * 25, j * 25]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ) + for i in range(10) + for j in range(10) + ] def _random_standard_centers(n=100): - """Create random cluster centers. + """Create random cluster centers. - Create n cluster centers randomly. Each cluster center is a draw from a - gaussian distribution centered at (0,0) with standard covariance. + Create n cluster centers randomly. Each cluster center is a draw from a + gaussian distribution centered at (0,0) with standard covariance. - Args: - n - optional; the number of centers to draw (default 100). + Args: + n - optional; the number of centers to draw (default 100). - Returns: - A list of cluster centers. - """ - generator = np.random.multivariate_normal(mean=np.array([0, 0]), - cov=np.array([[1.0, 0.0], [0.0, 1.0]])) - return [np.random.multivariate_normal(mean=pt, cov=np.array([[1.0, 0.0], [0.0, 1.0]])) - for pt in generator.rvs(size=n)] + Returns: + A list of cluster centers. + """ + generator = np.random.multivariate_normal( + mean=np.array([0, 0]), cov=np.array([[1.0, 0.0], [0.0, 1.0]]) + ) + return [ + np.random.multivariate_normal(mean=pt, cov=np.array([[1.0, 0.0], [0.0, 1.0]])) + for pt in generator.rvs(size=n) + ] def _from_file(filename): - with open(filename, 'r') as f: - clustering = [] - for line in f: - splits = line.split('\t') - l, vec = int(splits[0]), np.array([float(x) for x in splits[1:]]) - clustering.append((vec, l)) - return clustering + with open(filename, "r") as f: + clustering = [] + for line in f: + splits = line.split("\t") + l, vec = int(splits[0]), np.array([float(x) for x in splits[1:]]) + clustering.append((vec, l)) + return clustering diff --git a/pyikt/stream/cluster/utils/dendrogram_purity.py b/pyikt/stream/cluster/utils/dendrogram_purity.py index a70032f..0d6cd25 100644 --- a/pyikt/stream/cluster/utils/dendrogram_purity.py +++ b/pyikt/stream/cluster/utils/dendrogram_purity.py @@ -16,7 +16,6 @@ from itertools import combinations, groupby import numpy as np -from tqdm import tqdm from tqdm._tqdm import trange @@ -38,16 +37,22 @@ def expected_dendrogram_purity(root): # Construct a map from leaf to cluster and from cluster to a list of leaves. # Filter out the singletons in the leaf to cluster map. leaves = root.leaves() - def get_cluster(x): return x.pts[0][0] - cluster_to_leaves = {c: list(ls) - for c, ls in groupby(sorted(leaves, key=get_cluster), - get_cluster)} + + def get_cluster(x): + return x.pts[0][0] + + cluster_to_leaves = { + c: list(ls) for c, ls in groupby(sorted(leaves, key=get_cluster), get_cluster) + } leaf_to_cluster = {l: l.pts[0][0] for l in leaves} - non_singleton_leaves = [l for l in leaf_to_cluster.keys() - if len(cluster_to_leaves[leaf_to_cluster[l]]) > 1] + non_singleton_leaves = [ + l + for l in leaf_to_cluster.keys() + if len(cluster_to_leaves[leaf_to_cluster[l]]) > 1 + ] if len(non_singleton_leaves) == 0.0: return 1.0 - assert(len(non_singleton_leaves) > 0) + assert len(non_singleton_leaves) > 0 # For n samples, sample a leaf uniformly at random then select another leaf # from the same class unformly at random. @@ -59,13 +64,11 @@ def get_cluster(x): return x.pts[0][0] rand_cluster_member = np.random.choice(cluster_to_leaves[cluster]) # Make sure we get two distinct leaves while rand_cluster_member == rand_leaf: - assert(leaf_to_cluster[rand_leaf] == - leaf_to_cluster[rand_cluster_member]) + assert leaf_to_cluster[rand_leaf] == leaf_to_cluster[rand_cluster_member] rand_cluster_member = np.random.choice(cluster_to_leaves[cluster]) # Find their lowest common ancestor and compute cluster purity. - assert(leaf_to_cluster[rand_leaf] == - leaf_to_cluster[rand_cluster_member]) + assert leaf_to_cluster[rand_leaf] == leaf_to_cluster[rand_cluster_member] lca = rand_leaf.lca(rand_cluster_member) unnormalized_purity += lca.purity(cluster=cluster) return unnormalized_purity / samps @@ -81,8 +84,9 @@ def get_cluster(x): return x.pts[0][0] sorted_lvs = sorted(leaves, key=get_cluster) - leaves_by_true_class = {c: list(ls) for c, ls in groupby(sorted_lvs, - key=get_cluster)} + leaves_by_true_class = { + c: list(ls) for c, ls in groupby(sorted_lvs, key=get_cluster) + } leaf_pairs_by_true_class = {} for class_lbl, lvs in leaves_by_true_class.items(): # leaf_pairs_by_true_class[class_lbl] = combinations(leaves_by_true_class[class_lbl], 2) @@ -93,7 +97,7 @@ def get_cluster(x): for pair in leaf_pairs_by_true_class[class_lbl]: lca = pair[0].lca(pair[1]) sum_purity += lca.purity(get_cluster(pair[0])) - assert(get_cluster(pair[0]) == get_cluster(pair[1])) + assert get_cluster(pair[0]) == get_cluster(pair[1]) count += 1.0 if count == 0.0: return 1.0 diff --git a/pyikt/stream/cluster/utils/dendrogram_purity_pool.py b/pyikt/stream/cluster/utils/dendrogram_purity_pool.py index 19e1a7b..8db22b9 100644 --- a/pyikt/stream/cluster/utils/dendrogram_purity_pool.py +++ b/pyikt/stream/cluster/utils/dendrogram_purity_pool.py @@ -11,22 +11,28 @@ limitations under the License. """ -import time -from functools import partial -from itertools import combinations, groupby -from multiprocessing import Pool, Manager - +import sys import threading -from queue import Queue +from itertools import combinations, groupby +from multiprocessing import Pool import numpy as np -import sys + sys.setrecursionlimit(50000) queueLock = threading.Lock() class Producer(threading.Thread): - def __init__(self, samp_queue, cluser_to_leaves, leaf_to_cluster, result_queue, non_singleton_leaves, *args, **kwargs): + def __init__( + self, + samp_queue, + cluser_to_leaves, + leaf_to_cluster, + result_queue, + non_singleton_leaves, + *args, + **kwargs, + ): super(Producer, self).__init__(*args, **kwargs) self.samp_queue = samp_queue self.result_queue = result_queue @@ -38,10 +44,10 @@ def run(self): while True: queueLock.acquire() if self.samp_queue.empty(): - print('bye') + print("bye") queueLock.release() break - print('剩余采样数:', self.samp_queue.qsize()) + print("剩余采样数:", self.samp_queue.qsize()) samp = self.samp_queue.get() queueLock.release() self.get_purity() @@ -52,9 +58,8 @@ def get_purity(self): rand_cluster_member = np.random.choice(self.cluster_to_leaves[cluster]) # Make sure we get two distinct leaves while rand_cluster_member == rand_leaf: - #assert(leaf_to_cluster[rand_leaf] == leaf_to_cluster[rand_cluster_member]) - rand_cluster_member = np.random.choice( - self.cluster_to_leaves[cluster]) + # assert(leaf_to_cluster[rand_leaf] == leaf_to_cluster[rand_cluster_member]) + rand_cluster_member = np.random.choice(self.cluster_to_leaves[cluster]) lca = rand_leaf.lca(rand_cluster_member) purity = lca.purity(cluster=cluster) # print(purity) @@ -86,12 +91,15 @@ def expected_dendrogram_purity(root): def get_cluster(x): return x.pts[0][0] - cluster_to_leaves = {c: list(ls) - for c, ls in groupby(sorted(leaves, key=get_cluster), - get_cluster)} + cluster_to_leaves = { + c: list(ls) for c, ls in groupby(sorted(leaves, key=get_cluster), get_cluster) + } leaf_to_cluster = {l: l.pts[0][0] for l in leaves} - non_singleton_leaves = [l for l in leaf_to_cluster.keys() - if len(cluster_to_leaves[leaf_to_cluster[l]]) > 1] + non_singleton_leaves = [ + l + for l in leaf_to_cluster.keys() + if len(cluster_to_leaves[leaf_to_cluster[l]]) > 1 + ] if len(non_singleton_leaves) == 0.0: return 1.0 @@ -100,12 +108,13 @@ def get_cluster(x): samps = len(non_singleton_leaves) * 5 # TODO (AK): pick 5 in a better way. with Pool(processes=6) as pool: res = pool.starmap( - process, [(non_singleton_leaves, leaf_to_cluster, cluster_to_leaves)]*samps) + process, + [(non_singleton_leaves, leaf_to_cluster, cluster_to_leaves)] * samps, + ) return sum(res) / samps def process(non_singleton_leaves, leaf_to_cluster, cluster_to_leaves): - rand_leaf = np.random.choice(non_singleton_leaves) cluster = leaf_to_cluster[rand_leaf] rand_cluster_member = np.random.choice(cluster_to_leaves[cluster]) @@ -127,8 +136,9 @@ def get_cluster(x): return x.pts[0][0] sorted_lvs = sorted(leaves, key=get_cluster) - leaves_by_true_class = {c: list(ls) for c, ls in groupby(sorted_lvs, - key=get_cluster)} + leaves_by_true_class = { + c: list(ls) for c, ls in groupby(sorted_lvs, key=get_cluster) + } leaf_pairs_by_true_class = {} for class_lbl, lvs in leaves_by_true_class.items(): # leaf_pairs_by_true_class[class_lbl] = combinations(leaves_by_true_class[class_lbl], 2) @@ -139,7 +149,7 @@ def get_cluster(x): for pair in leaf_pairs_by_true_class[class_lbl]: lca = pair[0].lca(pair[1]) sum_purity += lca.purity(get_cluster(pair[0])) - assert(get_cluster(pair[0]) == get_cluster(pair[1])) + assert get_cluster(pair[0]) == get_cluster(pair[1]) count += 1.0 if count == 0.0: return 1.0 diff --git a/pyikt/stream/cluster/utils/file_utils.py b/pyikt/stream/cluster/utils/file_utils.py index 981b532..e850c8e 100644 --- a/pyikt/stream/cluster/utils/file_utils.py +++ b/pyikt/stream/cluster/utils/file_utils.py @@ -1,11 +1,11 @@ # Copyright 2021 Xin Han -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,10 +38,9 @@ def load_data(filename): if filename.endswith(".csv"): split_sep = "," elif filename.endswith(".tsv"): - split_sep = '\t' - with open(filename, 'r') as f: + split_sep = "\t" + with open(filename, "r") as f: for line in f: splits = line.strip().split(sep=split_sep) - pid, l, vec = splits[0], splits[1], np.array([float(x) - for x in splits[2:]]) - yield ((l, pid, vec)) \ No newline at end of file + pid, l, vec = splits[0], splits[1], np.array([float(x) for x in splits[2:]]) + yield ((l, pid, vec)) diff --git a/pyikt/stream/cluster/utils/logger.py b/pyikt/stream/cluster/utils/logger.py index 1b73494..6b509c7 100644 --- a/pyikt/stream/cluster/utils/logger.py +++ b/pyikt/stream/cluster/utils/logger.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ - Copyright (c) 2021 Xin Han - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. +Copyright (c) 2021 Xin Han + +This Source Code Form is subject to the terms of the Mozilla Public +License, v. 2.0. If a copy of the MPL was not distributed with this +file, You can obtain one at http://mozilla.org/MPL/2.0/. """ # coding: utf-8 @@ -14,34 +14,38 @@ class Logger(object): level_relations = { - 'debug': logging.DEBUG, - 'info': logging.INFO, - 'warning': logging.WARNING, - 'error': logging.ERROR, - 'crit': logging.CRITICAL + "debug": logging.DEBUG, + "info": logging.INFO, + "warning": logging.WARNING, + "error": logging.ERROR, + "crit": logging.CRITICAL, } - def __init__(self, filename, - level='info', - when='D', - backCount=25, - fmt='%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s'): + def __init__( + self, + filename, + level="info", + when="D", + backCount=25, + fmt="%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s", + ): self.logger = logging.getLogger(filename) format_str = logging.Formatter(fmt) self.logger.setLevel(self.level_relations.get(level)) console_handler = logging.StreamHandler() console_handler.setFormatter(format_str) file_handler = handlers.TimedRotatingFileHandler( - filename=filename, when=when, backupCount=backCount, encoding='utf-8') + filename=filename, when=when, backupCount=backCount, encoding="utf-8" + ) file_handler.setFormatter(format_str) self.logger.addHandler(console_handler) self.logger.addHandler(file_handler) -if __name__ == '__main__': - log = Logger('all.log', level='debug') - log.logger.debug('debug') - log.logger.info('info') - log.logger.warning('warning') - log.logger.error('error') - Logger('error.log', level='error').logger.error('error') +if __name__ == "__main__": + log = Logger("all.log", level="debug") + log.logger.debug("debug") + log.logger.info("info") + log.logger.warning("warning") + log.logger.error("error") + Logger("error.log", level="error").logger.error("error") diff --git a/pyikt/stream/cluster/utils/serialize_trees.py b/pyikt/stream/cluster/utils/serialize_trees.py index d380bc3..03f66fb 100644 --- a/pyikt/stream/cluster/utils/serialize_trees.py +++ b/pyikt/stream/cluster/utils/serialize_trees.py @@ -12,6 +12,7 @@ See the License for the specific language governing permissions and limitations under the License. """ + import math import numpy as np @@ -22,13 +23,13 @@ def _fast_dot(x, y): """Compute the dot product of x and y using numba. - Args: - x - a numpy vector (or list). - y - a numpy vector (or list). + Args: + x - a numpy vector (or list). + y - a numpy vector (or list). - Returns: - x_T.y - """ + Returns: + x_T.y + """ return np.dot(x, y) @@ -75,20 +76,30 @@ def _fast_norm_diff(x, y): def serliaze_tree_to_file_with_point_ids(root, fn): - with open(fn, 'w') as fout: + with open(fn, "w") as fout: queue = Queue() queue.put(root) while not queue.empty(): curr_node = queue.get() - curr_node_id = curr_node.pts[0][1] if curr_node.is_leaf( - ) else curr_node.id + curr_node_id = curr_node.pts[0][1] if curr_node.is_leaf() else curr_node.id sibling_node_id = "None" if curr_node.parent: - sibling_node_id = curr_node.siblings()[0].pts[0][1] if curr_node.siblings()[ - 0].is_leaf() else curr_node.siblings()[0].id + sibling_node_id = ( + curr_node.siblings()[0].pts[0][1] + if curr_node.siblings()[0].is_leaf() + else curr_node.siblings()[0].id + ) dis = getDistance(curr_node) if curr_node.parent else "None" - fout.write("%s\t%s\t%s\t%s\t%s\n" % (curr_node_id, sibling_node_id, - curr_node.parent.id if curr_node.parent else "None", dis, curr_node.pts[0][0] if curr_node.is_leaf() else "None")) + fout.write( + "%s\t%s\t%s\t%s\t%s\n" + % ( + curr_node_id, + sibling_node_id, + curr_node.parent.id if curr_node.parent else "None", + dis, + curr_node.pts[0][0] if curr_node.is_leaf() else "None", + ) + ) for c in curr_node.children: queue.put(c) @@ -98,34 +109,59 @@ def getDistance(curr_node): curr_point_count = curr_node.point_counter sibling_point_count = sibling.point_counter - distance = 2*(200 - (_fast_dot(sibling.ikv, curr_node.ikv) / - (curr_point_count*sibling_point_count))) + distance = 2 * ( + 200 + - ( + _fast_dot(sibling.ikv, curr_node.ikv) + / (curr_point_count * sibling_point_count) + ) + ) return distance def serliaze_tree_to_file(root, fn): - with open(fn, 'w') as fout: + with open(fn, "w") as fout: queue = Queue() queue.put(root) while not queue.empty(): curr_node = queue.get() - fout.write("%s\t%s\t%s\t%s\n" % (curr_node.id, curr_node.parent.id if curr_node.parent else "None", - curr_node.pts[0][1] if curr_node.is_leaf() else "None", len(curr_node.pts))) + fout.write( + "%s\t%s\t%s\t%s\n" + % ( + curr_node.id, + curr_node.parent.id if curr_node.parent else "None", + curr_node.pts[0][1] if curr_node.is_leaf() else "None", + len(curr_node.pts), + ) + ) for c in curr_node.children: queue.put(c) def serliaze_collapsed_tree_to_file_with_point_ids(root, fn): - with open(fn, 'w') as fout: + with open(fn, "w") as fout: queue = Queue() queue.put(root) while not queue.empty(): curr_node = queue.get() - curr_node_id = curr_node.pts[0][2] if curr_node.is_leaf( - ) and not curr_node.is_collapsed else curr_node.id - fout.write("%s\t%s\t%s\n" % (curr_node_id, curr_node.parent.id if curr_node.parent else "None", - curr_node.pts[0][1] if curr_node.is_leaf() and not curr_node.is_collapsed else "None")) + curr_node_id = ( + curr_node.pts[0][2] + if curr_node.is_leaf() and not curr_node.is_collapsed + else curr_node.id + ) + fout.write( + "%s\t%s\t%s\n" + % ( + curr_node_id, + curr_node.parent.id if curr_node.parent else "None", + ( + curr_node.pts[0][1] + if curr_node.is_leaf() and not curr_node.is_collapsed + else "None" + ), + ) + ) for c in curr_node.children: queue.put(c) if curr_node.collapsed_leaves is not None: diff --git a/pyikt/stream/tests/test_icid.py b/pyikt/stream/tests/test_icid.py index ddc79c8..d5285dd 100644 --- a/pyikt/stream/tests/test_icid.py +++ b/pyikt/stream/tests/test_icid.py @@ -2,9 +2,10 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. -import pytest import numpy as np +import pytest from sklearn.utils import check_random_state + from pyikt.stream import ICID rng = check_random_state(42) diff --git a/pyikt/stream/tests/test_streakhc.py b/pyikt/stream/tests/test_streakhc.py index bf70dc5..73826db 100644 --- a/pyikt/stream/tests/test_streakhc.py +++ b/pyikt/stream/tests/test_streakhc.py @@ -1,8 +1,7 @@ -import pytest import numpy as np +import pytest + from pyikt.stream import STREAMKHC -import tempfile -import os def test_streamkhc_init(): diff --git a/pyikt/timeseries/__init__.py b/pyikt/timeseries/__init__.py index 18cae9a..dfd081e 100644 --- a/pyikt/timeseries/__init__.py +++ b/pyikt/timeseries/__init__.py @@ -10,7 +10,6 @@ from .anomaly._iktod import IKTOD - __all__ = [ "IKTOD", ] diff --git a/pyikt/timeseries/anomaly/_iktod.py b/pyikt/timeseries/anomaly/_iktod.py index d9bcf7f..737f12e 100644 --- a/pyikt/timeseries/anomaly/_iktod.py +++ b/pyikt/timeseries/anomaly/_iktod.py @@ -9,10 +9,12 @@ """ import warnings +from typing import Optional, Union + import numpy as np -from typing import Union, Optional from sklearn.base import BaseEstimator, OutlierMixin -from sklearn.utils.validation import check_is_fitted, check_array +from sklearn.utils.validation import check_array, check_is_fitted + from pyikt.group import IKGAD @@ -147,7 +149,6 @@ def fit(self, X) -> "IKTOD": # Check if time series length is compatible with period_length rest_samples = X.shape[0] % self.period_length if rest_samples != 0: - warnings.warn( f"The last sequence of series has {rest_samples} samples, " f"which are less than other sequence." diff --git a/pyikt/timeseries/tests/test_iktod.py b/pyikt/timeseries/tests/test_iktod.py index 40e17c1..e86afe1 100644 --- a/pyikt/timeseries/tests/test_iktod.py +++ b/pyikt/timeseries/tests/test_iktod.py @@ -1,5 +1,6 @@ import numpy as np import pytest + from pyikt.timeseries import IKTOD diff --git a/pyikt/trajectory/__init__.py b/pyikt/trajectory/__init__.py index 1d04e46..f5ad3ad 100644 --- a/pyikt/trajectory/__init__.py +++ b/pyikt/trajectory/__init__.py @@ -11,7 +11,6 @@ from .anomaly._ikat import IKAT from .cluster._tidkc import TIDKC - __all__ = [ "IKAT", "TIDKC", diff --git a/pyikt/trajectory/anomaly/_ikat.py b/pyikt/trajectory/anomaly/_ikat.py index d38b31b..d985a2d 100644 --- a/pyikt/trajectory/anomaly/_ikat.py +++ b/pyikt/trajectory/anomaly/_ikat.py @@ -1,7 +1,9 @@ +from typing import Any, Literal, Optional, Union + import numpy as np -from typing import Optional, Union, Literal, Any from sklearn.base import BaseEstimator, OutlierMixin from sklearn.utils.validation import check_is_fitted + from pyikt.group import IKGAD from pyikt.group.utils import check_format diff --git a/pyikt/trajectory/cluster/_tidkc.py b/pyikt/trajectory/cluster/_tidkc.py index bef2d8f..0bcad13 100644 --- a/pyikt/trajectory/cluster/_tidkc.py +++ b/pyikt/trajectory/cluster/_tidkc.py @@ -8,12 +8,14 @@ work. If not, see . """ +from typing import Any, Literal, Optional, Union + import numpy as np from sklearn.base import BaseEstimator, ClusterMixin -from pyikt.kernel import IsoKernel + from pyikt.cluster import IDKC from pyikt.group.utils import check_format -from typing import Optional, Union, Literal, Any +from pyikt.kernel import IsoKernel class TIDKC(BaseEstimator, ClusterMixin): diff --git a/pyikt/trajectory/dataloader/_sheepdogs.py b/pyikt/trajectory/dataloader/_sheepdogs.py index d14f7b0..3e1dd44 100644 --- a/pyikt/trajectory/dataloader/_sheepdogs.py +++ b/pyikt/trajectory/dataloader/_sheepdogs.py @@ -1,7 +1,9 @@ -from .base import FileDataset -import pandas as pd import datetime +import pandas as pd + +from .base import FileDataset + class SheepDogs(FileDataset): """SheepDogs trajectory dataset. diff --git a/pyikt/trajectory/dataloader/base.py b/pyikt/trajectory/dataloader/base.py index 18de853..095db53 100644 --- a/pyikt/trajectory/dataloader/base.py +++ b/pyikt/trajectory/dataloader/base.py @@ -2,7 +2,6 @@ import abc import inspect -import itertools import os import pathlib import re diff --git a/pyikt/trajectory/tests/test_ikat.py b/pyikt/trajectory/tests/test_ikat.py index d1f3404..d02f8b3 100644 --- a/pyikt/trajectory/tests/test_ikat.py +++ b/pyikt/trajectory/tests/test_ikat.py @@ -4,8 +4,9 @@ license that can be found in the LICENSE file. """ -import pytest import numpy as np +import pytest + from pyikt.trajectory import IKAT diff --git a/pyikt/trajectory/tests/test_tidkc.py b/pyikt/trajectory/tests/test_tidkc.py index 174acce..110e91c 100644 --- a/pyikt/trajectory/tests/test_tidkc.py +++ b/pyikt/trajectory/tests/test_tidkc.py @@ -1,5 +1,6 @@ import numpy as np import pytest + from pyikt.trajectory import TIDKC diff --git a/pyikt/trajectory/utils.py b/pyikt/trajectory/utils.py index e7b51bb..e46e776 100644 --- a/pyikt/trajectory/utils.py +++ b/pyikt/trajectory/utils.py @@ -8,8 +8,9 @@ work. If not, see . """ +from typing import Any, List, Optional, Union + import numpy as np -from typing import Union, List, Any, Optional def check_format( diff --git a/pyproject.toml b/pyproject.toml index 8ba0e75..0d7e615 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -95,7 +95,7 @@ ruff = "0.4.2" [tool.pixi.feature.lint.tasks] black = { cmd = "black --check --diff pyikt && black --check --diff examples" } ruff = { cmd = "ruff check --output-format=full pyikt && ruff check --output-format=full examples" } -lint = { depends_on = ["black", "ruff"] } +lint = { depends-on = ["black", "ruff"] } [tool.pixi.feature.test.dependencies] pytest = "*" From 50aac8b4d9814b5872ca70cd0353f66fbc8d0f84 Mon Sep 17 00:00:00 2001 From: Xin Han Date: Wed, 5 Mar 2025 18:48:55 +1100 Subject: [PATCH 2/5] format code --- .pre-commit-config.yaml | 20 +-- pixi.lock | 155 ++++++++++-------- pyikt/stream/cluster/utils/serialize_trees.py | 12 +- pyproject.toml | 6 +- 4 files changed, 101 insertions(+), 92 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 64c11db..346262d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,16 +1,16 @@ repos: -- repo: https://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace -- repo: https://github.com/psf/black - rev: 23.3.0 + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/psf/black + rev: 24.8.0 hooks: - - id: black -- repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.272 + - id: black + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.9.9 hooks: - - id: ruff + - id: ruff args: ["--fix", "--show-source"] diff --git a/pixi.lock b/pixi.lock index 9e1e677..d8afd03 100644 --- a/pixi.lock +++ b/pixi.lock @@ -281,7 +281,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/attrs-25.1.0-pyh71513ae_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/babel-2.17.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/beautifulsoup4-4.13.3-pyha770c72_0.conda - - conda: https://conda.anaconda.org/conda-forge/linux-64/black-23.3.0-py310hff52083_1.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/black-24.8.0-py310hff52083_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-6.2.0-pyh29332c3_4.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-with-css-6.2.0-h82add2a_4.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/brotli-python-1.1.0-py310hf71b8c6_2.conda @@ -429,7 +429,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/linux-64/regex-2024.11.6-py310ha75aee5_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/requests-2.32.3-pyhd8ed1ab_1.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/rpds-py-0.23.1-py310hc1293b2_0.conda - - conda: https://conda.anaconda.org/conda-forge/linux-64/ruff-0.4.2-py310h9065425_0.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/ruff-0.9.9-py310h8851ac2_0.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/scikit-learn-1.6.1-py310h27f47ee_0.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/scipy-1.11.2-py310ha4c1d20_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/send2trash-1.8.3-pyh0d859eb_1.conda @@ -472,7 +472,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/attrs-25.1.0-pyh71513ae_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/babel-2.17.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/beautifulsoup4-4.13.3-pyha770c72_0.conda - - conda: https://conda.anaconda.org/conda-forge/osx-64/black-23.3.0-py310h2ec42d9_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-64/black-24.8.0-py310h2ec42d9_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-6.2.0-pyh29332c3_4.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-with-css-6.2.0-h82add2a_4.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/brotli-python-1.1.0-py310h53e7c6a_2.conda @@ -613,7 +613,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/osx-64/regex-2024.11.6-py310hbb8c376_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/requests-2.32.3-pyhd8ed1ab_1.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/rpds-py-0.23.1-py310h40a894c_0.conda - - conda: https://conda.anaconda.org/conda-forge/osx-64/ruff-0.4.2-py310h4a464a8_0.conda + - conda: https://conda.anaconda.org/conda-forge/osx-64/ruff-0.9.9-py310h9dc1ea1_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/scikit-learn-1.6.1-py310h6ed8a50_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/scipy-1.11.2-py310h3900cf1_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/send2trash-1.8.3-pyh31c8845_1.conda @@ -656,7 +656,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/attrs-25.1.0-pyh71513ae_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/babel-2.17.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/beautifulsoup4-4.13.3-pyha770c72_0.conda - - conda: https://conda.anaconda.org/conda-forge/osx-arm64/black-23.3.0-py310hbe9552e_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/black-24.8.0-py310hbe9552e_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-6.2.0-pyh29332c3_4.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-with-css-6.2.0-h82add2a_4.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/brotli-python-1.1.0-py310hb4ad77e_2.conda @@ -798,7 +798,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/osx-arm64/regex-2024.11.6-py310h078409c_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/requests-2.32.3-pyhd8ed1ab_1.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/rpds-py-0.23.1-py310h31b3829_0.conda - - conda: https://conda.anaconda.org/conda-forge/osx-arm64/ruff-0.4.2-py310h275c10e_0.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/ruff-0.9.9-py310hdcf0d46_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/scikit-learn-1.6.1-py310h48c93d9_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/scipy-1.11.2-py310h0975f3d_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/send2trash-1.8.3-pyh31c8845_1.conda @@ -840,7 +840,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/attrs-25.1.0-pyh71513ae_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/babel-2.17.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/beautifulsoup4-4.13.3-pyha770c72_0.conda - - conda: https://conda.anaconda.org/conda-forge/win-64/black-23.3.0-py310h5588dad_1.conda + - conda: https://conda.anaconda.org/conda-forge/win-64/black-24.8.0-py310h5588dad_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-6.2.0-pyh29332c3_4.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-with-css-6.2.0-h82add2a_4.conda - conda: https://conda.anaconda.org/conda-forge/win-64/brotli-python-1.1.0-py310h9e98ed7_2.conda @@ -981,7 +981,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/win-64/regex-2024.11.6-py310ha8f682b_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/requests-2.32.3-pyhd8ed1ab_1.conda - conda: https://conda.anaconda.org/conda-forge/win-64/rpds-py-0.23.1-py310h7c79e54_0.conda - - conda: https://conda.anaconda.org/conda-forge/win-64/ruff-0.4.2-py310h7f1804c_0.conda + - conda: https://conda.anaconda.org/conda-forge/win-64/ruff-0.9.9-py310h090d742_0.conda - conda: https://conda.anaconda.org/conda-forge/win-64/scikit-learn-1.6.1-py310hf2a6c47_0.conda - conda: https://conda.anaconda.org/conda-forge/win-64/scipy-1.11.2-py310h578b7cb_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/send2trash-1.8.3-pyh5737063_1.conda @@ -1038,7 +1038,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/attrs-25.1.0-pyh71513ae_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/babel-2.17.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/beautifulsoup4-4.13.3-pyha770c72_0.conda - - conda: https://conda.anaconda.org/conda-forge/linux-64/black-23.3.0-py310hff52083_1.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/black-24.8.0-py310hff52083_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-6.2.0-pyh29332c3_4.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-with-css-6.2.0-h82add2a_4.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/brotli-python-1.1.0-py310hf71b8c6_2.conda @@ -1220,7 +1220,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/attrs-25.1.0-pyh71513ae_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/babel-2.17.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/beautifulsoup4-4.13.3-pyha770c72_0.conda - - conda: https://conda.anaconda.org/conda-forge/osx-64/black-23.3.0-py310h2ec42d9_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-64/black-24.8.0-py310h2ec42d9_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-6.2.0-pyh29332c3_4.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-with-css-6.2.0-h82add2a_4.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/brotli-python-1.1.0-py310h53e7c6a_2.conda @@ -1395,7 +1395,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/attrs-25.1.0-pyh71513ae_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/babel-2.17.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/beautifulsoup4-4.13.3-pyha770c72_0.conda - - conda: https://conda.anaconda.org/conda-forge/osx-arm64/black-23.3.0-py310hbe9552e_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/black-24.8.0-py310hbe9552e_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-6.2.0-pyh29332c3_4.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-with-css-6.2.0-h82add2a_4.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/brotli-python-1.1.0-py310hb4ad77e_2.conda @@ -1569,7 +1569,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/attrs-25.1.0-pyh71513ae_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/babel-2.17.0-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/beautifulsoup4-4.13.3-pyha770c72_0.conda - - conda: https://conda.anaconda.org/conda-forge/win-64/black-23.3.0-py310h5588dad_1.conda + - conda: https://conda.anaconda.org/conda-forge/win-64/black-24.8.0-py310h5588dad_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-6.2.0-pyh29332c3_4.conda - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-with-css-6.2.0-h82add2a_4.conda - conda: https://conda.anaconda.org/conda-forge/win-64/brotli-python-1.1.0-py310h9e98ed7_2.conda @@ -1749,7 +1749,7 @@ environments: linux-64: - conda: https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 - conda: https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 - - conda: https://conda.anaconda.org/conda-forge/linux-64/black-23.3.0-py310hff52083_1.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/black-24.8.0-py310hff52083_1.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/brotli-python-1.1.0-py310hf71b8c6_2.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/bzip2-1.0.8-h4bc722e_7.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/ca-certificates-2024.12.14-hbcca054_0.conda @@ -1807,13 +1807,14 @@ environments: - conda: https://conda.anaconda.org/conda-forge/linux-64/pyyaml-6.0.2-py310h89163eb_2.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/readline-8.2-h8228510_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/requests-2.32.3-pyhd8ed1ab_1.conda - - conda: https://conda.anaconda.org/conda-forge/linux-64/ruff-0.4.2-py310h9065425_0.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/ruff-0.9.9-py310h8851ac2_0.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/scikit-learn-1.6.1-py310h27f47ee_0.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/scipy-1.11.2-py310ha4c1d20_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/setuptools-75.8.0-pyhff2d567_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/threadpoolctl-3.5.0-pyhc1e730c_0.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/tk-8.6.13-noxft_h4845f30_101.conda - conda: https://conda.anaconda.org/conda-forge/noarch/tomli-2.2.1-pyhd8ed1ab_1.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/typing_extensions-4.12.2-pyha770c72_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2024b-hc8b5060_0.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/ukkonen-1.0.1-py310h3788b33_5.conda - conda: https://conda.anaconda.org/conda-forge/noarch/urllib3-2.3.0-pyhd8ed1ab_0.conda @@ -1833,7 +1834,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/0f/dd/84f10e23edd882c6f968c21c2434fe67bd4a528967067515feca9e611e5e/tzdata-2025.1-py2.py3-none-any.whl - pypi: . osx-64: - - conda: https://conda.anaconda.org/conda-forge/osx-64/black-23.3.0-py310h2ec42d9_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-64/black-24.8.0-py310h2ec42d9_1.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/brotli-python-1.1.0-py310h53e7c6a_2.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/bzip2-1.0.8-hfdf4475_7.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/ca-certificates-2024.12.14-h8857fd0_0.conda @@ -1883,13 +1884,14 @@ environments: - conda: https://conda.anaconda.org/conda-forge/osx-64/pyyaml-6.0.2-py310h8e2f543_2.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/readline-8.2-h9e318b2_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/requests-2.32.3-pyhd8ed1ab_1.conda - - conda: https://conda.anaconda.org/conda-forge/osx-64/ruff-0.4.2-py310h4a464a8_0.conda + - conda: https://conda.anaconda.org/conda-forge/osx-64/ruff-0.9.9-py310h9dc1ea1_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/scikit-learn-1.6.1-py310h6ed8a50_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/scipy-1.11.2-py310h3900cf1_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/setuptools-75.8.0-pyhff2d567_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/threadpoolctl-3.5.0-pyhc1e730c_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/tk-8.6.13-h1abcd95_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/tomli-2.2.1-pyhd8ed1ab_1.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/typing_extensions-4.12.2-pyha770c72_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2024b-hc8b5060_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/ukkonen-1.0.1-py310hfa8da69_5.conda - conda: https://conda.anaconda.org/conda-forge/noarch/urllib3-2.3.0-pyhd8ed1ab_0.conda @@ -1909,7 +1911,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/0f/dd/84f10e23edd882c6f968c21c2434fe67bd4a528967067515feca9e611e5e/tzdata-2025.1-py2.py3-none-any.whl - pypi: . osx-arm64: - - conda: https://conda.anaconda.org/conda-forge/osx-arm64/black-23.3.0-py310hbe9552e_1.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/black-24.8.0-py310hbe9552e_1.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/brotli-python-1.1.0-py310hb4ad77e_2.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/bzip2-1.0.8-h99b78c6_7.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/ca-certificates-2024.12.14-hf0a4a13_0.conda @@ -1959,13 +1961,14 @@ environments: - conda: https://conda.anaconda.org/conda-forge/osx-arm64/pyyaml-6.0.2-py310hc74094e_2.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/readline-8.2-h92ec313_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/requests-2.32.3-pyhd8ed1ab_1.conda - - conda: https://conda.anaconda.org/conda-forge/osx-arm64/ruff-0.4.2-py310h275c10e_0.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/ruff-0.9.9-py310hdcf0d46_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/scikit-learn-1.6.1-py310h48c93d9_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/scipy-1.11.2-py310h0975f3d_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/setuptools-75.8.0-pyhff2d567_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/threadpoolctl-3.5.0-pyhc1e730c_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/tk-8.6.13-h5083fa2_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/tomli-2.2.1-pyhd8ed1ab_1.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/typing_extensions-4.12.2-pyha770c72_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2024b-hc8b5060_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/ukkonen-1.0.1-py310h7306fd8_5.conda - conda: https://conda.anaconda.org/conda-forge/noarch/urllib3-2.3.0-pyhd8ed1ab_0.conda @@ -1985,7 +1988,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/0f/dd/84f10e23edd882c6f968c21c2434fe67bd4a528967067515feca9e611e5e/tzdata-2025.1-py2.py3-none-any.whl - pypi: . win-64: - - conda: https://conda.anaconda.org/conda-forge/win-64/black-23.3.0-py310h5588dad_1.conda + - conda: https://conda.anaconda.org/conda-forge/win-64/black-24.8.0-py310h5588dad_1.conda - conda: https://conda.anaconda.org/conda-forge/win-64/brotli-python-1.1.0-py310h9e98ed7_2.conda - conda: https://conda.anaconda.org/conda-forge/win-64/bzip2-1.0.8-h2466b09_7.conda - conda: https://conda.anaconda.org/conda-forge/win-64/ca-certificates-2024.12.14-h56e8100_0.conda @@ -2040,7 +2043,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/win-64/python_abi-3.10-5_cp310.conda - conda: https://conda.anaconda.org/conda-forge/win-64/pyyaml-6.0.2-py310h38315fa_2.conda - conda: https://conda.anaconda.org/conda-forge/noarch/requests-2.32.3-pyhd8ed1ab_1.conda - - conda: https://conda.anaconda.org/conda-forge/win-64/ruff-0.4.2-py310h7f1804c_0.conda + - conda: https://conda.anaconda.org/conda-forge/win-64/ruff-0.9.9-py310h090d742_0.conda - conda: https://conda.anaconda.org/conda-forge/win-64/scikit-learn-1.6.1-py310hf2a6c47_0.conda - conda: https://conda.anaconda.org/conda-forge/win-64/scipy-1.11.2-py310h578b7cb_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/setuptools-75.8.0-pyhff2d567_0.conda @@ -2048,6 +2051,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/noarch/threadpoolctl-3.5.0-pyhc1e730c_0.conda - conda: https://conda.anaconda.org/conda-forge/win-64/tk-8.6.13-h5226925_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/tomli-2.2.1-pyhd8ed1ab_1.conda + - conda: https://conda.anaconda.org/conda-forge/noarch/typing_extensions-4.12.2-pyha770c72_1.conda - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2024b-hc8b5060_0.conda - conda: https://conda.anaconda.org/conda-forge/win-64/ucrt-10.0.22621.0-h57928b3_1.conda - conda: https://conda.anaconda.org/conda-forge/win-64/ukkonen-1.0.1-py310hc19bc0b_5.conda @@ -2528,9 +2532,9 @@ packages: - pkg:pypi/beautifulsoup4?source=compressed-mapping size: 145482 timestamp: 1738740460562 -- conda: https://conda.anaconda.org/conda-forge/linux-64/black-23.3.0-py310hff52083_1.conda - sha256: 9ede541d2f84668f45dd02185d53547e84a5834f8a167d89b74b79b5d7f7a992 - md5: 22bc96cd2aed2482d207ab376fc00f18 +- conda: https://conda.anaconda.org/conda-forge/linux-64/black-24.8.0-py310hff52083_1.conda + sha256: 660306076a8128446c64c057ea2fd87be7b0b42b04d80d51f45c5006f44a7560 + md5: 803feebc8451cf02fb415b603dcd3e36 depends: - click >=8.0.0 - mypy_extensions >=0.4.3 @@ -2540,15 +2544,16 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - tomli >=1.1.0 + - typing_extensions >=4.0.1 license: MIT license_family: MIT purls: - pkg:pypi/black?source=hash-mapping - size: 271936 - timestamp: 1682492054286 -- conda: https://conda.anaconda.org/conda-forge/osx-64/black-23.3.0-py310h2ec42d9_1.conda - sha256: ccd6cb8877ef0a4246c3ad6893e927bc6ddb265b773f908c2188e5e52c2ae37a - md5: dda28fe2408191e4ab3d48df4a331899 + size: 304024 + timestamp: 1726154973752 +- conda: https://conda.anaconda.org/conda-forge/osx-64/black-24.8.0-py310h2ec42d9_1.conda + sha256: 0829ccb0e526aec7825a4ef34d07dbed4d002a0ae9f02e87cff8666cdd9be4d5 + md5: bec9c91e3676af9ca62c3d373f22637b depends: - click >=8.0.0 - mypy_extensions >=0.4.3 @@ -2558,15 +2563,16 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - tomli >=1.1.0 + - typing_extensions >=4.0.1 license: MIT license_family: MIT purls: - pkg:pypi/black?source=hash-mapping - size: 271994 - timestamp: 1682492532222 -- conda: https://conda.anaconda.org/conda-forge/osx-arm64/black-23.3.0-py310hbe9552e_1.conda - sha256: 26ee80c3d884eef62b6850085fdab4ecb83ba91d2a23179b9c2292ec55ba9f52 - md5: a81d69fef268a3a8fba818da27bab102 + size: 305165 + timestamp: 1726154983228 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/black-24.8.0-py310hbe9552e_1.conda + sha256: b403cf7ad2678b0682d86755168c7d3c28974c69caa059aa58e27b04048adc03 + md5: 7e2e651c0c677216559ea424ce6daf67 depends: - click >=8.0.0 - mypy_extensions >=0.4.3 @@ -2577,15 +2583,16 @@ packages: - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 - tomli >=1.1.0 + - typing_extensions >=4.0.1 license: MIT license_family: MIT purls: - pkg:pypi/black?source=hash-mapping - size: 272162 - timestamp: 1682492378469 -- conda: https://conda.anaconda.org/conda-forge/win-64/black-23.3.0-py310h5588dad_1.conda - sha256: 1ce1ddbddf3397fafa1e8cfa5df8add4c2184c09ebc8db29534d933085e8a869 - md5: 1d8f9fb35cc2668ee709dbbdb18864c0 + size: 306017 + timestamp: 1726155314251 +- conda: https://conda.anaconda.org/conda-forge/win-64/black-24.8.0-py310h5588dad_1.conda + sha256: f0497e7b8c9144ab2d53ff95f76f1fb15b2a69c2af5b93c0cc420356c8243c1d + md5: f1db58ddb07812e6b18d68440ed07d84 depends: - click >=8.0.0 - mypy_extensions >=0.4.3 @@ -2595,12 +2602,13 @@ packages: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - tomli >=1.1.0 + - typing_extensions >=4.0.1 license: MIT license_family: MIT purls: - pkg:pypi/black?source=hash-mapping - size: 287586 - timestamp: 1682492402457 + size: 330123 + timestamp: 1726155398256 - conda: https://conda.anaconda.org/conda-forge/noarch/bleach-6.2.0-pyh29332c3_4.conda sha256: a05971bb80cca50ce9977aad3f7fc053e54ea7d5321523efc7b9a6e12901d3cd md5: f0b4c8e370446ef89797608d60a564b3 @@ -6716,8 +6724,8 @@ packages: timestamp: 1736243563082 - pypi: . name: pyikt - version: 0.1.dev151 - sha256: 0e602c12a91f83e11fd62e4d2ea842e14106dceb1d6c4bbee50a3f79903faf86 + version: 0.1.dev152 + sha256: 5e1c3b02e49953855bd5f62b3a8d6030e408650884d22024a42dc9e769c52464 requires_dist: - scikit-learn>=1.2 - pandas>=1.5 @@ -7491,68 +7499,79 @@ packages: - pkg:pypi/rpds-py?source=hash-mapping size: 251319 timestamp: 1740153103392 -- conda: https://conda.anaconda.org/conda-forge/linux-64/ruff-0.4.2-py310h9065425_0.conda - sha256: 64d9aa18c31b7bf9b5f6131afcd9ed5ab956eba0fe54d9d74d6303ac19d5bb6d - md5: cbde66f7f4f8b6231de8614f619a95e1 +- conda: https://conda.anaconda.org/conda-forge/linux-64/ruff-0.9.9-py310h8851ac2_0.conda + sha256: d54c94dabed40dfaac39eed8abfe984565cac9b98211e65b0aaef4abc7baaf21 + md5: 5858183d8265e53d813f211034aa76e4 depends: - - libgcc-ng >=12 - - libstdcxx-ng >=12 + - __glibc >=2.17,<3.0.a0 + - libgcc >=13 + - libstdcxx >=13 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 + constrains: + - __glibc >=2.17 + arch: x86_64 + platform: linux license: MIT license_family: MIT purls: - pkg:pypi/ruff?source=hash-mapping - size: 6305544 - timestamp: 1714088914090 -- conda: https://conda.anaconda.org/conda-forge/osx-64/ruff-0.4.2-py310h4a464a8_0.conda - sha256: aa1a8e035e114b44c5855a8bc8e2b20cb164e66b17a0d8d3df182830ee0e776f - md5: f950d318915d12ea4d0766431ac820c1 + size: 8833469 + timestamp: 1741052377867 +- conda: https://conda.anaconda.org/conda-forge/osx-64/ruff-0.9.9-py310h9dc1ea1_0.conda + sha256: 98bd018b2166d7e251de4d5b50c2bca696d5b0fa3a30ab8ef49e152a4eddce29 + md5: 557b734112353bd913dccfad0c2d170b depends: - - __osx >=10.9 - - libcxx >=16 + - __osx >=10.13 + - libcxx >=18 - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 constrains: - - __osx >=10.12 + - __osx >=10.13 + arch: x86_64 + platform: osx license: MIT license_family: MIT purls: - pkg:pypi/ruff?source=hash-mapping - size: 6093722 - timestamp: 1714089668361 -- conda: https://conda.anaconda.org/conda-forge/osx-arm64/ruff-0.4.2-py310h275c10e_0.conda - sha256: 1812ffbcd86a2b0913f9302d1616f4aa042be5a2c4a98214fe0c2281f3bfee51 - md5: 00e1b0cba8e276e87ecfaa206406301a + size: 8148295 + timestamp: 1741052399938 +- conda: https://conda.anaconda.org/conda-forge/osx-arm64/ruff-0.9.9-py310hdcf0d46_0.conda + sha256: 5dacb1a80b426b1bc25acff74412b50825eaa8c9829f292de499d2866d48671e + md5: 387c7bef8f4c5b1aac49094ec333771e depends: - __osx >=11.0 - - libcxx >=16 + - libcxx >=18 - python >=3.10,<3.11.0a0 - python >=3.10,<3.11.0a0 *_cpython - python_abi 3.10.* *_cp310 constrains: - __osx >=11.0 + arch: arm64 + platform: osx license: MIT license_family: MIT purls: - pkg:pypi/ruff?source=hash-mapping - size: 5839236 - timestamp: 1714089852161 -- conda: https://conda.anaconda.org/conda-forge/win-64/ruff-0.4.2-py310h7f1804c_0.conda - sha256: f7a93bba671f185de24a0b2562ca32294fc88deec50714a1489ffeec0f359fb1 - md5: 21d829b02be70b9d3244ea118b9b3544 + size: 7759023 + timestamp: 1741053034909 +- conda: https://conda.anaconda.org/conda-forge/win-64/ruff-0.9.9-py310h090d742_0.conda + sha256: c3b16e4182f713e1fc063a8c11f804e7e1ce1d5673ba170630f44360a5dcedac + md5: 8574062c445d472c9ce7935c7c2294a2 depends: - python >=3.10,<3.11.0a0 - python_abi 3.10.* *_cp310 - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 + arch: x86_64 + platform: win license: MIT license_family: MIT purls: - pkg:pypi/ruff?source=hash-mapping - size: 6229260 - timestamp: 1714089878264 + size: 7924341 + timestamp: 1741053302702 - conda: https://conda.anaconda.org/conda-forge/linux-64/scikit-learn-1.6.1-py310h27f47ee_0.conda sha256: 5c865487412b900d0abeb934907e5357c4a6cad19093316701ffd575980d0c54 md5: 618ec5a8500fb53e8e52785e06d239f4 diff --git a/pyikt/stream/cluster/utils/serialize_trees.py b/pyikt/stream/cluster/utils/serialize_trees.py index 03f66fb..9d3d2da 100644 --- a/pyikt/stream/cluster/utils/serialize_trees.py +++ b/pyikt/stream/cluster/utils/serialize_trees.py @@ -17,6 +17,7 @@ import numpy as np from numba import jit +from queue import Queue @jit(nopython=True) @@ -64,17 +65,6 @@ def _fast_norm_diff(x, y): return _fast_norm(x - y) -try: - from Queue import Queue -except: - pass - -try: - from queue import Queue -except: - pass - - def serliaze_tree_to_file_with_point_ids(root, fn): with open(fn, "w") as fout: queue = Queue() diff --git a/pyproject.toml b/pyproject.toml index 0d7e615..6982ae2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,9 +88,9 @@ pyikt = { path = ".", editable = true } [tool.pixi.feature.lint.dependencies] # The version below should be aligned with the one of `.pre-commit-config.yaml` -black = "23.3.0" +black = "24.8.0" pre-commit = "3.7.1" -ruff = "0.4.2" +ruff = "0.9.9" [tool.pixi.feature.lint.tasks] black = { cmd = "black --check --diff pyikt && black --check --diff examples" } @@ -113,7 +113,7 @@ mkdocstrings = "0.26.1" mkdocstrings-python = "1.11.1" notebook = "6.4.12" jupyter_contrib_nbextensions = "0.7.0" -black = "23.3.0" +black = "24.8.0" [tool.pixi.feature.doc.tasks] clean-doc = { cmd = "rm -rf site" } From ae68a27c2fcbc3312c951db12c80e9678690ae1a Mon Sep 17 00:00:00 2001 From: Xin Han Date: Mon, 10 Mar 2025 11:50:46 +1100 Subject: [PATCH 3/5] rename pyikt as ikpykit --- .coveragerc | 4 +- .github/workflows/pypi.yml | 4 +- .github/workflows/python-app.yml | 2 +- .gitignore | 2 +- LICENSE | 2 +- README.md | 95 +++++++++--------- docs/README.md | 60 ++++++----- docs/api/anomaly/idkd.md | 2 +- docs/api/anomaly/iforest.md | 2 +- docs/api/anomaly/inne.md | 2 +- docs/api/cluster/idkc.md | 2 +- docs/api/cluster/ikahc.md | 2 +- docs/api/cluster/pskc.md | 2 +- docs/api/graph/IsoGraphKernel.md | 2 +- docs/api/graph/ikgod.md | 2 +- docs/api/group/ikgad.md | 2 +- docs/api/kernel/isolation_dis_kernel.md | 2 +- docs/api/kernel/isolation_kernel.md | 2 +- docs/api/stream/icid.md | 2 +- docs/api/stream/streakhc.md | 2 +- docs/api/time_series/iktod.md | 2 +- docs/api/trajectory/data_loader/sheep_dogs.md | 2 +- docs/api/trajectory/ikat.md | 2 +- docs/api/trajectory/tidkc.md | 2 +- docs/contributing/contribution.md | 10 +- docs/examples/examples_english.md | 2 +- docs/quick-start/how-to-install.md | 12 +-- docs/releases/releases.md | 4 +- docs/user_guides/inne.ipynb | 4 +- docs/user_guides/table-of-contents.md | 4 +- examples/plot_inne.py | 4 +- {pyikt => ikpykit}/__init__.py | 4 +- {pyikt => ikpykit}/anomaly/__init__.py | 4 +- {pyikt => ikpykit}/anomaly/_idkd.py | 8 +- {pyikt => ikpykit}/anomaly/_iforest.py | 6 +- {pyikt => ikpykit}/anomaly/_inne.py | 6 +- {pyikt => ikpykit}/anomaly/tests/__init__.py | 0 {pyikt => ikpykit}/anomaly/tests/test_idkd.py | 2 +- {pyikt => ikpykit}/anomaly/tests/test_inne.py | 2 +- {pyikt => ikpykit}/cluster/__init__.py | 0 {pyikt => ikpykit}/cluster/_idkc.py | 8 +- {pyikt => ikpykit}/cluster/_ikahc.py | 8 +- {pyikt => ikpykit}/cluster/_kcluster.py | 4 +- {pyikt => ikpykit}/cluster/_pskc.py | 10 +- {pyikt => ikpykit}/cluster/_utils.py | 4 +- {pyikt => ikpykit}/cluster/tests/__init__.py | 0 {pyikt => ikpykit}/cluster/tests/test_idkc.py | 6 +- .../cluster/tests/test_ikahc.py | 6 +- {pyikt => ikpykit}/cluster/tests/test_pskc.py | 2 +- {pyikt => ikpykit}/graph/__init__.py | 4 +- {pyikt => ikpykit}/graph/_ikgod.py | 10 +- {pyikt => ikpykit}/graph/_isographkernel.py | 10 +- {pyikt => ikpykit}/graph/tests/test_ikgod.py | 2 +- .../graph/tests/test_isographkernel.py | 2 +- {pyikt => ikpykit}/graph/utils.py | 4 +- {pyikt => ikpykit}/group/__init__.py | 4 +- {pyikt => ikpykit}/group/anomaly/__init__.py | 0 {pyikt => ikpykit}/group/anomaly/_ikgad.py | 10 +- {pyikt => ikpykit}/group/tests/test_Ikgad.py | 6 +- {pyikt => ikpykit}/group/utils.py | 4 +- {pyikt => ikpykit}/kernel/__init__.py | 4 +- {pyikt => ikpykit}/kernel/_ik_anne.py | 4 +- {pyikt => ikpykit}/kernel/_ik_iforest.py | 4 +- {pyikt => ikpykit}/kernel/_ik_inne.py | 4 +- {pyikt => ikpykit}/kernel/_isodiskernel.py | 8 +- {pyikt => ikpykit}/kernel/_isokernel.py | 12 +-- {pyikt => ikpykit}/kernel/tests/__init__.py | 0 .../kernel/tests/test_isodiskernel.py | 2 +- .../kernel/tests/test_isokernel.py | 2 +- {pyikt => ikpykit}/stream/__init__.py | 4 +- .../stream/changedetect/__init__.py | 0 .../stream/changedetect/_icid.py | 8 +- {pyikt => ikpykit}/stream/cluster/__init__.py | 0 {pyikt => ikpykit}/stream/cluster/_inode.py | 4 +- .../stream/cluster/_streakhc.py | 8 +- .../stream/cluster/utils/Graphviz.py | 0 .../stream/cluster/utils/__init__.py | 0 .../stream/cluster/utils/deltasep_utils.py | 0 .../stream/cluster/utils/dendrogram_purity.py | 0 .../cluster/utils/dendrogram_purity_pool.py | 0 .../stream/cluster/utils/file_utils.py | 0 .../stream/cluster/utils/logger.py | 0 .../stream/cluster/utils/serialize_trees.py | 0 {pyikt => ikpykit}/stream/tests/test_icid.py | 2 +- .../stream/tests/test_streakhc.py | 2 +- {pyikt => ikpykit}/timeseries/__init__.py | 4 +- .../timeseries/anomaly/__init__.py | 0 .../timeseries/anomaly/_iktod.py | 8 +- .../timeseries/tests/test_iktod.py | 2 +- {pyikt => ikpykit}/trajectory/__init__.py | 4 +- .../trajectory/anomaly/__init__.py | 0 .../trajectory/anomaly/_ikat.py | 8 +- .../trajectory/cluster/__init__.py | 0 .../trajectory/cluster/_tidkc.py | 14 +-- .../trajectory/dataloader/__init__.py | 0 .../trajectory/dataloader/_sheepdogs.py | 2 +- .../trajectory/dataloader/base.py | 0 .../dataloader/datasets/flyingfox.zip | Bin .../dataloader/datasets/sheepdogs.zip | Bin .../trajectory/dataloader/datasets/turkey.zip | Bin .../dataloader/datasets/wildebeest.zip | Bin .../trajectory/tests/test_ikat.py | 2 +- .../trajectory/tests/test_tidkc.py | 2 +- {pyikt => ikpykit}/trajectory/utils.py | 4 +- mkdocs.yml | 10 +- pixi.lock | 32 +++--- pyproject.toml | 28 +++--- 107 files changed, 278 insertions(+), 289 deletions(-) rename {pyikt => ikpykit}/__init__.py (93%) rename {pyikt => ikpykit}/anomaly/__init__.py (87%) rename {pyikt => ikpykit}/anomaly/_idkd.py (98%) rename {pyikt => ikpykit}/anomaly/_iforest.py (98%) rename {pyikt => ikpykit}/anomaly/_inne.py (99%) rename {pyikt => ikpykit}/anomaly/tests/__init__.py (100%) rename {pyikt => ikpykit}/anomaly/tests/test_idkd.py (98%) rename {pyikt => ikpykit}/anomaly/tests/test_inne.py (99%) rename {pyikt => ikpykit}/cluster/__init__.py (100%) rename {pyikt => ikpykit}/cluster/_idkc.py (98%) rename {pyikt => ikpykit}/cluster/_ikahc.py (98%) rename {pyikt => ikpykit}/cluster/_kcluster.py (97%) rename {pyikt => ikpykit}/cluster/_pskc.py (97%) rename {pyikt => ikpykit}/cluster/_utils.py (96%) rename {pyikt => ikpykit}/cluster/tests/__init__.py (100%) rename {pyikt => ikpykit}/cluster/tests/test_idkc.py (95%) rename {pyikt => ikpykit}/cluster/tests/test_ikahc.py (98%) rename {pyikt => ikpykit}/cluster/tests/test_pskc.py (99%) rename {pyikt => ikpykit}/graph/__init__.py (87%) rename {pyikt => ikpykit}/graph/_ikgod.py (98%) rename {pyikt => ikpykit}/graph/_isographkernel.py (97%) rename {pyikt => ikpykit}/graph/tests/test_ikgod.py (99%) rename {pyikt => ikpykit}/graph/tests/test_isographkernel.py (98%) rename {pyikt => ikpykit}/graph/utils.py (98%) rename {pyikt => ikpykit}/group/__init__.py (85%) rename {pyikt => ikpykit}/group/anomaly/__init__.py (100%) rename {pyikt => ikpykit}/group/anomaly/_ikgad.py (98%) rename {pyikt => ikpykit}/group/tests/test_Ikgad.py (97%) rename {pyikt => ikpykit}/group/utils.py (97%) rename {pyikt => ikpykit}/kernel/__init__.py (87%) rename {pyikt => ikpykit}/kernel/_ik_anne.py (99%) rename {pyikt => ikpykit}/kernel/_ik_iforest.py (97%) rename {pyikt => ikpykit}/kernel/_ik_inne.py (99%) rename {pyikt => ikpykit}/kernel/_isodiskernel.py (97%) rename {pyikt => ikpykit}/kernel/_isokernel.py (96%) rename {pyikt => ikpykit}/kernel/tests/__init__.py (100%) rename {pyikt => ikpykit}/kernel/tests/test_isodiskernel.py (96%) rename {pyikt => ikpykit}/kernel/tests/test_isokernel.py (97%) rename {pyikt => ikpykit}/stream/__init__.py (88%) rename {pyikt => ikpykit}/stream/changedetect/__init__.py (100%) rename {pyikt => ikpykit}/stream/changedetect/_icid.py (98%) rename {pyikt => ikpykit}/stream/cluster/__init__.py (100%) rename {pyikt => ikpykit}/stream/cluster/_inode.py (99%) rename {pyikt => ikpykit}/stream/cluster/_streakhc.py (98%) rename {pyikt => ikpykit}/stream/cluster/utils/Graphviz.py (100%) rename {pyikt => ikpykit}/stream/cluster/utils/__init__.py (100%) rename {pyikt => ikpykit}/stream/cluster/utils/deltasep_utils.py (100%) rename {pyikt => ikpykit}/stream/cluster/utils/dendrogram_purity.py (100%) rename {pyikt => ikpykit}/stream/cluster/utils/dendrogram_purity_pool.py (100%) rename {pyikt => ikpykit}/stream/cluster/utils/file_utils.py (100%) rename {pyikt => ikpykit}/stream/cluster/utils/logger.py (100%) rename {pyikt => ikpykit}/stream/cluster/utils/serialize_trees.py (100%) rename {pyikt => ikpykit}/stream/tests/test_icid.py (99%) rename {pyikt => ikpykit}/stream/tests/test_streakhc.py (99%) rename {pyikt => ikpykit}/timeseries/__init__.py (85%) rename {pyikt => ikpykit}/timeseries/anomaly/__init__.py (100%) rename {pyikt => ikpykit}/timeseries/anomaly/_iktod.py (98%) rename {pyikt => ikpykit}/timeseries/tests/test_iktod.py (98%) rename {pyikt => ikpykit}/trajectory/__init__.py (86%) rename {pyikt => ikpykit}/trajectory/anomaly/__init__.py (100%) rename {pyikt => ikpykit}/trajectory/anomaly/_ikat.py (97%) rename {pyikt => ikpykit}/trajectory/cluster/__init__.py (100%) rename {pyikt => ikpykit}/trajectory/cluster/_tidkc.py (96%) rename {pyikt => ikpykit}/trajectory/dataloader/__init__.py (100%) rename {pyikt => ikpykit}/trajectory/dataloader/_sheepdogs.py (98%) rename {pyikt => ikpykit}/trajectory/dataloader/base.py (100%) rename {pyikt => ikpykit}/trajectory/dataloader/datasets/flyingfox.zip (100%) rename {pyikt => ikpykit}/trajectory/dataloader/datasets/sheepdogs.zip (100%) rename {pyikt => ikpykit}/trajectory/dataloader/datasets/turkey.zip (100%) rename {pyikt => ikpykit}/trajectory/dataloader/datasets/wildebeest.zip (100%) rename {pyikt => ikpykit}/trajectory/tests/test_ikat.py (99%) rename {pyikt => ikpykit}/trajectory/tests/test_tidkc.py (98%) rename {pyikt => ikpykit}/trajectory/utils.py (98%) diff --git a/.coveragerc b/.coveragerc index f4c14a7..8019ee9 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,5 +2,5 @@ [run] branch = True -source = pyikt -include = */pyikt/* +source = ikpykit +include = */ikpykit/* diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index f2b9d8c..2c5ad14 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -38,7 +38,7 @@ jobs: if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) environment: name: testpypi - url: https://test.pypi.org/p/pyikt # Update to your actual package name + url: https://test.pypi.org/p/ikpykit # Update to your actual package name permissions: id-token: write steps: @@ -59,7 +59,7 @@ jobs: if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') environment: name: pypi - url: https://pypi.org/p/pyikt # Update to your actual package name + url: https://pypi.org/p/ikpykit # Update to your actual package name permissions: id-token: write steps: diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index aa549fc..a6d0fe4 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -30,4 +30,4 @@ jobs: uses: codecov/codecov-action@v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} - slug: IsolationKernel/pyikt + slug: IsolationKernel/ikpykit diff --git a/.gitignore b/.gitignore index a89af71..fa737ca 100644 --- a/.gitignore +++ b/.gitignore @@ -190,4 +190,4 @@ myx_test/ # pixi environments .pixi *.egg-info -pyikt/_version.py +ikpykit/_version.py diff --git a/LICENSE b/LICENSE index bb33d7d..fd6c0a3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han Attribution-NonCommercial-NoDerivatives 4.0 International diff --git a/README.md b/README.md index 92cd346..35da24f 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,25 @@ - ![Python](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue) -[![PyPI](https://img.shields.io/pypi/v/pyikt)](https://pypi.org/project/pyikt/) -[![codecov](https://codecov.io/gh/IsolationKernel/pyikt/branch/master/graph/badge.svg)](https://codecov.io/gh/IsolationKernel/pyikt) -[![Build status](https://github.com/IsolationKernel/pyikt/actions/workflows/python-app.yml/badge.svg)](https://github.com/IsolationKernel/pyikt/actions/workflows/python-app.yml/badge.svg) +[![PyPI](https://img.shields.io/pypi/v/ikpykit)](https://pypi.org/project/ikpykit/) +[![codecov](https://codecov.io/gh/IsolationKernel/ikpykit/branch/master/graph/badge.svg)](https://codecov.io/gh/IsolationKernel/ikpykit) +[![Build status](https://github.com/IsolationKernel/ikpykit/actions/workflows/python-app.yml/badge.svg)](https://github.com/IsolationKernel/ikpykit/actions/workflows/python-app.yml/badge.svg) [![Project Status: Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) -[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/IsolationKernel/pyikt/graphs/commit-activity) -[![Downloads](https://static.pepy.tech/badge/pyikt)](https://pepy.tech/project/pyikt) -[![Downloads](https://static.pepy.tech/badge/pyikt/month)](https://pepy.tech/project/pyikt) -[![License](https://img.shields.io/github/license/IsolationKernel/pyikt)](https://github.com/IsolationKernel/pyikt/blob/master/LICENSE) +[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/IsolationKernel/ikpykit/graphs/commit-activity) +[![Downloads](https://static.pepy.tech/badge/ikpykit)](https://pepy.tech/project/ikpykit) +[![Downloads](https://static.pepy.tech/badge/ikpykit/month)](https://pepy.tech/project/ikpykit) +[![License](https://img.shields.io/github/license/IsolationKernel/ikpykit)](https://github.com/IsolationKernel/ikpykit/blob/master/LICENSE) ## About The Project -**PyIKT** (Python for Isolation Kernel Toolkit) is an intuitive Python library designed for a variety of machine learning tasks including kernel similarity calculation, anomaly detection, clustering, and change detection—all powered by the innovative **Isolation Kernel (IK)** . Isolation Kernel is a data-dependent kernel that measures similarity by isolating data points using an isolation mechanism. It uniquely adapts to the data distribution, with the property that points in sparse regions are more similar than those in dense regions. Notably, it requires no learning or closed-form expression, making it efficient and scalable. +**IKPyKit** (Isolation Kernel Python toolKit) is an intuitive Python library designed for a variety of machine learning tasks including kernel similarity calculation, anomaly detection, clustering, and change detection—all powered by the innovative **Isolation Kernel (IK)** . Isolation Kernel is a data-dependent kernel that measures similarity by isolating data points using an isolation mechanism. It uniquely adapts to the data distribution, with the property that points in sparse regions are more similar than those in dense regions. Notably, it requires no learning or closed-form expression, making it efficient and scalable. --- @@ -36,27 +35,27 @@ Learn more about its history and development on the [IsolationKernel GitHub page --- -### Why use PyIKT? +### Why use IKPyKit? -PyIKT is specifically built to harness the power of Isolation Kernel, providing specialized algorithms for a wide range of data types and tasks. Its seamless integration with the scikit-learn API allows easy adoption and compatibility with scikit-learn tools. +IKPyKit is specifically built to harness the power of Isolation Kernel, providing specialized algorithms for a wide range of data types and tasks. Its seamless integration with the scikit-learn API allows easy adoption and compatibility with scikit-learn tools. -- **Tailored for Isolation Kernel**: PyIKT directly leverages the unique properties of Isolation Kernel for efficient and effective machine learning solutions. -- **Efficient and User-Friendly**: Designed for simplicity and performance, PyIKT offers an intuitive interface built on the scikit-learn API. +- **Tailored for Isolation Kernel**: IKPyKit directly leverages the unique properties of Isolation Kernel for efficient and effective machine learning solutions. +- **Efficient and User-Friendly**: Designed for simplicity and performance, IKPyKit offers an intuitive interface built on the scikit-learn API. - **Support for Diverse Data Types**: It supports graph data, group data, stream data, time series, and trajectory data, making it versatile for various domains. - **Comprehensive Resources**: Users benefit from rich documentation and examples to quickly understand and apply the library’s features. -- **Ideal for Research and Industry**: PyIKT is suitable for both academic research and industrial applications, providing scalable and cutting-edge tools for modern machine learning challenges. +- **Ideal for Research and Industry**: IKPyKit is suitable for both academic research and industrial applications, providing scalable and cutting-edge tools for modern machine learning challenges. --- ## Installation & Dependencies -To install the basic version of `pyikt` with core dependencies, run the following: +To install the basic version of `ikpykit` with core dependencies, run the following: ```bash -pip install pyikt +pip install ikpykit ``` -For more installation options, including dependencies and additional features, check out our [Installation Guide](https://isolationkernel.github.io/pyikt/quick-start/how-to-install.html). +For more installation options, including dependencies and additional features, check out our [Installation Guide](https://isolationkernel.github.io/ikpykit/quick-start/how-to-install.html). --- @@ -65,7 +64,7 @@ For more installation options, including dependencies and additional features, c ```py # Anomaly Detection using inne. import numpy as np -from pyikt.anomaly import INNE +from ikpykit.anomaly import INNE X = np.array([[-1.1, 0.2], [0.3, 0.5], [0.5, 1.1], [100, 90]]) clf = INNE(contamination=0.25).fit(X) clf.predict([[0.1, 0.3], [0, 0.7], [90, 85]]) @@ -92,104 +91,104 @@ clf.predict([[0.1, 0.3], [0, 0.7], [90, 85]]) | Abbr | Algorithm | Utilization | Published | | -------------------------------------------------------------------------------------------- | ----------------------------- | --------------------------------------------- | -------------------- | -| [IsoKernel](https://isolationkernel.github.io/pyikt/api/kernel/isolation_kernel.html) | Isolation Kernel | IK feature mapping and similarity calculating | AAAI2019, SIGKDD2018 | -| [IsodisKernel](https://isolationkernel.github.io/pyikt/api/kernel/isolation_dis_kernel.html) | Isolation Distribution Kernel | Distribution similarity calculating | SIGKDD2022 | +| [IsoKernel](https://isolationkernel.github.io/ikpykit/api/kernel/isolation_kernel.html) | Isolation Kernel | IK feature mapping and similarity calculating | AAAI2019, SIGKDD2018 | +| [IsodisKernel](https://isolationkernel.github.io/ikpykit/api/kernel/isolation_dis_kernel.html) | Isolation Distribution Kernel | Distribution similarity calculating | SIGKDD2022 | **(ii) Point Anomaly detection** : | Abbr | Algorithm | Utiliztion | Published | | --------------------------------------------------------------------------- | ------------------------------------------------------------------ | ----------------- | ------------------ | -| [IForest](https://isolationkernel.github.io/pyikt/api/anomaly/iforest.html) | Isolation forest | Anomaly Detection | ICDM2008, TKDD2022 | -| [INNE](https://isolationkernel.github.io/pyikt/api/anomaly/inne.html) | Isolation-based anomaly detection using nearest-neighbor ensembles | Anomaly Detection | CIJ2018 | -| [IDKD](https://isolationkernel.github.io/pyikt/api/anomaly/idkd.html) | Isolation Distributional Kernel for point anomaly detections | Anomaly Detection | TKDE2022 | +| [IForest](https://isolationkernel.github.io/ikpykit/api/anomaly/iforest.html) | Isolation forest | Anomaly Detection | ICDM2008, TKDD2022 | +| [INNE](https://isolationkernel.github.io/ikpykit/api/anomaly/inne.html) | Isolation-based anomaly detection using nearest-neighbor ensembles | Anomaly Detection | CIJ2018 | +| [IDKD](https://isolationkernel.github.io/ikpykit/api/anomaly/idkd.html) | Isolation Distributional Kernel for point anomaly detections | Anomaly Detection | TKDE2022 | **(iii) Point Clustering** : | Abbr | Algorithm | Utiliztion | Published | | ----------------------------------------------------------------------- | ------------------------------------------------------------ | ----------------------- | --------- | -| [IDKC](https://isolationkernel.github.io/pyikt/api/cluster/idkc.html) | Kernel-based Clustering via Isolation Distributional Kernel. | Point Clustering | IS2023 | -| [PSKC](https://isolationkernel.github.io/pyikt/api/cluster/pskc.html) | Point-set Kernel Clustering | Point Clustering | TKDE2023 | -| [IKAHC](https://isolationkernel.github.io/pyikt/api/cluster/ikahc.html) | Isolation Kernel for Agglomerative Hierarchical Clustering | Hierarchical Clustering | PR2023 | +| [IDKC](https://isolationkernel.github.io/ikpykit/api/cluster/idkc.html) | Kernel-based Clustering via Isolation Distributional Kernel. | Point Clustering | IS2023 | +| [PSKC](https://isolationkernel.github.io/ikpykit/api/cluster/pskc.html) | Point-set Kernel Clustering | Point Clustering | TKDE2023 | +| [IKAHC](https://isolationkernel.github.io/ikpykit/api/cluster/ikahc.html) | Isolation Kernel for Agglomerative Hierarchical Clustering | Hierarchical Clustering | PR2023 | **(IV) Graph Data** : | Abbr | Algorithm | Utiliztion | Published | | --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | --------------------------------------------- | --------- | -| [IKGOD](https://isolationkernel.github.io/pyikt/api/graph/ikgod.html) | Subgraph Centralization: A Necessary Step for Graph Anomaly Detection. | Graph Anomaly Detection | SIAM2023 | -| [IsoGraphKernel](https://isolationkernel.github.io/pyikt/api/graph/IsoGraphKernel.html) | Isolation Graph Kernel | Graph IK embedding and similarity calculating | AAAI2021 | +| [IKGOD](https://isolationkernel.github.io/ikpykit/api/graph/ikgod.html) | Subgraph Centralization: A Necessary Step for Graph Anomaly Detection. | Graph Anomaly Detection | SIAM2023 | +| [IsoGraphKernel](https://isolationkernel.github.io/ikpykit/api/graph/IsoGraphKernel.html) | Isolation Graph Kernel | Graph IK embedding and similarity calculating | AAAI2021 | **(V) Group Data** : | Abbr | Algorithm | Utiliztion | Published | | --------------------------------------------------------------------- | ------------------------------------------------------------ | ----------------------- | --------- | -| [IKGAD](https://isolationkernel.github.io/pyikt/api/group/ikgad.html) | Isolation Distributional Kernel for group anomaly detections | Group Anomaly Detection | TKDE2022 | +| [IKGAD](https://isolationkernel.github.io/ikpykit/api/group/ikgad.html) | Isolation Distributional Kernel for group anomaly detections | Group Anomaly Detection | TKDE2022 | **(VI) Stream Data** : | Abbr | Algorithm | Utiliztion | Published | | ---------------------------------------------------------------------------- | --------------------------------------------------------------- | ------------------------------ | ---------- | -| [StreaKHC](https://isolationkernel.github.io/pyikt/api/stream/streakhc.html) | Isolation Distribution Kernel for Trajectory Anomaly Detections | Online Hierarchical Clustering | SIGKDD2022 | -| [ICID](https://isolationkernel.github.io/pyikt/api/stream/icid.html) | Detecting change intervals with isolation distributional kernel | Change Intervals Detection | JAIR2024 | +| [StreaKHC](https://isolationkernel.github.io/ikpykit/api/stream/streakhc.html) | Isolation Distribution Kernel for Trajectory Anomaly Detections | Online Hierarchical Clustering | SIGKDD2022 | +| [ICID](https://isolationkernel.github.io/ikpykit/api/stream/icid.html) | Detecting change intervals with isolation distributional kernel | Change Intervals Detection | JAIR2024 | **(VII) Trajectory Data** : | Abbr | Algorithm | Utiliztion | Published | | -------------------------------------------------------------------------- | --------------------------------------------------------------- | ---------------------------- | --------- | -| [TIDKC](https://isolationkernel.github.io/pyikt/api/trajectory/tidkc.html) | Distribution-based Tajectory Clustering | Trajectory Clustering | ICDM2023 | -| [IKAT](https://isolationkernel.github.io/pyikt/api/trajectory/ikat.html) | Isolation Distribution Kernel for Trajectory Anomaly Detections | Trajectory Anomaly Detection | JAIR2024 | +| [TIDKC](https://isolationkernel.github.io/ikpykit/api/trajectory/tidkc.html) | Distribution-based Tajectory Clustering | Trajectory Clustering | ICDM2023 | +| [IKAT](https://isolationkernel.github.io/ikpykit/api/trajectory/ikat.html) | Isolation Distribution Kernel for Trajectory Anomaly Detections | Trajectory Anomaly Detection | JAIR2024 | **(VIII) Time Series** | Abbr | Algorithm | Utiliztion | Published | | --------------------------------------------------------------------------- | --------------------------------------------------------------- | ----------------- | --------- | -| [IKTOD](https://isolationkernel.github.io/pyikt/api/time_series/iktod.html) | Isolation distribution kernel for Time Series Anomaly Detection | Anomaly detection | VLDB2022 | +| [IKTOD](https://isolationkernel.github.io/ikpykit/api/time_series/iktod.html) | Isolation distribution kernel for Time Series Anomaly Detection | Anomaly detection | VLDB2022 | --- ## Features -pyikt provides a set of key features designed to make time series forecasting with machine learning easy and efficient. For a detailed overview, see the [User Guides](https://isolationkernel.github.io/pyikt/user_guides/table-of-contents.html). +ikpykit provides a set of key features designed to make time series forecasting with machine learning easy and efficient. For a detailed overview, see the [User Guides](https://isolationkernel.github.io/ikpykit/user_guides/table-of-contents.html). --- ## Examples and tutorials -Explore our extensive list of examples and tutorials (English and Spanish) to get you started with PyIKT. You can find them [here](https://isolationkernel.github.io/pyikt/examples/examples_english.html). +Explore our extensive list of examples and tutorials (English and Spanish) to get you started with ikpykit. You can find them [here](https://isolationkernel.github.io/ikpykit/examples/examples_english.html). --- ## How to contribute -Primarily, PyIKT development consists of adding and creating new *Forecasters*, new validation strategies, or improving the performance of the current code. However, there are many other ways to contribute: +Primarily, ikpykit development consists of adding and creating new *Forecasters*, new validation strategies, or improving the performance of the current code. However, there are many other ways to contribute: -- Submit a bug report or feature request on [GitHub Issues](https://github.com/IsolationKernel/pyikt/issues). -- Contribute a Jupyter notebook to our [examples](https://isolationkernel.github.io/pyikt/examples/examples_english.html). +- Submit a bug report or feature request on [GitHub Issues](https://github.com/IsolationKernel/ikpykit/issues). +- Contribute a Jupyter notebook to our [examples](https://isolationkernel.github.io/ikpykit/examples/examples_english.html). - Write [unit or integration tests](https://docs.pytest.org/en/latest/) for our project. - Answer questions on our issues, Stack Overflow, and elsewhere. - Translate our documentation into another language. - Write a blog post, tweet, or share our project with others. -For more information on how to contribute to pyikt, see our [Contribution Guide](https://isolationkernel.github.io/pyikt/contributing/contribution.html). +For more information on how to contribute to ikpykit, see our [Contribution Guide](https://isolationkernel.github.io/ikpykit/contributing/contribution.html). -Visit our [authors section](https://isolationkernel.github.io/pyikt/authors/authors.html) to meet all the contributors to pyikt. +Visit our [authors section](https://isolationkernel.github.io/ikpykit/authors/authors.html) to meet all the contributors to ikpykit. --- ## Citation -If you use pyikt for a scientific publication, we would appreciate citations to the published software. +If you use ikpykit for a scientific publication, we would appreciate citations to the published software. **BibTeX**: ``` -@software{PyIKT, +@software{IKPyKit, author = {Xin Han, Yixiao Ma, Ye Zhu, and Kaiming Ting}, -title = {PyIKT:A Python Library for Isolation Kernel Toolkit}, +title = {IKPyKit:A Python Library for Isolation Kernel Toolkit}, version = {0.1.0}, month = {3}, year = {2025}, license = {BSD-3-Clause}, -url = {https://github.com/IsolationKernel/pyikt} +url = {https://github.com/IsolationKernel/ikpykit} } ``` @@ -197,4 +196,4 @@ url = {https://github.com/IsolationKernel/pyikt} ## License -[BSD-3-Clause License](https://github.com/IsolationKernel/pyikt/blob/master/LICENSE) +[BSD-3-Clause License](https://github.com/IsolationKernel/ikpykit/blob/master/LICENSE) diff --git a/docs/README.md b/docs/README.md index 001bf20..0dbb5e6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,27 +1,25 @@ ![Python](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue) -[![PyPI](https://img.shields.io/pypi/v/pyikt)](https://pypi.org/project/pyikt/) -[![codecov](https://codecov.io/gh/IsolationKernel/pyikt/branch/master/graph/badge.svg)](https://codecov.io/gh/IsolationKernel/pyikt) -[![Build status](https://github.com/IsolationKernel/pyikt/actions/workflows/python-app.yml/badge.svg)](https://github.com/IsolationKernel/pyikt/actions/workflows/python-app.yml/badge.svg) +[![PyPI](https://img.shields.io/pypi/v/ikpykit)](https://pypi.org/project/ikpykit/) +[![codecov](https://codecov.io/gh/IsolationKernel/ikpykit/branch/master/graph/badge.svg)](https://codecov.io/gh/IsolationKernel/ikpykit) +[![Build status](https://github.com/IsolationKernel/ikpykit/actions/workflows/python-app.yml/badge.svg)](https://github.com/IsolationKernel/ikpykit/actions/workflows/python-app.yml/badge.svg) [![Project Status: Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) -[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/IsolationKernel/pyikt/graphs/commit-activity) -[![Downloads](https://static.pepy.tech/badge/pyikt)](https://pepy.tech/project/pyikt) -[![Downloads](https://static.pepy.tech/badge/pyikt/month)](https://pepy.tech/project/pyikt) -[![License](https://img.shields.io/github/license/IsolationKernel/pyikt)](https://github.com/IsolationKernel/pyikt/blob/master/LICENSE) - - +[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/IsolationKernel/ikpykit/graphs/commit-activity) +[![Downloads](https://static.pepy.tech/badge/ikpykit)](https://pepy.tech/project/ikpykit) +[![Downloads](https://static.pepy.tech/badge/ikpykit/month)](https://pepy.tech/project/ikpykit) +[![License](https://img.shields.io/github/license/IsolationKernel/ikpykit)](https://github.com/IsolationKernel/ikpykit/blob/master/LICENSE) ## About The Project -**PyIKT** (Python for Isolation Kernel Toolkit) is an intuitive Python library designed for a variety of machine learning tasks including kernel similarity calculation, anomaly detection, clustering, and change detection—all powered by the innovative **Isolation Kernel (IK)** . Isolation Kernel is a data-dependent kernel that measures similarity by isolating data points using an isolation mechanism. It uniquely adapts to the data distribution, with the property that points in sparse regions are more similar than those in dense regions. Notably, it requires no learning or closed-form expression, making it efficient and scalable. +**IKPyKit** (Python for Isolation Kernel Toolkit) is an intuitive Python library designed for a variety of machine learning tasks including kernel similarity calculation, anomaly detection, clustering, and change detection—all powered by the innovative **Isolation Kernel (IK)** . Isolation Kernel is a data-dependent kernel that measures similarity by isolating data points using an isolation mechanism. It uniquely adapts to the data distribution, with the property that points in sparse regions are more similar than those in dense regions. Notably, it requires no learning or closed-form expression, making it efficient and scalable. --- @@ -37,24 +35,24 @@ Learn more about its history and development on the [IsolationKernel GitHub page --- -### Why use PyIKT? +### Why use IKPyKit? -PyIKT is specifically built to harness the power of Isolation Kernel, providing specialized algorithms for a wide range of data types and tasks. Its seamless integration with the scikit-learn API allows easy adoption and compatibility with scikit-learn tools. +IKPyKit is specifically built to harness the power of Isolation Kernel, providing specialized algorithms for a wide range of data types and tasks. Its seamless integration with the scikit-learn API allows easy adoption and compatibility with scikit-learn tools. -- **Tailored for Isolation Kernel**: PyIKT directly leverages the unique properties of Isolation Kernel for efficient and effective machine learning solutions. -- **Efficient and User-Friendly**: Designed for simplicity and performance, PyIKT offers an intuitive interface built on the scikit-learn API. +- **Tailored for Isolation Kernel**: IKPyKit directly leverages the unique properties of Isolation Kernel for efficient and effective machine learning solutions. +- **Efficient and User-Friendly**: Designed for simplicity and performance, IKPyKit offers an intuitive interface built on the scikit-learn API. - **Support for Diverse Data Types**: It supports graph data, group data, stream data, time series, and trajectory data, making it versatile for various domains. - **Comprehensive Resources**: Users benefit from rich documentation and examples to quickly understand and apply the library’s features. -- **Ideal for Research and Industry**: PyIKT is suitable for both academic research and industrial applications, providing scalable and cutting-edge tools for modern machine learning challenges. +- **Ideal for Research and Industry**: IKPyKit is suitable for both academic research and industrial applications, providing scalable and cutting-edge tools for modern machine learning challenges. --- ## Installation & Dependencies -To install the basic version of `pyikt` with core dependencies, run the following: +To install the basic version of `IKPyKit` with core dependencies, run the following: ```bash -pip install pyikt +pip install ikpykit ``` For more installation options, including dependencies and additional features, check out our [Installation Guide](./quick-start/how-to-install.html). @@ -66,7 +64,7 @@ For more installation options, including dependencies and additional features, c ```py # Anomaly Detection using inne. import numpy as np -from pyikt.anomaly import INNE +from ikpykit.anomaly import INNE X = np.array([[-1.1, 0.2], [0.3, 0.5], [0.5, 1.1], [100, 90]]) clf = INNE(contamination=0.25).fit(X) clf.predict([[0.1, 0.3], [0, 0.7], [90, 85]]) @@ -149,48 +147,48 @@ clf.predict([[0.1, 0.3], [0, 0.7], [90, 85]]) ## Features -pyikt provides a set of key features designed to make time series forecasting with machine learning easy and efficient. For a detailed overview, see the [User Guides](./user_guides/table-of-contents.html). +ikpykit provides a set of key features designed to make time series forecasting with machine learning easy and efficient. For a detailed overview, see the [User Guides](./user_guides/table-of-contents.html). --- ## Examples and tutorials -Explore our extensive list of examples and tutorials (English and Spanish) to get you started with PyIKT. You can find them [here](./examples/examples_english.html). +Explore our extensive list of examples and tutorials (English and Spanish) to get you started with ikpykit. You can find them [here](./examples/examples_english.html). --- ## How to contribute -Primarily, PyIKT development consists of adding and creating new *Forecasters*, new validation strategies, or improving the performance of the current code. However, there are many other ways to contribute: +Primarily, ikpykit development consists of adding and creating new *Forecasters*, new validation strategies, or improving the performance of the current code. However, there are many other ways to contribute: -- Submit a bug report or feature request on [GitHub Issues](https://github.com/IsolationKernel/pyikt/issues). +- Submit a bug report or feature request on [GitHub Issues](https://github.com/IsolationKernel/ikpykit/issues). - Contribute a Jupyter notebook to our [examples](./examples/examples_english.html). - Write [unit or integration tests](https://docs.pytest.org/en/latest/) for our project. - Answer questions on our issues, Stack Overflow, and elsewhere. - Translate our documentation into another language. - Write a blog post, tweet, or share our project with others. -For more information on how to contribute to pyikt, see our [Contribution Guide](./contributing/contribution.html). +For more information on how to contribute to ikpykit, see our [Contribution Guide](./contributing/contribution.html). -Visit our [authors section](./authors/authors.html) to meet all the contributors to pyikt. +Visit our [authors section](./authors/authors.html) to meet all the contributors to ikpykit. --- ## Citation -If you use pyikt for a scientific publication, we would appreciate citations to the published software. +If you use ikpykit for a scientific publication, we would appreciate citations to the published software. **BibTeX**: ``` -@software{PyIKT, +@software{IKPyKit, author = {Xin Han, Yixiao Ma, Ye Zhu, and Kaiming Ting}, -title = {PyIKT:A Python Library for Isolation Kernel Toolkit}, +title = {IKPyKit:A Python Library for Isolation Kernel Toolkit}, version = {0.1.0}, month = {3}, year = {2025}, license = {BSD-3-Clause}, -url = {https://github.com/IsolationKernel/pyikt} +url = {https://github.com/IsolationKernel/ikpykit} } ``` @@ -198,4 +196,4 @@ url = {https://github.com/IsolationKernel/pyikt} ## License -[BSD-3-Clause License](https://github.com/IsolationKernel/pyikt/blob/master/LICENSE) +[BSD-3-Clause License](https://github.com/IsolationKernel/ikpykit/blob/master/LICENSE) diff --git a/docs/api/anomaly/idkd.md b/docs/api/anomaly/idkd.md index b5ebe7b..c041d25 100644 --- a/docs/api/anomaly/idkd.md +++ b/docs/api/anomaly/idkd.md @@ -1 +1 @@ -::: pyikt.anomaly.IDKD +::: ikpykit.anomaly.IDKD diff --git a/docs/api/anomaly/iforest.md b/docs/api/anomaly/iforest.md index df79339..3a98d1c 100644 --- a/docs/api/anomaly/iforest.md +++ b/docs/api/anomaly/iforest.md @@ -1 +1 @@ -::: pyikt.anomaly.IForest +::: ikpykit.anomaly.IForest diff --git a/docs/api/anomaly/inne.md b/docs/api/anomaly/inne.md index 467bb9c..676a018 100644 --- a/docs/api/anomaly/inne.md +++ b/docs/api/anomaly/inne.md @@ -1 +1 @@ -::: pyikt.anomaly.INNE +::: ikpykit.anomaly.INNE diff --git a/docs/api/cluster/idkc.md b/docs/api/cluster/idkc.md index b004254..b074c36 100644 --- a/docs/api/cluster/idkc.md +++ b/docs/api/cluster/idkc.md @@ -1 +1 @@ -::: pyikt.cluster.IDKC +::: ikpykit.cluster.IDKC diff --git a/docs/api/cluster/ikahc.md b/docs/api/cluster/ikahc.md index 5c44e1b..ee37b21 100644 --- a/docs/api/cluster/ikahc.md +++ b/docs/api/cluster/ikahc.md @@ -1 +1 @@ -::: pyikt.cluster.IKAHC +::: ikpykit.cluster.IKAHC diff --git a/docs/api/cluster/pskc.md b/docs/api/cluster/pskc.md index 5ee8403..61f1df6 100644 --- a/docs/api/cluster/pskc.md +++ b/docs/api/cluster/pskc.md @@ -1 +1 @@ -::: pyikt.cluster.PSKC +::: ikpykit.cluster.PSKC diff --git a/docs/api/graph/IsoGraphKernel.md b/docs/api/graph/IsoGraphKernel.md index f4941f0..1680e6c 100644 --- a/docs/api/graph/IsoGraphKernel.md +++ b/docs/api/graph/IsoGraphKernel.md @@ -1 +1 @@ -::: pyikt.graph.IsoGraphKernel +::: ikpykit.graph.IsoGraphKernel diff --git a/docs/api/graph/ikgod.md b/docs/api/graph/ikgod.md index d0ccb4c..a5e2c64 100644 --- a/docs/api/graph/ikgod.md +++ b/docs/api/graph/ikgod.md @@ -1 +1 @@ -::: pyikt.graph.IKGOD +::: ikpykit.graph.IKGOD diff --git a/docs/api/group/ikgad.md b/docs/api/group/ikgad.md index 762c979..93ef321 100644 --- a/docs/api/group/ikgad.md +++ b/docs/api/group/ikgad.md @@ -1 +1 @@ -::: pyikt.group.IKGAD +::: ikpykit.group.IKGAD diff --git a/docs/api/kernel/isolation_dis_kernel.md b/docs/api/kernel/isolation_dis_kernel.md index e421fd4..a9a4809 100644 --- a/docs/api/kernel/isolation_dis_kernel.md +++ b/docs/api/kernel/isolation_dis_kernel.md @@ -1 +1 @@ -::: pyikt.kernel.IsoDisKernel +::: ikpykit.kernel.IsoDisKernel diff --git a/docs/api/kernel/isolation_kernel.md b/docs/api/kernel/isolation_kernel.md index 5ae911a..0edb0ca 100644 --- a/docs/api/kernel/isolation_kernel.md +++ b/docs/api/kernel/isolation_kernel.md @@ -1 +1 @@ -::: pyikt.kernel.IsoKernel +::: ikpykit.kernel.IsoKernel diff --git a/docs/api/stream/icid.md b/docs/api/stream/icid.md index d309e15..4271a04 100644 --- a/docs/api/stream/icid.md +++ b/docs/api/stream/icid.md @@ -1 +1 @@ -::: pyikt.stream.ICID +::: ikpykit.stream.ICID diff --git a/docs/api/stream/streakhc.md b/docs/api/stream/streakhc.md index e224183..bdb9f2d 100644 --- a/docs/api/stream/streakhc.md +++ b/docs/api/stream/streakhc.md @@ -1 +1 @@ -::: pyikt.stream.STREAMKHC +::: ikpykit.stream.STREAMKHC diff --git a/docs/api/time_series/iktod.md b/docs/api/time_series/iktod.md index 77c8a4c..ea3e5fd 100644 --- a/docs/api/time_series/iktod.md +++ b/docs/api/time_series/iktod.md @@ -1 +1 @@ -::: pyikt.timeseries.IKTOD +::: ikpykit.timeseries.IKTOD diff --git a/docs/api/trajectory/data_loader/sheep_dogs.md b/docs/api/trajectory/data_loader/sheep_dogs.md index 91eb50b..bfd92b9 100644 --- a/docs/api/trajectory/data_loader/sheep_dogs.md +++ b/docs/api/trajectory/data_loader/sheep_dogs.md @@ -1 +1 @@ -::: pyikt.trajectory.dataloader.SheepDogs +::: ikpykit.trajectory.dataloader.SheepDogs diff --git a/docs/api/trajectory/ikat.md b/docs/api/trajectory/ikat.md index c39b181..cde2a24 100644 --- a/docs/api/trajectory/ikat.md +++ b/docs/api/trajectory/ikat.md @@ -1 +1 @@ -::: pyikt.trajectory.IKAT +::: ikpykit.trajectory.IKAT diff --git a/docs/api/trajectory/tidkc.md b/docs/api/trajectory/tidkc.md index 869a6fa..1fe4ebe 100644 --- a/docs/api/trajectory/tidkc.md +++ b/docs/api/trajectory/tidkc.md @@ -1 +1 @@ -::: pyikt.trajectory.TIDKC +::: ikpykit.trajectory.TIDKC diff --git a/docs/contributing/contribution.md b/docs/contributing/contribution.md index 456f7fc..23c362d 100644 --- a/docs/contributing/contribution.md +++ b/docs/contributing/contribution.md @@ -1,15 +1,15 @@ -Contributing to PyIKT +Contributing to ikpykit ===================== -Hi! Thanks for your interest in contributing to PyIKT :D . +Hi! Thanks for your interest in contributing to ikpykit :D . In this document we'll try to summarize everything that you need to know to do a good job. Code and Issues --------------- -We use [Github](https://github.com/IsolationKernel/pyikt) to host our code repositories -and issues.You can look at [issues](https://github.com/IsolationKernel/pyikt/issues) to report any -issues related to pyikt. Here is a [guide](https://guides.github.com/features/issues/) +We use [Github](https://github.com/IsolationKernel/ikpykit) to host our code repositories +and issues.You can look at [issues](https://github.com/IsolationKernel/ikpykit/issues) to report any +issues related to ikpykit. Here is a [guide](https://guides.github.com/features/issues/) on how to report better issues. Git and our Branching model diff --git a/docs/examples/examples_english.md b/docs/examples/examples_english.md index b3d961c..b525342 100644 --- a/docs/examples/examples_english.md +++ b/docs/examples/examples_english.md @@ -2,7 +2,7 @@ # Examples and Tutorials -Practical examples and tutorials to help you understand and apply PyIKT. +Practical examples and tutorials to help you understand and apply ikpykit. Anomaly Detection diff --git a/docs/quick-start/how-to-install.md b/docs/quick-start/how-to-install.md index 604b2d2..a5f3f0b 100644 --- a/docs/quick-start/how-to-install.md +++ b/docs/quick-start/how-to-install.md @@ -1,27 +1,27 @@ # Installation Guide -This guide will help you install `pyikt`. The default installation of `pyikt` includes only the essential dependencies required for basic functionality. Additional optional dependencies can be installed for extended features. +This guide will help you install `ikpykit`. The default installation of `ikpykit` includes only the essential dependencies required for basic functionality. Additional optional dependencies can be installed for extended features. -![Python](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue) [![PyPI](https://img.shields.io/pypi/v/pyikt)](https://pypi.org/project/pyikt/) +![Python](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue) [![PyPI](https://img.shields.io/pypi/v/ikpykit)](https://pypi.org/project/ikpykit/) ## **Basic installation** -To install the basic version of `pyikt` with its core dependencies, run: +To install the basic version of `ikpykit` with its core dependencies, run: ```bash -pip install pyikt +pip install ikpykit ``` Specific version: ```bash -pip install pyikt==0.1.0 +pip install ikpykit==0.1.0 ``` Latest (unstable): ```bash -pip install git+https://github.com/pyikt/pyikt@master +pip install git+https://github.com/ikpykit/ikpykit@master ``` The following dependencies are installed with the default installation: diff --git a/docs/releases/releases.md b/docs/releases/releases.md index 92427d1..1630c98 100644 --- a/docs/releases/releases.md +++ b/docs/releases/releases.md @@ -3,8 +3,8 @@ All significant changes to this project are documented in this release file. | Legend | | -|:-----------------------------------------------------------|:--------------------------------------| +| :--------------------------------------------------------- | :------------------------------------ | | Feature | New feature | | Enhancement | Improvement in existing functionality | | API Change | Changes in the API | -| Fix | Bug fix | \ No newline at end of file +| Fix | Bug fix | diff --git a/docs/user_guides/inne.ipynb b/docs/user_guides/inne.ipynb index adb9362..ec8a9fd 100644 --- a/docs/user_guides/inne.ipynb +++ b/docs/user_guides/inne.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "\n# IsolationNNE example\n\nAn example using :class:`pyikt.anomaly.IsolationNNE` for anomaly\ndetection.\n" + "\n# IsolationNNE example\n\nAn example using :class:`ikpykit.anomaly.IsolationNNE` for anomaly\ndetection.\n" ] }, { @@ -15,7 +15,7 @@ }, "outputs": [], "source": [ - "import numpy as np\nimport matplotlib.pyplot as plt\nfrom pyikt.anomaly import IsolationNNE\n\nrng = np.random.RandomState(42)\n\n# Generate train data\nX = 0.3 * rng.randn(100, 2)\nX_train = np.r_[X + 2, X - 2]\n# Generate some regular novel observations\nX = 0.3 * rng.randn(20, 2)\nX_test = np.r_[X + 2, X - 2]\n# Generate some abnormal novel observations\nX_outliers = rng.uniform(low=-4, high=4, size=(20, 2))\n\n# fit the model\nclf = IsolationNNE()\nclf.fit(X_train)\ny_pred_train = clf.predict(X_train)\ny_pred_test = clf.predict(X_test)\ny_pred_outliers = clf.predict(X_outliers)\n\n# plot the line, the samples, and the nearest vectors to the plane\nxx, yy = np.meshgrid(np.linspace(-5, 5, 50), np.linspace(-5, 5, 50))\nZ = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])\nZ = Z.reshape(xx.shape)\n\nplt.title(\"IsolationNNE\")\nplt.contourf(xx, yy, Z, cmap=plt.cm.Blues_r)\n\nb1 = plt.scatter(X_train[:, 0], X_train[:, 1], c=\"white\", s=20, edgecolor=\"k\")\nb2 = plt.scatter(X_test[:, 0], X_test[:, 1], c=\"green\", s=20, edgecolor=\"k\")\nc = plt.scatter(X_outliers[:, 0], X_outliers[:, 1], c=\"red\", s=20, edgecolor=\"k\")\nplt.axis(\"tight\")\nplt.xlim((-5, 5))\nplt.ylim((-5, 5))\nplt.legend(\n [b1, b2, c],\n [\"training observations\", \"new regular observations\", \"new abnormal observations\"],\n loc=\"upper left\",\n)\nplt.show()" + "import numpy as np\nimport matplotlib.pyplot as plt\nfrom ikpykit.anomaly import IsolationNNE\n\nrng = np.random.RandomState(42)\n\n# Generate train data\nX = 0.3 * rng.randn(100, 2)\nX_train = np.r_[X + 2, X - 2]\n# Generate some regular novel observations\nX = 0.3 * rng.randn(20, 2)\nX_test = np.r_[X + 2, X - 2]\n# Generate some abnormal novel observations\nX_outliers = rng.uniform(low=-4, high=4, size=(20, 2))\n\n# fit the model\nclf = IsolationNNE()\nclf.fit(X_train)\ny_pred_train = clf.predict(X_train)\ny_pred_test = clf.predict(X_test)\ny_pred_outliers = clf.predict(X_outliers)\n\n# plot the line, the samples, and the nearest vectors to the plane\nxx, yy = np.meshgrid(np.linspace(-5, 5, 50), np.linspace(-5, 5, 50))\nZ = clf.decision_function(np.c_[xx.ravel(), yy.ravel()])\nZ = Z.reshape(xx.shape)\n\nplt.title(\"IsolationNNE\")\nplt.contourf(xx, yy, Z, cmap=plt.cm.Blues_r)\n\nb1 = plt.scatter(X_train[:, 0], X_train[:, 1], c=\"white\", s=20, edgecolor=\"k\")\nb2 = plt.scatter(X_test[:, 0], X_test[:, 1], c=\"green\", s=20, edgecolor=\"k\")\nc = plt.scatter(X_outliers[:, 0], X_outliers[:, 1], c=\"red\", s=20, edgecolor=\"k\")\nplt.axis(\"tight\")\nplt.xlim((-5, 5))\nplt.ylim((-5, 5))\nplt.legend(\n [b1, b2, c],\n [\"training observations\", \"new regular observations\", \"new abnormal observations\"],\n loc=\"upper left\",\n)\nplt.show()" ] } ], diff --git a/docs/user_guides/table-of-contents.md b/docs/user_guides/table-of-contents.md index 94b0ed1..78c61fa 100644 --- a/docs/user_guides/table-of-contents.md +++ b/docs/user_guides/table-of-contents.md @@ -1,9 +1,9 @@ # Table of Contents -Welcome to the PyIKT user guides! This comprehensive collection of guides is designed to help you navigate through the various features and functionalities of PyIKT. Whether you are a beginner or an advanced user, you will find the necessary resources to master data with PyIKT. Below, you will find the user guides categorized by topic for easier navigation. +Welcome to the ikpykit user guides! This comprehensive collection of guides is designed to help you navigate through the various features and functionalities of ikpykit. Whether you are a beginner or an advanced user, you will find the necessary resources to master data with ikpykit. Below, you will find the user guides categorized by topic for easier navigation. Anomaly Detection - [INNE](../user_guides/inne.html) -We hope you find these guides helpful. If you have any questions or need further assistance, please don't hesitate to reach out to the PyIKT community. +We hope you find these guides helpful. If you have any questions or need further assistance, please don't hesitate to reach out to the ikpykit community. diff --git a/examples/plot_inne.py b/examples/plot_inne.py index 4e9d306..e189d60 100644 --- a/examples/plot_inne.py +++ b/examples/plot_inne.py @@ -7,14 +7,14 @@ IsolationNNE example ========================================== -An example using :class:`pyikt.anomaly.IsolationNNE` for anomaly +An example using :class:`ikpykit.anomaly.IsolationNNE` for anomaly detection. """ import numpy as np import matplotlib.pyplot as plt -from pyikt.anomaly import INNE +from ikpykit.anomaly import INNE rng = np.random.RandomState(42) diff --git a/pyikt/__init__.py b/ikpykit/__init__.py similarity index 93% rename from pyikt/__init__.py rename to ikpykit/__init__.py index 55027d2..9c1f1a4 100644 --- a/pyikt/__init__.py +++ b/ikpykit/__init__.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/anomaly/__init__.py b/ikpykit/anomaly/__init__.py similarity index 87% rename from pyikt/anomaly/__init__.py rename to ikpykit/anomaly/__init__.py index 5cf941e..45e2bf5 100644 --- a/pyikt/anomaly/__init__.py +++ b/ikpykit/anomaly/__init__.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/anomaly/_idkd.py b/ikpykit/anomaly/_idkd.py similarity index 98% rename from pyikt/anomaly/_idkd.py rename to ikpykit/anomaly/_idkd.py index a0b0f56..856d8e2 100644 --- a/pyikt/anomaly/_idkd.py +++ b/ikpykit/anomaly/_idkd.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -17,7 +17,7 @@ from sklearn.utils.extmath import safe_sparse_dot from sklearn.utils.validation import check_is_fitted -from pyikt.kernel import IsoKernel +from ikpykit.kernel import IsoKernel class IDKD(OutlierMixin, BaseEstimator): @@ -76,7 +76,7 @@ class IDKD(OutlierMixin, BaseEstimator): Examples -------- - >>> from pyikt.anomaly import IDKD + >>> from ikpykit.anomaly import IDKD >>> import numpy as np >>> X = np.array([[-1.1, 0.2], [0.3, 0.5], [0.5, 1.1], [100, 90]]) >>> clf = IDKD(max_samples=2, contamination=0.25).fit(X) diff --git a/pyikt/anomaly/_iforest.py b/ikpykit/anomaly/_iforest.py similarity index 98% rename from pyikt/anomaly/_iforest.py rename to ikpykit/anomaly/_iforest.py index 22d9a98..7b1491d 100644 --- a/pyikt/anomaly/_iforest.py +++ b/ikpykit/anomaly/_iforest.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -93,7 +93,7 @@ class IForest(OutlierMixin, BaseEstimator): Examples -------- - >>> from pyikt.anomaly import IForest + >>> from ikpykit.anomaly import IForest >>> import numpy as np >>> X = np.array([[-1.1, 0.2], [0.3, 0.5], [0.5, 1.1], [100, 90]]) >>> clf = IForest(contamination=0.25).fit(X) diff --git a/pyikt/anomaly/_inne.py b/ikpykit/anomaly/_inne.py similarity index 99% rename from pyikt/anomaly/_inne.py rename to ikpykit/anomaly/_inne.py index 6487f90..90b386d 100644 --- a/pyikt/anomaly/_inne.py +++ b/ikpykit/anomaly/_inne.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -68,7 +68,7 @@ class INNE(OutlierMixin, BaseEstimator): Examples -------- - >>> from pyikt.anomaly import INNE + >>> from ikpykit.anomaly import INNE >>> import numpy as np >>> X = np.array([[-1.1, 0.2], [0.3, 0.5], [0.5, 1.1], [100, 90]]) >>> clf = INNE(contamination=0.25).fit(X) diff --git a/pyikt/anomaly/tests/__init__.py b/ikpykit/anomaly/tests/__init__.py similarity index 100% rename from pyikt/anomaly/tests/__init__.py rename to ikpykit/anomaly/tests/__init__.py diff --git a/pyikt/anomaly/tests/test_idkd.py b/ikpykit/anomaly/tests/test_idkd.py similarity index 98% rename from pyikt/anomaly/tests/test_idkd.py rename to ikpykit/anomaly/tests/test_idkd.py index ccd2c84..9131364 100644 --- a/pyikt/anomaly/tests/test_idkd.py +++ b/ikpykit/anomaly/tests/test_idkd.py @@ -8,7 +8,7 @@ import pytest from sklearn.datasets import load_iris -from pyikt.anomaly import IDKD +from ikpykit.anomaly import IDKD method = ["inne", "anne"] diff --git a/pyikt/anomaly/tests/test_inne.py b/ikpykit/anomaly/tests/test_inne.py similarity index 99% rename from pyikt/anomaly/tests/test_inne.py rename to ikpykit/anomaly/tests/test_inne.py index 4c7436d..f6b09e4 100644 --- a/pyikt/anomaly/tests/test_inne.py +++ b/ikpykit/anomaly/tests/test_inne.py @@ -19,7 +19,7 @@ ignore_warnings, ) -from pyikt.anomaly import INNE +from ikpykit.anomaly import INNE rng = check_random_state(0) diff --git a/pyikt/cluster/__init__.py b/ikpykit/cluster/__init__.py similarity index 100% rename from pyikt/cluster/__init__.py rename to ikpykit/cluster/__init__.py diff --git a/pyikt/cluster/_idkc.py b/ikpykit/cluster/_idkc.py similarity index 98% rename from pyikt/cluster/_idkc.py rename to ikpykit/cluster/_idkc.py index 0275ee4..4ccff69 100644 --- a/pyikt/cluster/_idkc.py +++ b/ikpykit/cluster/_idkc.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -15,7 +15,7 @@ from sklearn.utils.extmath import safe_sparse_dot from sklearn.utils.validation import check_array, check_random_state -from pyikt.kernel import IsoKernel +from ikpykit.kernel import IsoKernel from ._kcluster import KCluster @@ -88,7 +88,7 @@ class IDKC(BaseEstimator, ClusterMixin): Examples -------- - >>> from pyikt.cluster import IDKC + >>> from ikpykit.cluster import IDKC >>> import numpy as np >>> X = np.array([[1, 2], [1, 4], [5, 2], [5, 5], [1, 0], [5, 0]]) >>> clustering = IDKC( diff --git a/pyikt/cluster/_ikahc.py b/ikpykit/cluster/_ikahc.py similarity index 98% rename from pyikt/cluster/_ikahc.py rename to ikpykit/cluster/_ikahc.py index 6e68e87..91317c2 100644 --- a/pyikt/cluster/_ikahc.py +++ b/ikpykit/cluster/_ikahc.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -16,7 +16,7 @@ from sklearn.utils import check_array from sklearn.utils.validation import check_is_fitted -from pyikt.kernel import IsoKernel +from ikpykit.kernel import IsoKernel class IKAHC(BaseEstimator, ClusterMixin): @@ -80,7 +80,7 @@ class IKAHC(BaseEstimator, ClusterMixin): Examples -------- - >>> from pyikt.cluster import IKAHC + >>> from ikpykit.cluster import IKAHC >>> import numpy as np >>> X = [[0.4,0.3], [0.3,0.8], [0.5, 0.4], [0.5, 0.1]] >>> clf = IKAHC(n_estimators=200, max_samples=2, lk_method='single', n_clusters=2, return_flat=True) diff --git a/pyikt/cluster/_kcluster.py b/ikpykit/cluster/_kcluster.py similarity index 97% rename from pyikt/cluster/_kcluster.py rename to ikpykit/cluster/_kcluster.py index a48d537..d41450b 100644 --- a/pyikt/cluster/_kcluster.py +++ b/ikpykit/cluster/_kcluster.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/cluster/_pskc.py b/ikpykit/cluster/_pskc.py similarity index 97% rename from pyikt/cluster/_pskc.py rename to ikpykit/cluster/_pskc.py index 9182b0b..c43c988 100644 --- a/pyikt/cluster/_pskc.py +++ b/ikpykit/cluster/_pskc.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -14,8 +14,8 @@ from sklearn.utils.extmath import safe_sparse_dot from sklearn.utils.validation import check_is_fitted -from pyikt.cluster._kcluster import KCluster -from pyikt.kernel import IsoKernel +from ikpykit.cluster._kcluster import KCluster +from ikpykit.kernel import IsoKernel class PSKC(BaseEstimator, ClusterMixin): @@ -68,7 +68,7 @@ class PSKC(BaseEstimator, ClusterMixin): Examples -------- - >>> from pyikt.cluster import PSKC + >>> from ikpykit.cluster import PSKC >>> import numpy as np >>> X = np.array([[1, 2], [1, 4], [10, 2], [10, 10], [1, 0], [1, 1]]) >>> pskc = PSKC(n_estimators=100, max_samples=2, tau=0.3, v=0.1, random_state=24) diff --git a/pyikt/cluster/_utils.py b/ikpykit/cluster/_utils.py similarity index 96% rename from pyikt/cluster/_utils.py rename to ikpykit/cluster/_utils.py index 95cb052..b8240ac 100644 --- a/pyikt/cluster/_utils.py +++ b/ikpykit/cluster/_utils.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/cluster/tests/__init__.py b/ikpykit/cluster/tests/__init__.py similarity index 100% rename from pyikt/cluster/tests/__init__.py rename to ikpykit/cluster/tests/__init__.py diff --git a/pyikt/cluster/tests/test_idkc.py b/ikpykit/cluster/tests/test_idkc.py similarity index 95% rename from pyikt/cluster/tests/test_idkc.py rename to ikpykit/cluster/tests/test_idkc.py index e8f61c8..2a186cb 100644 --- a/pyikt/cluster/tests/test_idkc.py +++ b/ikpykit/cluster/tests/test_idkc.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -12,7 +12,7 @@ from sklearn import metrics from sklearn.datasets import make_blobs -from pyikt.cluster import IDKC +from ikpykit.cluster import IDKC def test_IDKC(): diff --git a/pyikt/cluster/tests/test_ikahc.py b/ikpykit/cluster/tests/test_ikahc.py similarity index 98% rename from pyikt/cluster/tests/test_ikahc.py rename to ikpykit/cluster/tests/test_ikahc.py index 64175c4..4ae2f67 100644 --- a/pyikt/cluster/tests/test_ikahc.py +++ b/ikpykit/cluster/tests/test_ikahc.py @@ -1,6 +1,6 @@ -"""pyikt (c) by Xin Han +"""ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -10,7 +10,7 @@ import numpy as np import pytest -from pyikt.cluster import IKAHC +from ikpykit.cluster import IKAHC def test_ikahc_initialization(): diff --git a/pyikt/cluster/tests/test_pskc.py b/ikpykit/cluster/tests/test_pskc.py similarity index 99% rename from pyikt/cluster/tests/test_pskc.py rename to ikpykit/cluster/tests/test_pskc.py index 8104099..c9c6047 100644 --- a/pyikt/cluster/tests/test_pskc.py +++ b/ikpykit/cluster/tests/test_pskc.py @@ -8,7 +8,7 @@ import pytest from sklearn.datasets import make_blobs -from pyikt.cluster import PSKC +from ikpykit.cluster import PSKC @pytest.fixture diff --git a/pyikt/graph/__init__.py b/ikpykit/graph/__init__.py similarity index 87% rename from pyikt/graph/__init__.py rename to ikpykit/graph/__init__.py index 6f91a99..6763ea6 100644 --- a/pyikt/graph/__init__.py +++ b/ikpykit/graph/__init__.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/graph/_ikgod.py b/ikpykit/graph/_ikgod.py similarity index 98% rename from pyikt/graph/_ikgod.py rename to ikpykit/graph/_ikgod.py index 98b4dda..9a1b5d1 100644 --- a/pyikt/graph/_ikgod.py +++ b/ikpykit/graph/_ikgod.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -19,8 +19,8 @@ from sklearn.utils.extmath import safe_sparse_dot from sklearn.utils.validation import check_is_fitted -from pyikt.graph.utils import check_format, get_degrees, get_neighbors -from pyikt.kernel import IsoKernel +from ikpykit.graph.utils import check_format, get_degrees, get_neighbors +from ikpykit.kernel import IsoKernel class IKGOD(BaseEstimator): @@ -76,7 +76,7 @@ class IKGOD(BaseEstimator): Examples -------- - >>> from pyikt.graph import IKGOD + >>> from ikpykit.graph import IKGOD >>> import scipy.sparse as sp >>> import numpy as np >>> # Create adjacency matrix and features diff --git a/pyikt/graph/_isographkernel.py b/ikpykit/graph/_isographkernel.py similarity index 97% rename from pyikt/graph/_isographkernel.py rename to ikpykit/graph/_isographkernel.py index 293dda0..4aef9a6 100644 --- a/pyikt/graph/_isographkernel.py +++ b/ikpykit/graph/_isographkernel.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -19,8 +19,8 @@ from sklearn.utils.extmath import safe_sparse_dot from sklearn.utils.validation import check_is_fitted -from pyikt.graph.utils import check_format, get_degrees, get_neighbors -from pyikt.kernel import IsoKernel +from ikpykit.graph.utils import check_format, get_degrees, get_neighbors +from ikpykit.kernel import IsoKernel class IsoGraphKernel(BaseEstimator): @@ -59,7 +59,7 @@ class IsoGraphKernel(BaseEstimator): Examples -------- - >>> from pyikt.graph import IsoGraphKernel + >>> from ikpykit.graph import IsoGraphKernel >>> import numpy as np >>> X = np.array([[0.4, 0.3], [0.3, 0.8], [0.5, 0.4], [0.5, 0.1]]) >>> adjacency = np.array([[0, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 0]]) diff --git a/pyikt/graph/tests/test_ikgod.py b/ikpykit/graph/tests/test_ikgod.py similarity index 99% rename from pyikt/graph/tests/test_ikgod.py rename to ikpykit/graph/tests/test_ikgod.py index e38f938..952573e 100644 --- a/pyikt/graph/tests/test_ikgod.py +++ b/ikpykit/graph/tests/test_ikgod.py @@ -3,7 +3,7 @@ import scipy.sparse as sp from sklearn.datasets import make_blobs -from pyikt.graph import IKGOD +from ikpykit.graph import IKGOD def test_ikgod_initialization(): diff --git a/pyikt/graph/tests/test_isographkernel.py b/ikpykit/graph/tests/test_isographkernel.py similarity index 98% rename from pyikt/graph/tests/test_isographkernel.py rename to ikpykit/graph/tests/test_isographkernel.py index 77cc162..ce114ae 100644 --- a/pyikt/graph/tests/test_isographkernel.py +++ b/ikpykit/graph/tests/test_isographkernel.py @@ -1,7 +1,7 @@ import numpy as np import scipy.sparse as sp -from pyikt.graph import IsoGraphKernel +from ikpykit.graph import IsoGraphKernel def test_isographkernel_initialization(): diff --git a/pyikt/graph/utils.py b/ikpykit/graph/utils.py similarity index 98% rename from pyikt/graph/utils.py rename to ikpykit/graph/utils.py index 59ec0f9..cb4c3d8 100644 --- a/pyikt/graph/utils.py +++ b/ikpykit/graph/utils.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/group/__init__.py b/ikpykit/group/__init__.py similarity index 85% rename from pyikt/group/__init__.py rename to ikpykit/group/__init__.py index e4635d8..ff66604 100644 --- a/pyikt/group/__init__.py +++ b/ikpykit/group/__init__.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/group/anomaly/__init__.py b/ikpykit/group/anomaly/__init__.py similarity index 100% rename from pyikt/group/anomaly/__init__.py rename to ikpykit/group/anomaly/__init__.py diff --git a/pyikt/group/anomaly/_ikgad.py b/ikpykit/group/anomaly/_ikgad.py similarity index 98% rename from pyikt/group/anomaly/_ikgad.py rename to ikpykit/group/anomaly/_ikgad.py index 24ac279..61ca665 100644 --- a/pyikt/group/anomaly/_ikgad.py +++ b/ikpykit/group/anomaly/_ikgad.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -13,8 +13,8 @@ from sklearn.utils.extmath import safe_sparse_dot from sklearn.utils.validation import check_is_fitted -from pyikt.group.utils import check_format -from pyikt.kernel import IsoKernel +from ikpykit.group.utils import check_format +from ikpykit.kernel import IsoKernel class IKGAD(OutlierMixin, BaseEstimator): @@ -76,7 +76,7 @@ class IKGAD(OutlierMixin, BaseEstimator): Examples -------- - >>> from pyikt.group import IKGAD + >>> from ikpykit.group import IKGAD >>> import numpy as np >>> X =[[[1.0, 1.1], [1.2, 1.3]], [[1.3, 1.2], [1.1, 1.0]], [[1.0, 1.2], [1.4, 1.3]], [[5.0, 5.1], [5.2, 5.3]]] >>> clf = IKGAD(max_samples_1=2, max_samples_2=2, contamination=0.25, random_state=42) diff --git a/pyikt/group/tests/test_Ikgad.py b/ikpykit/group/tests/test_Ikgad.py similarity index 97% rename from pyikt/group/tests/test_Ikgad.py rename to ikpykit/group/tests/test_Ikgad.py index 9a49c3f..faec846 100644 --- a/pyikt/group/tests/test_Ikgad.py +++ b/ikpykit/group/tests/test_Ikgad.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -11,7 +11,7 @@ import numpy as np import pytest -from pyikt.group import IKGAD +from ikpykit.group import IKGAD def test_IKGAD_initialization(): diff --git a/pyikt/group/utils.py b/ikpykit/group/utils.py similarity index 97% rename from pyikt/group/utils.py rename to ikpykit/group/utils.py index a6592d2..bd7bf7c 100644 --- a/pyikt/group/utils.py +++ b/ikpykit/group/utils.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/kernel/__init__.py b/ikpykit/kernel/__init__.py similarity index 87% rename from pyikt/kernel/__init__.py rename to ikpykit/kernel/__init__.py index 4757639..3d6cb40 100644 --- a/pyikt/kernel/__init__.py +++ b/ikpykit/kernel/__init__.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/kernel/_ik_anne.py b/ikpykit/kernel/_ik_anne.py similarity index 99% rename from pyikt/kernel/_ik_anne.py rename to ikpykit/kernel/_ik_anne.py index e281b10..d331065 100644 --- a/pyikt/kernel/_ik_anne.py +++ b/ikpykit/kernel/_ik_anne.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/kernel/_ik_iforest.py b/ikpykit/kernel/_ik_iforest.py similarity index 97% rename from pyikt/kernel/_ik_iforest.py rename to ikpykit/kernel/_ik_iforest.py index 8f5b8e1..462c3d6 100644 --- a/pyikt/kernel/_ik_iforest.py +++ b/ikpykit/kernel/_ik_iforest.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/kernel/_ik_inne.py b/ikpykit/kernel/_ik_inne.py similarity index 99% rename from pyikt/kernel/_ik_inne.py rename to ikpykit/kernel/_ik_inne.py index 57d6209..135dd36 100644 --- a/pyikt/kernel/_ik_inne.py +++ b/ikpykit/kernel/_ik_inne.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/kernel/_isodiskernel.py b/ikpykit/kernel/_isodiskernel.py similarity index 97% rename from pyikt/kernel/_isodiskernel.py rename to ikpykit/kernel/_isodiskernel.py index c01f782..33c64fd 100644 --- a/pyikt/kernel/_isodiskernel.py +++ b/ikpykit/kernel/_isodiskernel.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -16,7 +16,7 @@ from sklearn.utils import check_array from sklearn.utils.validation import check_is_fitted -from pyikt.kernel import IsoKernel +from ikpykit.kernel import IsoKernel class IsoDisKernel(BaseEstimator, TransformerMixin): @@ -57,7 +57,7 @@ class IsoDisKernel(BaseEstimator, TransformerMixin): Examples -------- - >>> from pyikt.kernel import IsoDisKernel + >>> from ikpykit.kernel import IsoDisKernel >>> import numpy as np >>> X = [[0.4,0.3], [0.3,0.8], [0.5,0.4], [0.5,0.1]] >>> idk = IsoDisKernel(max_samples=3,).fit(X) diff --git a/pyikt/kernel/_isokernel.py b/ikpykit/kernel/_isokernel.py similarity index 96% rename from pyikt/kernel/_isokernel.py rename to ikpykit/kernel/_isokernel.py index 5d05b74..74e4d2c 100644 --- a/pyikt/kernel/_isokernel.py +++ b/ikpykit/kernel/_isokernel.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -17,9 +17,9 @@ from sklearn.utils.extmath import safe_sparse_dot from sklearn.utils.validation import check_is_fitted -from pyikt.kernel._ik_anne import IK_ANNE -from pyikt.kernel._ik_iforest import IK_IForest -from pyikt.kernel._ik_inne import IK_INNE +from ikpykit.kernel._ik_anne import IK_ANNE +from ikpykit.kernel._ik_iforest import IK_IForest +from ikpykit.kernel._ik_inne import IK_INNE class IsoKernel(TransformerMixin, BaseEstimator): @@ -64,7 +64,7 @@ class IsoKernel(TransformerMixin, BaseEstimator): Examples -------- - >>> from pyikt.kernel import IsoKernel + >>> from ikpykit.kernel import IsoKernel >>> import numpy as np >>> X = [[0.4,0.3], [0.3,0.8], [0.5, 0.4], [0.5, 0.1]] >>> ik = IsoKernel().fit(X) diff --git a/pyikt/kernel/tests/__init__.py b/ikpykit/kernel/tests/__init__.py similarity index 100% rename from pyikt/kernel/tests/__init__.py rename to ikpykit/kernel/tests/__init__.py diff --git a/pyikt/kernel/tests/test_isodiskernel.py b/ikpykit/kernel/tests/test_isodiskernel.py similarity index 96% rename from pyikt/kernel/tests/test_isodiskernel.py rename to ikpykit/kernel/tests/test_isodiskernel.py index 74f371a..3c62664 100644 --- a/pyikt/kernel/tests/test_isodiskernel.py +++ b/ikpykit/kernel/tests/test_isodiskernel.py @@ -7,7 +7,7 @@ import pytest from sklearn.datasets import load_iris -from pyikt.kernel import IsoDisKernel +from ikpykit.kernel import IsoDisKernel method = ["inne", "anne"] diff --git a/pyikt/kernel/tests/test_isokernel.py b/ikpykit/kernel/tests/test_isokernel.py similarity index 97% rename from pyikt/kernel/tests/test_isokernel.py rename to ikpykit/kernel/tests/test_isokernel.py index 6fd858d..8df0a1b 100644 --- a/pyikt/kernel/tests/test_isokernel.py +++ b/ikpykit/kernel/tests/test_isokernel.py @@ -7,7 +7,7 @@ import pytest from sklearn.datasets import load_iris -from pyikt import IsoKernel +from ikpykit import IsoKernel method = ["inne", "anne"] diff --git a/pyikt/stream/__init__.py b/ikpykit/stream/__init__.py similarity index 88% rename from pyikt/stream/__init__.py rename to ikpykit/stream/__init__.py index f8f4122..dc31ff4 100644 --- a/pyikt/stream/__init__.py +++ b/ikpykit/stream/__init__.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/stream/changedetect/__init__.py b/ikpykit/stream/changedetect/__init__.py similarity index 100% rename from pyikt/stream/changedetect/__init__.py rename to ikpykit/stream/changedetect/__init__.py diff --git a/pyikt/stream/changedetect/_icid.py b/ikpykit/stream/changedetect/_icid.py similarity index 98% rename from pyikt/stream/changedetect/_icid.py rename to ikpykit/stream/changedetect/_icid.py index 5b3de24..4074a89 100644 --- a/pyikt/stream/changedetect/_icid.py +++ b/ikpykit/stream/changedetect/_icid.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -14,7 +14,7 @@ from sklearn.utils import check_array from sklearn.utils.validation import check_is_fitted -from pyikt.kernel import IsoDisKernel +from ikpykit.kernel import IsoDisKernel class ICID(BaseEstimator): @@ -87,7 +87,7 @@ class ICID(BaseEstimator): Examples -------- - >>> from pyikt.stream import ICID + >>> from ikpykit.stream import ICID >>> import numpy as np >>> np.random.seed(42) >>> X_normal1 = np.random.randn(50, 2) diff --git a/pyikt/stream/cluster/__init__.py b/ikpykit/stream/cluster/__init__.py similarity index 100% rename from pyikt/stream/cluster/__init__.py rename to ikpykit/stream/cluster/__init__.py diff --git a/pyikt/stream/cluster/_inode.py b/ikpykit/stream/cluster/_inode.py similarity index 99% rename from pyikt/stream/cluster/_inode.py rename to ikpykit/stream/cluster/_inode.py index 482e649..c75c816 100644 --- a/pyikt/stream/cluster/_inode.py +++ b/ikpykit/stream/cluster/_inode.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/stream/cluster/_streakhc.py b/ikpykit/stream/cluster/_streakhc.py similarity index 98% rename from pyikt/stream/cluster/_streakhc.py rename to ikpykit/stream/cluster/_streakhc.py index d110c3d..6b2aa19 100644 --- a/pyikt/stream/cluster/_streakhc.py +++ b/ikpykit/stream/cluster/_streakhc.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -16,7 +16,7 @@ from sklearn.base import BaseEstimator, ClusterMixin from sklearn.utils.validation import check_array, check_is_fitted, check_X_y -from pyikt.kernel import IsoKernel +from ikpykit.kernel import IsoKernel from ._inode import INODE from .utils.dendrogram_purity import dendrogram_purity @@ -68,7 +68,7 @@ class STREAMKHC(BaseEstimator, ClusterMixin): Examples -------- - >>> from pyikt.stream import STREAMKHC + >>> from ikpykit.stream import STREAMKHC >>> import numpy as np >>> # Generate sample data >>> X = np.random.rand(100, 10) # 100 samples with 10 features diff --git a/pyikt/stream/cluster/utils/Graphviz.py b/ikpykit/stream/cluster/utils/Graphviz.py similarity index 100% rename from pyikt/stream/cluster/utils/Graphviz.py rename to ikpykit/stream/cluster/utils/Graphviz.py diff --git a/pyikt/stream/cluster/utils/__init__.py b/ikpykit/stream/cluster/utils/__init__.py similarity index 100% rename from pyikt/stream/cluster/utils/__init__.py rename to ikpykit/stream/cluster/utils/__init__.py diff --git a/pyikt/stream/cluster/utils/deltasep_utils.py b/ikpykit/stream/cluster/utils/deltasep_utils.py similarity index 100% rename from pyikt/stream/cluster/utils/deltasep_utils.py rename to ikpykit/stream/cluster/utils/deltasep_utils.py diff --git a/pyikt/stream/cluster/utils/dendrogram_purity.py b/ikpykit/stream/cluster/utils/dendrogram_purity.py similarity index 100% rename from pyikt/stream/cluster/utils/dendrogram_purity.py rename to ikpykit/stream/cluster/utils/dendrogram_purity.py diff --git a/pyikt/stream/cluster/utils/dendrogram_purity_pool.py b/ikpykit/stream/cluster/utils/dendrogram_purity_pool.py similarity index 100% rename from pyikt/stream/cluster/utils/dendrogram_purity_pool.py rename to ikpykit/stream/cluster/utils/dendrogram_purity_pool.py diff --git a/pyikt/stream/cluster/utils/file_utils.py b/ikpykit/stream/cluster/utils/file_utils.py similarity index 100% rename from pyikt/stream/cluster/utils/file_utils.py rename to ikpykit/stream/cluster/utils/file_utils.py diff --git a/pyikt/stream/cluster/utils/logger.py b/ikpykit/stream/cluster/utils/logger.py similarity index 100% rename from pyikt/stream/cluster/utils/logger.py rename to ikpykit/stream/cluster/utils/logger.py diff --git a/pyikt/stream/cluster/utils/serialize_trees.py b/ikpykit/stream/cluster/utils/serialize_trees.py similarity index 100% rename from pyikt/stream/cluster/utils/serialize_trees.py rename to ikpykit/stream/cluster/utils/serialize_trees.py diff --git a/pyikt/stream/tests/test_icid.py b/ikpykit/stream/tests/test_icid.py similarity index 99% rename from pyikt/stream/tests/test_icid.py rename to ikpykit/stream/tests/test_icid.py index d5285dd..6b573e4 100644 --- a/pyikt/stream/tests/test_icid.py +++ b/ikpykit/stream/tests/test_icid.py @@ -6,7 +6,7 @@ import pytest from sklearn.utils import check_random_state -from pyikt.stream import ICID +from ikpykit.stream import ICID rng = check_random_state(42) diff --git a/pyikt/stream/tests/test_streakhc.py b/ikpykit/stream/tests/test_streakhc.py similarity index 99% rename from pyikt/stream/tests/test_streakhc.py rename to ikpykit/stream/tests/test_streakhc.py index 73826db..fb98c87 100644 --- a/pyikt/stream/tests/test_streakhc.py +++ b/ikpykit/stream/tests/test_streakhc.py @@ -1,7 +1,7 @@ import numpy as np import pytest -from pyikt.stream import STREAMKHC +from ikpykit.stream import STREAMKHC def test_streamkhc_init(): diff --git a/pyikt/timeseries/__init__.py b/ikpykit/timeseries/__init__.py similarity index 85% rename from pyikt/timeseries/__init__.py rename to ikpykit/timeseries/__init__.py index dfd081e..5df0c28 100644 --- a/pyikt/timeseries/__init__.py +++ b/ikpykit/timeseries/__init__.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/timeseries/anomaly/__init__.py b/ikpykit/timeseries/anomaly/__init__.py similarity index 100% rename from pyikt/timeseries/anomaly/__init__.py rename to ikpykit/timeseries/anomaly/__init__.py diff --git a/pyikt/timeseries/anomaly/_iktod.py b/ikpykit/timeseries/anomaly/_iktod.py similarity index 98% rename from pyikt/timeseries/anomaly/_iktod.py rename to ikpykit/timeseries/anomaly/_iktod.py index 737f12e..f6c8170 100644 --- a/pyikt/timeseries/anomaly/_iktod.py +++ b/ikpykit/timeseries/anomaly/_iktod.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -15,7 +15,7 @@ from sklearn.base import BaseEstimator, OutlierMixin from sklearn.utils.validation import check_array, check_is_fitted -from pyikt.group import IKGAD +from ikpykit.group import IKGAD class IKTOD(OutlierMixin, BaseEstimator): @@ -85,7 +85,7 @@ class IKTOD(OutlierMixin, BaseEstimator): Examples -------- - >>> from pyikt.timeseries import IKTOD + >>> from ikpykit.timeseries import IKTOD >>> import numpy as np >>> # Time series with length 40 (4 periods of length 10) >>> X = np.sin(np.linspace(0, 8*np.pi, 40)).reshape(-1, 1) diff --git a/pyikt/timeseries/tests/test_iktod.py b/ikpykit/timeseries/tests/test_iktod.py similarity index 98% rename from pyikt/timeseries/tests/test_iktod.py rename to ikpykit/timeseries/tests/test_iktod.py index e86afe1..3c1dae8 100644 --- a/pyikt/timeseries/tests/test_iktod.py +++ b/ikpykit/timeseries/tests/test_iktod.py @@ -1,7 +1,7 @@ import numpy as np import pytest -from pyikt.timeseries import IKTOD +from ikpykit.timeseries import IKTOD def test_iktod_fit_and_predict(): diff --git a/pyikt/trajectory/__init__.py b/ikpykit/trajectory/__init__.py similarity index 86% rename from pyikt/trajectory/__init__.py rename to ikpykit/trajectory/__init__.py index f5ad3ad..b6c3ef4 100644 --- a/pyikt/trajectory/__init__.py +++ b/ikpykit/trajectory/__init__.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/pyikt/trajectory/anomaly/__init__.py b/ikpykit/trajectory/anomaly/__init__.py similarity index 100% rename from pyikt/trajectory/anomaly/__init__.py rename to ikpykit/trajectory/anomaly/__init__.py diff --git a/pyikt/trajectory/anomaly/_ikat.py b/ikpykit/trajectory/anomaly/_ikat.py similarity index 97% rename from pyikt/trajectory/anomaly/_ikat.py rename to ikpykit/trajectory/anomaly/_ikat.py index d985a2d..f785f19 100644 --- a/pyikt/trajectory/anomaly/_ikat.py +++ b/ikpykit/trajectory/anomaly/_ikat.py @@ -4,8 +4,8 @@ from sklearn.base import BaseEstimator, OutlierMixin from sklearn.utils.validation import check_is_fitted -from pyikt.group import IKGAD -from pyikt.group.utils import check_format +from ikpykit.group import IKGAD +from ikpykit.group.utils import check_format class IKAT(OutlierMixin, BaseEstimator): @@ -67,8 +67,8 @@ class IKAT(OutlierMixin, BaseEstimator): Examples -------- - >>> from pyikt.trajectory import IKAT - >>> from pyikt.trajectory.dataloader import SheepDogs + >>> from ikpykit.trajectory import IKAT + >>> from ikpykit.trajectory.dataloader import SheepDogs >>> sheepdogs = SheepDogs() >>> X, y = sheepdogs.load(return_X_y=True) >>> clf = IKAT().fit(X) diff --git a/pyikt/trajectory/cluster/__init__.py b/ikpykit/trajectory/cluster/__init__.py similarity index 100% rename from pyikt/trajectory/cluster/__init__.py rename to ikpykit/trajectory/cluster/__init__.py diff --git a/pyikt/trajectory/cluster/_tidkc.py b/ikpykit/trajectory/cluster/_tidkc.py similarity index 96% rename from pyikt/trajectory/cluster/_tidkc.py rename to ikpykit/trajectory/cluster/_tidkc.py index 0bcad13..cfca118 100644 --- a/pyikt/trajectory/cluster/_tidkc.py +++ b/ikpykit/trajectory/cluster/_tidkc.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this @@ -13,9 +13,9 @@ import numpy as np from sklearn.base import BaseEstimator, ClusterMixin -from pyikt.cluster import IDKC -from pyikt.group.utils import check_format -from pyikt.kernel import IsoKernel +from ikpykit.cluster import IDKC +from ikpykit.group.utils import check_format +from ikpykit.kernel import IsoKernel class TIDKC(BaseEstimator, ClusterMixin): @@ -85,8 +85,8 @@ class TIDKC(BaseEstimator, ClusterMixin): Examples -------- - >>> from pyikt.trajectory import TIDKC - >>> from pyikt.trajectory.dataloader import SheepDogs + >>> from ikpykit.trajectory import TIDKC + >>> from ikpykit.trajectory.dataloader import SheepDogs >>> sheepdogs = SheepDogs() >>> X, y = sheepdogs.load(return_X_y=True) >>> clf = TIDKC(k=2, kn=5, v=0.5, n_init_samples=10).fit(X) diff --git a/pyikt/trajectory/dataloader/__init__.py b/ikpykit/trajectory/dataloader/__init__.py similarity index 100% rename from pyikt/trajectory/dataloader/__init__.py rename to ikpykit/trajectory/dataloader/__init__.py diff --git a/pyikt/trajectory/dataloader/_sheepdogs.py b/ikpykit/trajectory/dataloader/_sheepdogs.py similarity index 98% rename from pyikt/trajectory/dataloader/_sheepdogs.py rename to ikpykit/trajectory/dataloader/_sheepdogs.py index 3e1dd44..d9c0b4c 100644 --- a/pyikt/trajectory/dataloader/_sheepdogs.py +++ b/ikpykit/trajectory/dataloader/_sheepdogs.py @@ -35,7 +35,7 @@ class SheepDogs(FileDataset): Examples -------- - >>> from pyikt.trajectory.dataloader import SheepDogs + >>> from ikpykit.trajectory.dataloader import SheepDogs >>> sheepdogs = SheepDogs() >>> X, y = sheepdogs.load(return_X_y=True) """ diff --git a/pyikt/trajectory/dataloader/base.py b/ikpykit/trajectory/dataloader/base.py similarity index 100% rename from pyikt/trajectory/dataloader/base.py rename to ikpykit/trajectory/dataloader/base.py diff --git a/pyikt/trajectory/dataloader/datasets/flyingfox.zip b/ikpykit/trajectory/dataloader/datasets/flyingfox.zip similarity index 100% rename from pyikt/trajectory/dataloader/datasets/flyingfox.zip rename to ikpykit/trajectory/dataloader/datasets/flyingfox.zip diff --git a/pyikt/trajectory/dataloader/datasets/sheepdogs.zip b/ikpykit/trajectory/dataloader/datasets/sheepdogs.zip similarity index 100% rename from pyikt/trajectory/dataloader/datasets/sheepdogs.zip rename to ikpykit/trajectory/dataloader/datasets/sheepdogs.zip diff --git a/pyikt/trajectory/dataloader/datasets/turkey.zip b/ikpykit/trajectory/dataloader/datasets/turkey.zip similarity index 100% rename from pyikt/trajectory/dataloader/datasets/turkey.zip rename to ikpykit/trajectory/dataloader/datasets/turkey.zip diff --git a/pyikt/trajectory/dataloader/datasets/wildebeest.zip b/ikpykit/trajectory/dataloader/datasets/wildebeest.zip similarity index 100% rename from pyikt/trajectory/dataloader/datasets/wildebeest.zip rename to ikpykit/trajectory/dataloader/datasets/wildebeest.zip diff --git a/pyikt/trajectory/tests/test_ikat.py b/ikpykit/trajectory/tests/test_ikat.py similarity index 99% rename from pyikt/trajectory/tests/test_ikat.py rename to ikpykit/trajectory/tests/test_ikat.py index d02f8b3..e446e49 100644 --- a/pyikt/trajectory/tests/test_ikat.py +++ b/ikpykit/trajectory/tests/test_ikat.py @@ -7,7 +7,7 @@ import numpy as np import pytest -from pyikt.trajectory import IKAT +from ikpykit.trajectory import IKAT @pytest.fixture diff --git a/pyikt/trajectory/tests/test_tidkc.py b/ikpykit/trajectory/tests/test_tidkc.py similarity index 98% rename from pyikt/trajectory/tests/test_tidkc.py rename to ikpykit/trajectory/tests/test_tidkc.py index 110e91c..ca55853 100644 --- a/pyikt/trajectory/tests/test_tidkc.py +++ b/ikpykit/trajectory/tests/test_tidkc.py @@ -1,7 +1,7 @@ import numpy as np import pytest -from pyikt.trajectory import TIDKC +from ikpykit.trajectory import TIDKC def test_tidkc_initialization(): diff --git a/pyikt/trajectory/utils.py b/ikpykit/trajectory/utils.py similarity index 98% rename from pyikt/trajectory/utils.py rename to ikpykit/trajectory/utils.py index e46e776..7986e12 100644 --- a/pyikt/trajectory/utils.py +++ b/ikpykit/trajectory/utils.py @@ -1,7 +1,7 @@ """ -pyikt (c) by Xin Han +ikpykit (c) by Xin Han -pyikt is licensed under a +ikpykit is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. You should have received a copy of the license along with this diff --git a/mkdocs.yml b/mkdocs.yml index 9ded03d..5d821ba 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,8 +1,8 @@ -site_name: PyIKT Docs +site_name: IKPyKit Docs extra_css: - stylesheets/extra.css -repo_url: https://github.com/IsolationKernel/pyikt -site_url: https://isolationkernel.github.io/pyikt +repo_url: https://github.com/IsolationKernel/ikpykit +site_url: https://isolationkernel.github.io/ikpykit remote_branch: docs_dev site_description: Python library for Isolation Kernel Toolkit. site_author: Isolation Kernel Team @@ -11,7 +11,7 @@ copyright: Copyright © 2024 - 2025 Xin Han nav: - Home: - - Welcome to PyIKT: README.md + - Welcome to IKPyKit: README.md - Quick start: - How to install: quick-start/how-to-install.md @@ -186,5 +186,5 @@ extra: make our documentation better. seo: description: >- - **PyIKT** (Python for Isolation Kernel Similarity) is an intuitive Python library designed for a variety of machine learning tasks including kernel similarity calculation, anomaly detection, clustering, and change detection—all powered by the innovative **Isolation Kernel (IK)** . Isolation Kernel is a data-dependent kernel that measures similarity by isolating data points using an isolation mechanism. It uniquely adapts to the data distribution, with the property that points in sparse regions are more similar than those in dense regions. Notably, it requires no learning or closed-form expression, making it efficient and scalable. + **IKPyKit** (Isolation Kernel Python toolKit) is an intuitive Python library designed for a variety of machine learning tasks including kernel similarity calculation, anomaly detection, clustering, and change detection—all powered by the innovative **Isolation Kernel (IK)** . Isolation Kernel is a data-dependent kernel that measures similarity by isolating data points using an isolation mechanism. It uniquely adapts to the data distribution, with the property that points in sparse regions are more similar than those in dense regions. Notably, it requires no learning or closed-form expression, making it efficient and scalable. keywords: time series, forecasting, machine learning, python, data science, scikit-learn, anomaly detection, clustering, change detection, kernel similarity, isolation kernel diff --git a/pixi.lock b/pixi.lock index d8afd03..6f38826 100644 --- a/pixi.lock +++ b/pixi.lock @@ -3231,6 +3231,18 @@ packages: - pkg:pypi/idna?source=hash-mapping size: 49765 timestamp: 1733211921194 +- pypi: . + name: ikpykit + version: 0.1.dev153 + sha256: 37164a92bdfea39a6e2109de81c87eb271e74e23200be8f715fa0a4a0da87ebd + requires_dist: + - scikit-learn>=1.2 + - pandas>=1.5 + - numpy<=1.22 + - numba>=0.54 + - tqdm>=4.62.3 + requires_python: '>=3.9' + editable: true - conda: https://conda.anaconda.org/conda-forge/noarch/importlib-metadata-8.6.1-pyha770c72_0.conda sha256: 598951ebdb23e25e4cec4bbff0ae369cec65ead80b50bc08b441d8e54de5cf03 md5: f4b39bf00c69f56ac01e020ebfac066c @@ -6722,18 +6734,6 @@ packages: - pkg:pypi/pygments?source=hash-mapping size: 888600 timestamp: 1736243563082 -- pypi: . - name: pyikt - version: 0.1.dev152 - sha256: 5e1c3b02e49953855bd5f62b3a8d6030e408650884d22024a42dc9e769c52464 - requires_dist: - - scikit-learn>=1.2 - - pandas>=1.5 - - numpy<=1.22 - - numba>=0.54 - - tqdm>=4.62.3 - requires_python: '>=3.9' - editable: true - conda: https://conda.anaconda.org/conda-forge/noarch/pymdown-extensions-10.14.3-pyhd8ed1ab_0.conda sha256: 83b638059eda5208e2e4acfeecf2ff53b5dcb1adc7d85fc92edf0e7a48b943eb md5: 08bf3657d03e1ee964c66288f5b3d797 @@ -7510,8 +7510,6 @@ packages: - python_abi 3.10.* *_cp310 constrains: - __glibc >=2.17 - arch: x86_64 - platform: linux license: MIT license_family: MIT purls: @@ -7528,8 +7526,6 @@ packages: - python_abi 3.10.* *_cp310 constrains: - __osx >=10.13 - arch: x86_64 - platform: osx license: MIT license_family: MIT purls: @@ -7547,8 +7543,6 @@ packages: - python_abi 3.10.* *_cp310 constrains: - __osx >=11.0 - arch: arm64 - platform: osx license: MIT license_family: MIT purls: @@ -7564,8 +7558,6 @@ packages: - ucrt >=10.0.20348.0 - vc >=14.2,<15 - vc14_runtime >=14.29.30139 - arch: x86_64 - platform: win license: MIT license_family: MIT purls: diff --git a/pyproject.toml b/pyproject.toml index 6982ae2..24563b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "pyikt" +name = "ikpykit" dynamic = ["version"] description = "Isolation Kernel Toolkit in Python." @@ -47,10 +47,10 @@ dependencies = [ requires-python = ">=3.9" [project.urls] -Homepage = "https://isolationkernel.github.io/pyikt/" -Repository = "https://github.com/IsolationKernel/pyikt" -Documentation = "https://isolationkernel.github.io/pyikt/" -"Release Notes" = "https://isolationkernel.github.io/pyikt/latest/releases/releases" +Homepage = "https://isolationkernel.github.io/ikpykit/" +Repository = "https://github.com/IsolationKernel/ikpykit" +Documentation = "https://isolationkernel.github.io/ikpykit/" +"Release Notes" = "https://isolationkernel.github.io/ikpykit/latest/releases/releases" [project.license] @@ -62,14 +62,14 @@ build-backend = "setuptools.build_meta" [tool.setuptools_scm] -version_file = "pyikt/_version.py" +version_file = "ikpykit/_version.py" local_scheme = "no-local-version" [tool.setuptools.packages.find] where = ["."] # list of folders that contain the packages (["."] by default) -include = ["pyikt", "pyikt*"] +include = ["ikpykit", "ikpykit*"] exclude = [ - "pyikt/**/tests/*", + "ikpykit/**/tests/*", ] # exclude packages matching these glob patterns (empty by default) namespaces = false # to disable scanning PEP 420 namespaces (true by default) @@ -84,7 +84,7 @@ numba = ">=0.54" numpy = "<=1.22" [tool.pixi.pypi-dependencies] -pyikt = { path = ".", editable = true } +ikpykit = { path = ".", editable = true } [tool.pixi.feature.lint.dependencies] # The version below should be aligned with the one of `.pre-commit-config.yaml` @@ -93,8 +93,8 @@ pre-commit = "3.7.1" ruff = "0.9.9" [tool.pixi.feature.lint.tasks] -black = { cmd = "black --check --diff pyikt && black --check --diff examples" } -ruff = { cmd = "ruff check --output-format=full pyikt && ruff check --output-format=full examples" } +black = { cmd = "black --check --diff ikpykit && black --check --diff examples" } +ruff = { cmd = "ruff check --output-format=full ikpykit && ruff check --output-format=full examples" } lint = { depends-on = ["black", "ruff"] } [tool.pixi.feature.test.dependencies] @@ -102,7 +102,7 @@ pytest = "*" pytest-cov = "*" [tool.pixi.feature.test.tasks] -test = { cmd = "pytest -vsl --cov=pyikt --cov-report=xml pyikt" } +test = { cmd = "pytest -vsl --cov=ikpykit --cov-report=xml ikpykit" } [tool.pixi.feature.doc.dependencies] mike = "2.1.3" @@ -136,7 +136,7 @@ exclude = ''' | \.vscode )/ ''' -force-exclude = "pyikt/_version.py" +force-exclude = "ikpykit/_version.py" [tool.ruff] # max line length for black @@ -149,7 +149,7 @@ exclude = [ "doc/_build", "doc/auto_examples", "build", - "pyikt/_version.py", + "ikpykit/_version.py", ] [tool.ruff.lint] From 8bc2dfae6b517b855c63305082f5339fbfaa9d7d Mon Sep 17 00:00:00 2001 From: Xin Han Date: Mon, 10 Mar 2025 12:22:53 +1100 Subject: [PATCH 4/5] fix pacakge circular import --- ikpykit/kernel/_isodiskernel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ikpykit/kernel/_isodiskernel.py b/ikpykit/kernel/_isodiskernel.py index 33c64fd..3e44419 100644 --- a/ikpykit/kernel/_isodiskernel.py +++ b/ikpykit/kernel/_isodiskernel.py @@ -16,7 +16,7 @@ from sklearn.utils import check_array from sklearn.utils.validation import check_is_fitted -from ikpykit.kernel import IsoKernel +from ._isokernel import IsoKernel class IsoDisKernel(BaseEstimator, TransformerMixin): From 9fb87d0a1c6a3dac906526c383da178b782525f5 Mon Sep 17 00:00:00 2001 From: Xin Han Date: Mon, 10 Mar 2025 12:55:36 +1100 Subject: [PATCH 5/5] fix install --- docs/quick-start/how-to-install.md | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/quick-start/how-to-install.md b/docs/quick-start/how-to-install.md index a5f3f0b..7b2e3c6 100644 --- a/docs/quick-start/how-to-install.md +++ b/docs/quick-start/how-to-install.md @@ -12,18 +12,35 @@ To install the basic version of `ikpykit` with its core dependencies, run: pip install ikpykit ``` -Specific version: +If you're feeling brave, feel free to install the bleeding edge: NOTE: Do so at your own risk; no guarantees given! +Latest (unstable): ```bash -pip install ikpykit==0.1.0 +pip install git+https://github.com/IsolationKernel/ikpykit.git@main --upgrade ``` -Latest (unstable): +Alternatively download the package, install requirements, and manually run the installer: ```bash -pip install git+https://github.com/ikpykit/ikpykit@master +wget https://github.com/IsolationKernel/ikpykit.git@main +unzip ikpykit-main.zip +rm ikpyikt-main.zip +cd ikpykit-main + +pip install -r requirements.txt + +python setup.py install ``` +Once the installation is completed, you can check whether the installation was successful through: + +```py +import ikpyikt +print(ikpyikt.__version__) +``` + +## **Dependencies** + The following dependencies are installed with the default installation: + numpy>=1.22