labelfree 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- labelfree-1.0.0/.github/workflows/docs.yml +39 -0
- labelfree-1.0.0/.github/workflows/release.yml +45 -0
- labelfree-1.0.0/.github/workflows/tests.yml +37 -0
- labelfree-1.0.0/.gitignore +179 -0
- labelfree-1.0.0/.pre-commit-config.yaml +7 -0
- labelfree-1.0.0/CHANGELOG.md +9 -0
- labelfree-1.0.0/CITATION.cff +12 -0
- labelfree-1.0.0/CONTRIBUTING.md +13 -0
- labelfree-1.0.0/LICENSE +21 -0
- labelfree-1.0.0/PKG-INFO +82 -0
- labelfree-1.0.0/README.md +46 -0
- labelfree-1.0.0/SECURITY.md +8 -0
- labelfree-1.0.0/docs/api.md +133 -0
- labelfree-1.0.0/docs/examples.md +59 -0
- labelfree-1.0.0/docs/index.md +47 -0
- labelfree-1.0.0/docs/metrics.md +66 -0
- labelfree-1.0.0/examples/metric_signal_analysis.ipynb +1114 -0
- labelfree-1.0.0/examples/metric_tuning.ipynb +452 -0
- labelfree-1.0.0/labelfree/__init__.py +5 -0
- labelfree-1.0.0/labelfree/metrics/__init__.py +48 -0
- labelfree-1.0.0/labelfree/metrics/asoi.py +125 -0
- labelfree-1.0.0/labelfree/metrics/autouad.py +94 -0
- labelfree-1.0.0/labelfree/metrics/consensus.py +95 -0
- labelfree-1.0.0/labelfree/metrics/ireos.py +356 -0
- labelfree-1.0.0/labelfree/metrics/laplacian.py +55 -0
- labelfree-1.0.0/labelfree/metrics/mass_volume.py +147 -0
- labelfree-1.0.0/labelfree/metrics/score_cluster.py +57 -0
- labelfree-1.0.0/labelfree/metrics/sireos.py +66 -0
- labelfree-1.0.0/labelfree/metrics/stability.py +126 -0
- labelfree-1.0.0/labelfree/utils/__init__.py +1 -0
- labelfree-1.0.0/labelfree/utils/validation.py +77 -0
- labelfree-1.0.0/pyproject.toml +52 -0
- labelfree-1.0.0/tests/test_asoi.py +47 -0
- labelfree-1.0.0/tests/test_autouad.py +67 -0
- labelfree-1.0.0/tests/test_consensus.py +80 -0
- labelfree-1.0.0/tests/test_ireos.py +180 -0
- labelfree-1.0.0/tests/test_laplacian.py +49 -0
- labelfree-1.0.0/tests/test_mass_volume.py +114 -0
- labelfree-1.0.0/tests/test_score_cluster.py +67 -0
- labelfree-1.0.0/tests/test_sireos.py +31 -0
- labelfree-1.0.0/tests/test_stability.py +69 -0
- labelfree-1.0.0/zensical.toml +28 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: Documentation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
paths:
|
|
7
|
+
- "docs/**"
|
|
8
|
+
- "zensical.toml"
|
|
9
|
+
- ".github/workflows/docs.yml"
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
pages: write
|
|
15
|
+
id-token: write
|
|
16
|
+
|
|
17
|
+
concurrency:
|
|
18
|
+
group: pages
|
|
19
|
+
cancel-in-progress: true
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
deploy:
|
|
23
|
+
environment:
|
|
24
|
+
name: github-pages
|
|
25
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/configure-pages@v5
|
|
29
|
+
- uses: actions/checkout@v5
|
|
30
|
+
- uses: actions/setup-python@v5
|
|
31
|
+
with:
|
|
32
|
+
python-version: "3.12"
|
|
33
|
+
- run: python -m pip install "zensical==0.0.47"
|
|
34
|
+
- run: zensical build --clean
|
|
35
|
+
- uses: actions/upload-pages-artifact@v4
|
|
36
|
+
with:
|
|
37
|
+
path: site
|
|
38
|
+
- uses: actions/deploy-pages@v4
|
|
39
|
+
id: deployment
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v5
|
|
15
|
+
- uses: actions/setup-python@v6
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
- run: python -m pip install ".[dev]" build twine
|
|
19
|
+
- name: Verify release tag
|
|
20
|
+
env:
|
|
21
|
+
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
|
22
|
+
run: >-
|
|
23
|
+
python -c "import importlib.metadata as metadata, labelfree, os;
|
|
24
|
+
expected = os.environ['RELEASE_TAG'];
|
|
25
|
+
assert expected == f'v{labelfree.__version__}' == 'v' + metadata.version('labelfree')"
|
|
26
|
+
- run: pytest
|
|
27
|
+
- run: python -m build
|
|
28
|
+
- run: twine check dist/*
|
|
29
|
+
- uses: actions/upload-artifact@v4
|
|
30
|
+
with:
|
|
31
|
+
name: distributions
|
|
32
|
+
path: dist/
|
|
33
|
+
|
|
34
|
+
publish:
|
|
35
|
+
needs: build
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
environment: pypi
|
|
38
|
+
permissions:
|
|
39
|
+
id-token: write
|
|
40
|
+
steps:
|
|
41
|
+
- uses: actions/download-artifact@v4
|
|
42
|
+
with:
|
|
43
|
+
name: distributions
|
|
44
|
+
path: dist/
|
|
45
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
lint:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v5
|
|
15
|
+
- uses: actions/setup-python@v6
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
cache: pip
|
|
19
|
+
cache-dependency-path: pyproject.toml
|
|
20
|
+
- run: python -m pip install ".[dev]"
|
|
21
|
+
- run: pre-commit run --all-files --show-diff-on-failure
|
|
22
|
+
|
|
23
|
+
test:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
strategy:
|
|
26
|
+
fail-fast: false
|
|
27
|
+
matrix:
|
|
28
|
+
python-version: ["3.12", "3.13", "3.14"]
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v5
|
|
31
|
+
- uses: actions/setup-python@v6
|
|
32
|
+
with:
|
|
33
|
+
python-version: ${{ matrix.python-version }}
|
|
34
|
+
cache: pip
|
|
35
|
+
cache-dependency-path: pyproject.toml
|
|
36
|
+
- run: python -m pip install ".[dev]"
|
|
37
|
+
- run: pytest
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Project
|
|
2
|
+
.idea
|
|
3
|
+
.claude
|
|
4
|
+
CLAUDE.md
|
|
5
|
+
|
|
6
|
+
# Byte-compiled / optimized / DLL files
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
*$py.class
|
|
10
|
+
|
|
11
|
+
# C extensions
|
|
12
|
+
*.so
|
|
13
|
+
|
|
14
|
+
# Distribution / packaging
|
|
15
|
+
.Python
|
|
16
|
+
build/
|
|
17
|
+
develop-eggs/
|
|
18
|
+
dist/
|
|
19
|
+
downloads/
|
|
20
|
+
eggs/
|
|
21
|
+
.eggs/
|
|
22
|
+
lib/
|
|
23
|
+
lib64/
|
|
24
|
+
parts/
|
|
25
|
+
sdist/
|
|
26
|
+
var/
|
|
27
|
+
wheels/
|
|
28
|
+
share/python-wheels/
|
|
29
|
+
*.egg-info/
|
|
30
|
+
.installed.cfg
|
|
31
|
+
*.egg
|
|
32
|
+
MANIFEST
|
|
33
|
+
|
|
34
|
+
# PyInstaller
|
|
35
|
+
# Usually these files are written by a python script from a template
|
|
36
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
37
|
+
*.manifest
|
|
38
|
+
*.spec
|
|
39
|
+
|
|
40
|
+
# Installer logs
|
|
41
|
+
pip-log.txt
|
|
42
|
+
pip-delete-this-directory.txt
|
|
43
|
+
|
|
44
|
+
# Unit test / coverage reports
|
|
45
|
+
htmlcov/
|
|
46
|
+
.tox/
|
|
47
|
+
.nox/
|
|
48
|
+
.coverage
|
|
49
|
+
.coverage.*
|
|
50
|
+
.cache
|
|
51
|
+
nosetests.xml
|
|
52
|
+
coverage.xml
|
|
53
|
+
*.cover
|
|
54
|
+
*.py,cover
|
|
55
|
+
.hypothesis/
|
|
56
|
+
.pytest_cache/
|
|
57
|
+
cover/
|
|
58
|
+
|
|
59
|
+
# Translations
|
|
60
|
+
*.mo
|
|
61
|
+
*.pot
|
|
62
|
+
|
|
63
|
+
# Django stuff:
|
|
64
|
+
*.log
|
|
65
|
+
local_settings.py
|
|
66
|
+
db.sqlite3
|
|
67
|
+
db.sqlite3-journal
|
|
68
|
+
|
|
69
|
+
# Flask stuff:
|
|
70
|
+
instance/
|
|
71
|
+
.webassets-cache
|
|
72
|
+
|
|
73
|
+
# Scrapy stuff:
|
|
74
|
+
.scrapy
|
|
75
|
+
|
|
76
|
+
# Sphinx documentation
|
|
77
|
+
docs/_build/
|
|
78
|
+
|
|
79
|
+
# PyBuilder
|
|
80
|
+
.pybuilder/
|
|
81
|
+
target/
|
|
82
|
+
|
|
83
|
+
# Jupyter Notebook
|
|
84
|
+
.ipynb_checkpoints
|
|
85
|
+
|
|
86
|
+
# IPython
|
|
87
|
+
profile_default/
|
|
88
|
+
ipython_config.py
|
|
89
|
+
|
|
90
|
+
# pyenv
|
|
91
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
92
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
93
|
+
# .python-version
|
|
94
|
+
|
|
95
|
+
# pipenv
|
|
96
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
97
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
98
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
99
|
+
# install all needed dependencies.
|
|
100
|
+
#Pipfile.lock
|
|
101
|
+
|
|
102
|
+
# UV
|
|
103
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
104
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
105
|
+
# commonly ignored for libraries.
|
|
106
|
+
uv.lock
|
|
107
|
+
|
|
108
|
+
# poetry
|
|
109
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
110
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
111
|
+
# commonly ignored for libraries.
|
|
112
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
113
|
+
#poetry.lock
|
|
114
|
+
|
|
115
|
+
# pdm
|
|
116
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
117
|
+
#pdm.lock
|
|
118
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
119
|
+
# in version control.
|
|
120
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
121
|
+
.pdm.toml
|
|
122
|
+
.pdm-python
|
|
123
|
+
.pdm-build/
|
|
124
|
+
|
|
125
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
126
|
+
__pypackages__/
|
|
127
|
+
|
|
128
|
+
# Celery stuff
|
|
129
|
+
celerybeat-schedule
|
|
130
|
+
celerybeat.pid
|
|
131
|
+
|
|
132
|
+
# SageMath parsed files
|
|
133
|
+
*.sage.py
|
|
134
|
+
|
|
135
|
+
# Environments
|
|
136
|
+
.env
|
|
137
|
+
.venv
|
|
138
|
+
env/
|
|
139
|
+
venv/
|
|
140
|
+
ENV/
|
|
141
|
+
env.bak/
|
|
142
|
+
venv.bak/
|
|
143
|
+
|
|
144
|
+
# Spyder project settings
|
|
145
|
+
.spyderproject
|
|
146
|
+
.spyproject
|
|
147
|
+
|
|
148
|
+
# Rope project settings
|
|
149
|
+
.ropeproject
|
|
150
|
+
|
|
151
|
+
# mkdocs documentation
|
|
152
|
+
/site
|
|
153
|
+
|
|
154
|
+
# mypy
|
|
155
|
+
.mypy_cache/
|
|
156
|
+
.dmypy.json
|
|
157
|
+
dmypy.json
|
|
158
|
+
|
|
159
|
+
# Pyre type checker
|
|
160
|
+
.pyre/
|
|
161
|
+
|
|
162
|
+
# pytype static type analyzer
|
|
163
|
+
.pytype/
|
|
164
|
+
|
|
165
|
+
# Cython debug symbols
|
|
166
|
+
cython_debug/
|
|
167
|
+
|
|
168
|
+
# PyCharm
|
|
169
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
170
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
171
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
172
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
173
|
+
#.idea/
|
|
174
|
+
|
|
175
|
+
# Ruff stuff:
|
|
176
|
+
.ruff_cache/
|
|
177
|
+
|
|
178
|
+
# PyPI configuration file
|
|
179
|
+
.pypirc
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 - 2026-07-10
|
|
4
|
+
|
|
5
|
+
- First stable functional API for label-free anomaly-detector metrics.
|
|
6
|
+
- Source-checked implementations with explicit score polarity and metric direction.
|
|
7
|
+
- Zensical documentation, tests, examples, CI, and trusted PyPI publishing.
|
|
8
|
+
- Faithful relative IREOS with kernel-logistic separability and adaptive
|
|
9
|
+
integration, replacing the former distance heuristic.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use labelfree, please cite this software."
|
|
3
|
+
title: "labelfree"
|
|
4
|
+
type: software
|
|
5
|
+
authors:
|
|
6
|
+
- family-names: "Hennhoefer"
|
|
7
|
+
given-names: "Oliver"
|
|
8
|
+
version: 1.0.0
|
|
9
|
+
date-released: 2026-07-10
|
|
10
|
+
repository-code: "https://github.com/OliverHennhoefer/label-free"
|
|
11
|
+
url: "https://oliverhennhoefer.github.io/label-free/"
|
|
12
|
+
license: MIT
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Open an issue before large changes. For a focused fix:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
python -m pip install -e ".[dev]"
|
|
7
|
+
pre-commit install
|
|
8
|
+
pre-commit run --all-files
|
|
9
|
+
pytest
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Keep pull requests small, add one regression test for changed behavior, and cite
|
|
13
|
+
the paper or author implementation when changing a published metric.
|
labelfree-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Oliver Hennhöfer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
labelfree-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: labelfree
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Label-free metrics for unsupervised anomaly detector evaluation
|
|
5
|
+
Project-URL: Documentation, https://oliverhennhoefer.github.io/label-free/
|
|
6
|
+
Project-URL: Issues, https://github.com/OliverHennhoefer/label-free/issues
|
|
7
|
+
Project-URL: Repository, https://github.com/OliverHennhoefer/label-free
|
|
8
|
+
Author-email: Oliver Hennhoefer <oliver.hennhoefer@mail.de>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: anomaly-detection,model-selection,unsupervised-learning
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Requires-Dist: numpy>=1.24
|
|
21
|
+
Requires-Dist: scikit-learn>=1.3
|
|
22
|
+
Requires-Dist: scipy>=1.10
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pre-commit>=4.2; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
26
|
+
Requires-Dist: ruff>=0.12; extra == 'dev'
|
|
27
|
+
Provides-Extra: docs
|
|
28
|
+
Requires-Dist: zensical==0.0.47; extra == 'docs'
|
|
29
|
+
Provides-Extra: examples
|
|
30
|
+
Requires-Dist: numba>=0.66; extra == 'examples'
|
|
31
|
+
Requires-Dist: oddball>=1.4; extra == 'examples'
|
|
32
|
+
Requires-Dist: optuna>=4; extra == 'examples'
|
|
33
|
+
Requires-Dist: pandas>=2.2; extra == 'examples'
|
|
34
|
+
Requires-Dist: pyod>=1.1; extra == 'examples'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# labelfree
|
|
38
|
+
|
|
39
|
+
[](https://github.com/OliverHennhoefer/label-free/actions/workflows/tests.yml)
|
|
40
|
+
[](https://oliverhennhoefer.github.io/label-free/)
|
|
41
|
+
[](https://pypi.org/project/labelfree/)
|
|
42
|
+
|
|
43
|
+
Label-free metrics for comparing unsupervised anomaly detectors and
|
|
44
|
+
hyperparameters when labeled anomalies are unavailable.
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install labelfree
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Quick start
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from labelfree.metrics import score_cluster_metrics
|
|
56
|
+
|
|
57
|
+
scores = [0.1, 0.2, 0.3, 3.8, 4.1]
|
|
58
|
+
metrics = score_cluster_metrics(scores, n_outliers=2)
|
|
59
|
+
print(metrics["silhouette"]) # higher is better
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The package includes score-cluster, ASI/ASOI, AutoUAD, Laplacian,
|
|
63
|
+
consensus, ranking-stability, IREOS, SIREOS, and Excess-Mass/Mass-Volume metrics.
|
|
64
|
+
Every raw-score API requires an explicit score polarity when larger values
|
|
65
|
+
mean more normal.
|
|
66
|
+
|
|
67
|
+
Label-free metrics are model-selection signals, not substitutes for labeled
|
|
68
|
+
evaluation. Check each metric's assumptions and direction before comparing
|
|
69
|
+
results.
|
|
70
|
+
|
|
71
|
+
See the [documentation](https://oliverhennhoefer.github.io/label-free/) for
|
|
72
|
+
metric selection, API details, and examples.
|
|
73
|
+
|
|
74
|
+
## Development
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
python -m pip install -e ".[dev]"
|
|
78
|
+
pytest
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Contributions are welcome; see [CONTRIBUTING.md](CONTRIBUTING.md). Released
|
|
82
|
+
under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# labelfree
|
|
2
|
+
|
|
3
|
+
[](https://github.com/OliverHennhoefer/label-free/actions/workflows/tests.yml)
|
|
4
|
+
[](https://oliverhennhoefer.github.io/label-free/)
|
|
5
|
+
[](https://pypi.org/project/labelfree/)
|
|
6
|
+
|
|
7
|
+
Label-free metrics for comparing unsupervised anomaly detectors and
|
|
8
|
+
hyperparameters when labeled anomalies are unavailable.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install labelfree
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
from labelfree.metrics import score_cluster_metrics
|
|
20
|
+
|
|
21
|
+
scores = [0.1, 0.2, 0.3, 3.8, 4.1]
|
|
22
|
+
metrics = score_cluster_metrics(scores, n_outliers=2)
|
|
23
|
+
print(metrics["silhouette"]) # higher is better
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The package includes score-cluster, ASI/ASOI, AutoUAD, Laplacian,
|
|
27
|
+
consensus, ranking-stability, IREOS, SIREOS, and Excess-Mass/Mass-Volume metrics.
|
|
28
|
+
Every raw-score API requires an explicit score polarity when larger values
|
|
29
|
+
mean more normal.
|
|
30
|
+
|
|
31
|
+
Label-free metrics are model-selection signals, not substitutes for labeled
|
|
32
|
+
evaluation. Check each metric's assumptions and direction before comparing
|
|
33
|
+
results.
|
|
34
|
+
|
|
35
|
+
See the [documentation](https://oliverhennhoefer.github.io/label-free/) for
|
|
36
|
+
metric selection, API details, and examples.
|
|
37
|
+
|
|
38
|
+
## Development
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
python -m pip install -e ".[dev]"
|
|
42
|
+
pytest
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Contributions are welcome; see [CONTRIBUTING.md](CONTRIBUTING.md). Released
|
|
46
|
+
under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
Security fixes are supported for the latest 1.x release.
|
|
4
|
+
|
|
5
|
+
Please report vulnerabilities privately through GitHub's security advisory
|
|
6
|
+
form. If private reporting is unavailable, email
|
|
7
|
+
`oliver.hennhoefer@mail.de`. Do not open a public issue before a fix is
|
|
8
|
+
available.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# API reference
|
|
2
|
+
|
|
3
|
+
Import public functions from `labelfree.metrics`.
|
|
4
|
+
|
|
5
|
+
## Partition metrics
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
score_cluster_metrics(
|
|
9
|
+
scores, *, n_outliers=None, contamination=None,
|
|
10
|
+
score_polarity="higher_is_anomalous"
|
|
11
|
+
) -> dict[str, float]
|
|
12
|
+
|
|
13
|
+
asi_score(
|
|
14
|
+
X, scores, *, n_outliers=None, contamination=None,
|
|
15
|
+
score_polarity="higher_is_anomalous"
|
|
16
|
+
) -> float
|
|
17
|
+
|
|
18
|
+
asoi_score(
|
|
19
|
+
X, scores, *, n_outliers=None, contamination=None,
|
|
20
|
+
score_polarity="higher_is_anomalous",
|
|
21
|
+
alpha=0.5314, beta=0.4686
|
|
22
|
+
) -> float
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Pass exactly one of `n_outliers` and `contamination`. Contamination uses
|
|
26
|
+
`ceil(n_samples * contamination)`.
|
|
27
|
+
|
|
28
|
+
## Score-distribution metrics
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
relative_top_median_score(
|
|
32
|
+
scores, *, top_fraction=0.05,
|
|
33
|
+
score_polarity="higher_is_anomalous", eps=1e-6
|
|
34
|
+
) -> float
|
|
35
|
+
|
|
36
|
+
expected_anomaly_gap_score(
|
|
37
|
+
scores, *, top_fraction=0.2,
|
|
38
|
+
score_polarity="higher_is_anomalous", eps=1e-6
|
|
39
|
+
) -> float
|
|
40
|
+
|
|
41
|
+
normalized_pseudo_discrepancy_score(
|
|
42
|
+
validation_scores, generated_scores, *,
|
|
43
|
+
score_polarity="higher_is_anomalous", eps=1e-6
|
|
44
|
+
) -> float
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
All three return higher-is-better scalars.
|
|
48
|
+
|
|
49
|
+
## Feature-space metrics
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
laplacian_score(
|
|
53
|
+
X, scores, *, n_neighbors=5,
|
|
54
|
+
score_polarity="higher_is_anomalous"
|
|
55
|
+
) -> float
|
|
56
|
+
|
|
57
|
+
sireos_score(
|
|
58
|
+
X, scores, *, score_polarity="higher_is_anomalous",
|
|
59
|
+
kernel_width=None, kernel_quantile=0.01
|
|
60
|
+
) -> float
|
|
61
|
+
|
|
62
|
+
ireos_score(
|
|
63
|
+
X, outlier_probabilities, *, gamma_max=None,
|
|
64
|
+
max_clump_size=1, penalty_cost=100.0,
|
|
65
|
+
integration_tol=0.005
|
|
66
|
+
) -> float
|
|
67
|
+
|
|
68
|
+
ireos_scores(
|
|
69
|
+
X, outlier_probability_matrix, *, gamma_max=None,
|
|
70
|
+
max_clump_size=1, penalty_cost=100.0,
|
|
71
|
+
integration_tol=0.005
|
|
72
|
+
) -> np.ndarray
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
IREOS is higher-is-better; SIREOS and Laplacian Score are lower-is-better.
|
|
76
|
+
IREOS requires detector-specific outlier probabilities in `[0, 1]`, not raw
|
|
77
|
+
scores. The plural function uses one shared automatically selected `gamma_max`
|
|
78
|
+
for all rows. Automatic selection requires at least one probability above
|
|
79
|
+
`0.5`; otherwise, pass `gamma_max` explicitly. If `kernel_width` is omitted,
|
|
80
|
+
SIREOS uses the requested quantile
|
|
81
|
+
of nonzero pairwise distances.
|
|
82
|
+
|
|
83
|
+
## Candidate consensus
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
model_centrality_scores(score_matrix, *, score_polarity="higher_is_anomalous")
|
|
87
|
+
average_rank_consensus_scores(score_matrix, *, score_polarity="higher_is_anomalous")
|
|
88
|
+
hits_model_scores(
|
|
89
|
+
score_matrix, *, score_polarity="higher_is_anomalous",
|
|
90
|
+
max_iter=100, tol=1e-10
|
|
91
|
+
)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`score_matrix` has shape `(n_models, n_samples)`. Each function returns one
|
|
95
|
+
higher-is-better value per model.
|
|
96
|
+
|
|
97
|
+
## Ranking stability
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
ranking_stability_score(
|
|
101
|
+
score_matrix, *, contamination, psi=0.8,
|
|
102
|
+
score_polarity="higher_is_anomalous"
|
|
103
|
+
) -> float
|
|
104
|
+
|
|
105
|
+
top_k_stability_score(
|
|
106
|
+
score_matrix, *, top_k=None, top_fraction=None,
|
|
107
|
+
score_polarity="higher_is_anomalous"
|
|
108
|
+
) -> float
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`score_matrix` has shape `(n_runs, n_samples)`. Pass exactly one of
|
|
112
|
+
`top_k` and `top_fraction` to top-k stability.
|
|
113
|
+
|
|
114
|
+
## Excess-Mass and Mass-Volume
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
excess_mass_curve(scores, reference_scores, *, support_volume, ...)
|
|
118
|
+
excess_mass_auc(scores, reference_scores, *, support_volume, ...)
|
|
119
|
+
mass_volume_curve(scores, reference_scores, *, support_volume, ...)
|
|
120
|
+
mass_volume_auc(scores, reference_scores, *, support_volume, ...)
|
|
121
|
+
bounding_box_volume(X, *, offset=1e-12) -> float
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Curve functions return `(axis, values)`. `reference_scores` are detector
|
|
125
|
+
scores on uniform samples from the support whose Lebesgue volume is
|
|
126
|
+
`support_volume`. `bounding_box_volume` is a convenience for an
|
|
127
|
+
axis-aligned support; it does not generate the reference samples.
|
|
128
|
+
|
|
129
|
+
## Validation
|
|
130
|
+
|
|
131
|
+
Inputs are converted to finite floating-point arrays. Invalid dimensions,
|
|
132
|
+
non-finite values, inconsistent sample counts, invalid fractions, and unknown
|
|
133
|
+
score polarities raise `ValueError`.
|