anomx 0.2.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.
- anomx-0.2.0/.github/workflows/ci.yml +29 -0
- anomx-0.2.0/.gitignore +29 -0
- anomx-0.2.0/.pre-commit-config.yaml +7 -0
- anomx-0.2.0/AGENTS.md +48 -0
- anomx-0.2.0/CHANGELOG.md +5 -0
- anomx-0.2.0/CONTRIBUTING.md +39 -0
- anomx-0.2.0/LICENSE +17 -0
- anomx-0.2.0/PKG-INFO +169 -0
- anomx-0.2.0/README.md +122 -0
- anomx-0.2.0/docs/api.md +30 -0
- anomx-0.2.0/docs/index.md +15 -0
- anomx-0.2.0/examples/baseline_detection.py +15 -0
- anomx-0.2.0/examples/naive_forecast.py +15 -0
- anomx-0.2.0/mkdocs.yml +8 -0
- anomx-0.2.0/pyproject.toml +118 -0
- anomx-0.2.0/src/anomx/__init__.py +53 -0
- anomx-0.2.0/src/anomx/__main__.py +6 -0
- anomx-0.2.0/src/anomx/_shared.py +40 -0
- anomx-0.2.0/src/anomx/cli.py +22 -0
- anomx-0.2.0/src/anomx/components/__init__.py +29 -0
- anomx-0.2.0/src/anomx/components/algorithms/__init__.py +14 -0
- anomx-0.2.0/src/anomx/components/algorithms/base.py +19 -0
- anomx-0.2.0/src/anomx/components/algorithms/contracts.py +49 -0
- anomx-0.2.0/src/anomx/components/algorithms/offline/__init__.py +28 -0
- anomx-0.2.0/src/anomx/components/algorithms/offline/catalog.py +58 -0
- anomx-0.2.0/src/anomx/components/algorithms/offline/pipeline.py +74 -0
- anomx-0.2.0/src/anomx/components/base.py +170 -0
- anomx-0.2.0/src/anomx/components/detection/__init__.py +11 -0
- anomx-0.2.0/src/anomx/components/detection/detectors/__init__.py +9 -0
- anomx-0.2.0/src/anomx/components/detection/detectors/base.py +18 -0
- anomx-0.2.0/src/anomx/components/detection/detectors/threshold.py +40 -0
- anomx-0.2.0/src/anomx/components/detection/scorers/__init__.py +9 -0
- anomx-0.2.0/src/anomx/components/detection/scorers/base.py +18 -0
- anomx-0.2.0/src/anomx/components/detection/scorers/zscore.py +41 -0
- anomx-0.2.0/src/anomx/components/models/__init__.py +13 -0
- anomx-0.2.0/src/anomx/components/models/base.py +30 -0
- anomx-0.2.0/src/anomx/components/models/forecasting/__init__.py +7 -0
- anomx-0.2.0/src/anomx/components/models/forecasting/rolling_window.py +86 -0
- anomx-0.2.0/src/anomx/components/models/reconstruction/__init__.py +7 -0
- anomx-0.2.0/src/anomx/components/models/reconstruction/pca.py +99 -0
- anomx-0.2.0/src/anomx/components/models/representation/__init__.py +7 -0
- anomx-0.2.0/src/anomx/components/models/representation/isolation_forest.py +80 -0
- anomx-0.2.0/src/anomx/data/__init__.py +10 -0
- anomx-0.2.0/src/anomx/data/connectors/__init__.py +9 -0
- anomx-0.2.0/src/anomx/data/connectors/base.py +26 -0
- anomx-0.2.0/src/anomx/data/connectors/local_fs.py +51 -0
- anomx-0.2.0/src/anomx/data/sequences/__init__.py +7 -0
- anomx-0.2.0/src/anomx/data/sequences/timeseries.py +28 -0
- anomx-0.2.0/src/anomx/datasets/__init__.py +10 -0
- anomx-0.2.0/src/anomx/datasets/core.py +136 -0
- anomx-0.2.0/src/anomx/datasets/loaders/__init__.py +5 -0
- anomx-0.2.0/src/anomx/datasets/loaders/synthetic.py +38 -0
- anomx-0.2.0/src/anomx/detectors/__init__.py +10 -0
- anomx-0.2.0/src/anomx/detectors/base.py +50 -0
- anomx-0.2.0/src/anomx/detectors/statistical.py +61 -0
- anomx-0.2.0/src/anomx/integrations/__init__.py +8 -0
- anomx-0.2.0/src/anomx/integrations/darts.py +83 -0
- anomx-0.2.0/src/anomx/models/__init__.py +16 -0
- anomx-0.2.0/src/anomx/models/base.py +35 -0
- anomx-0.2.0/src/anomx/models/forecasting/__init__.py +12 -0
- anomx-0.2.0/src/anomx/models/naive.py +64 -0
- anomx-0.2.0/src/anomx/models/reconstruction/__init__.py +7 -0
- anomx-0.2.0/src/anomx/models/representation/__init__.py +7 -0
- anomx-0.2.0/src/anomx/py.typed +1 -0
- anomx-0.2.0/src/anomx/scorers/__init__.py +10 -0
- anomx-0.2.0/src/anomx/scorers/base.py +15 -0
- anomx-0.2.0/src/anomx/scorers/statistical.py +43 -0
- anomx-0.2.0/tests/test_components.py +76 -0
- anomx-0.2.0/tests/test_datasets.py +29 -0
- anomx-0.2.0/tests/test_detectors.py +13 -0
- anomx-0.2.0/tests/test_models.py +12 -0
- anomx-0.2.0/tests/test_package.py +19 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python-version }}
|
|
20
|
+
- name: Install
|
|
21
|
+
run: |
|
|
22
|
+
python -m pip install --upgrade pip
|
|
23
|
+
python -m pip install -e ".[dev]"
|
|
24
|
+
- name: Lint
|
|
25
|
+
run: ruff check .
|
|
26
|
+
- name: Type check
|
|
27
|
+
run: mypy src/anomx
|
|
28
|
+
- name: Test
|
|
29
|
+
run: pytest --cov
|
anomx-0.2.0/.gitignore
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.pytest_cache/
|
|
6
|
+
.ruff_cache/
|
|
7
|
+
.mypy_cache/
|
|
8
|
+
.coverage
|
|
9
|
+
htmlcov/
|
|
10
|
+
build/
|
|
11
|
+
dist/
|
|
12
|
+
|
|
13
|
+
# Environments
|
|
14
|
+
.env
|
|
15
|
+
.venv/
|
|
16
|
+
venv/
|
|
17
|
+
|
|
18
|
+
# Editors and OS files
|
|
19
|
+
.DS_Store
|
|
20
|
+
.idea/
|
|
21
|
+
.vscode/
|
|
22
|
+
|
|
23
|
+
# Data and artifacts
|
|
24
|
+
/data/
|
|
25
|
+
/artifacts/
|
|
26
|
+
/models/
|
|
27
|
+
*.parquet
|
|
28
|
+
*.pkl
|
|
29
|
+
*.joblib
|
anomx-0.2.0/AGENTS.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This repository contains the open-source Python package that backs Anomx, a
|
|
4
|
+
data intelligence platform for time series, forecasting, anomaly detection, and
|
|
5
|
+
human-in-the-loop operational workflows.
|
|
6
|
+
|
|
7
|
+
## Project Intent
|
|
8
|
+
|
|
9
|
+
The package should stay focused on reusable library primitives:
|
|
10
|
+
|
|
11
|
+
- `datasets`: time series containers, dataset loaders, splits, transforms, and metadata.
|
|
12
|
+
- `scorers`: functions and classes that turn observations, residuals, forecasts, or model
|
|
13
|
+
outputs into anomaly scores.
|
|
14
|
+
- `detectors`: online and batch anomaly detectors that produce actionable anomaly labels
|
|
15
|
+
and detection results.
|
|
16
|
+
- `models`: forecasting, representation, and predictive models.
|
|
17
|
+
- `integrations`: optional adapters for third-party ecosystems such as Darts.
|
|
18
|
+
|
|
19
|
+
The platform itself owns orchestration, persistence, workers, user feedback loops,
|
|
20
|
+
audit trails, and product-specific APIs. This library should expose the clean core
|
|
21
|
+
that the platform can compose.
|
|
22
|
+
|
|
23
|
+
## Engineering Guidelines
|
|
24
|
+
|
|
25
|
+
- Prefer small, typed, composable abstractions over platform-specific coupling.
|
|
26
|
+
- Keep the default install lightweight. Put heavy ML dependencies behind extras such as
|
|
27
|
+
`anomx[darts]`.
|
|
28
|
+
- Treat batch and online use cases as first-class design constraints.
|
|
29
|
+
- Favor interpretable outputs: anomaly scores, thresholds, labels, timestamps, and
|
|
30
|
+
metadata should be easy to inspect.
|
|
31
|
+
- Match the existing public API style before adding new patterns.
|
|
32
|
+
- Add or update tests for behavior changes.
|
|
33
|
+
|
|
34
|
+
## Local Commands
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
python -m pip install -e ".[dev]"
|
|
38
|
+
pytest
|
|
39
|
+
ruff check .
|
|
40
|
+
mypy src/anomx
|
|
41
|
+
python -m pip install -e ".[release]"
|
|
42
|
+
python -m build
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Compatibility
|
|
46
|
+
|
|
47
|
+
The package targets Python 3.10+ and uses a `src/` layout. Public APIs should be
|
|
48
|
+
documented in docstrings and exported deliberately through package `__init__.py` files.
|
anomx-0.2.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Anomx is early-stage. Contributions should make the core library easier to compose,
|
|
4
|
+
test, or integrate into production time-series workflows.
|
|
5
|
+
|
|
6
|
+
## Development Setup
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
python -m venv .venv
|
|
10
|
+
source .venv/bin/activate
|
|
11
|
+
python -m pip install --upgrade pip
|
|
12
|
+
python -m pip install -e ".[dev]"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Checks
|
|
16
|
+
|
|
17
|
+
Run the core checks before opening a pull request:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pytest
|
|
21
|
+
ruff check .
|
|
22
|
+
mypy src/anomx
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Install the release tooling only when building or publishing distributions:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
python -m pip install -e ".[release]"
|
|
29
|
+
python -m build
|
|
30
|
+
twine check dist/*
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Design Principles
|
|
34
|
+
|
|
35
|
+
- Keep the core package platform-agnostic.
|
|
36
|
+
- Put optional integrations behind optional dependencies.
|
|
37
|
+
- Use typed dataclasses or protocols for shared contracts.
|
|
38
|
+
- Make anomaly outputs inspectable and auditable.
|
|
39
|
+
- Prefer clear algorithms and adapters before deep framework coupling.
|
anomx-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2026 Anomx
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
anomx-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: anomx
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Installable time-series anomaly library with forecasting, reconstruction, and representation base approaches.
|
|
5
|
+
Project-URL: Homepage, https://www.anomx.io
|
|
6
|
+
Project-URL: Repository, https://github.com/theorieken/anomx
|
|
7
|
+
Project-URL: Issues, https://github.com/theorieken/anomx/issues
|
|
8
|
+
Author: Theo Rieken
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: anomaly-detection,data-intelligence,forecasting,machine-learning,observability,time-series
|
|
12
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Requires-Dist: numpy>=1.24
|
|
25
|
+
Requires-Dist: pandas>=2.0
|
|
26
|
+
Requires-Dist: scikit-learn>=1.3
|
|
27
|
+
Provides-Extra: darts
|
|
28
|
+
Requires-Dist: u8darts[all]>=0.30; extra == 'darts'
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
31
|
+
Requires-Dist: pandas-stubs>=2.2; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
35
|
+
Provides-Extra: docs
|
|
36
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
|
|
37
|
+
Requires-Dist: mkdocs>=1.6; extra == 'docs'
|
|
38
|
+
Provides-Extra: platform
|
|
39
|
+
Requires-Dist: fsspec>=2024.6; extra == 'platform'
|
|
40
|
+
Requires-Dist: pyarrow>=16.0; extra == 'platform'
|
|
41
|
+
Requires-Dist: redis>=5.0; extra == 'platform'
|
|
42
|
+
Provides-Extra: release
|
|
43
|
+
Requires-Dist: build>=1.2; extra == 'release'
|
|
44
|
+
Requires-Dist: docutils<0.22,>=0.21.2; extra == 'release'
|
|
45
|
+
Requires-Dist: twine<7.0,>=6.2; extra == 'release'
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
|
|
48
|
+
# anomx
|
|
49
|
+
|
|
50
|
+
`anomx` is the core Python library for the Anomx platform: time-series datasets,
|
|
51
|
+
forecasting models, anomaly scorers, and anomaly detectors built for interpretable,
|
|
52
|
+
production-oriented workflows.
|
|
53
|
+
|
|
54
|
+
Anomx is a data intelligence platform focused on anomaly detection and predictive
|
|
55
|
+
insights in complex, data-driven systems. The platform handles orchestration,
|
|
56
|
+
workers, storage, connectors, audit trails, and human-in-the-loop feedback. This
|
|
57
|
+
repository contains the reusable modeling layer that those systems compose.
|
|
58
|
+
|
|
59
|
+
## Goals
|
|
60
|
+
|
|
61
|
+
- Provide clean primitives for time-series datasets, scorers, detectors, and models.
|
|
62
|
+
- Support both batch and online anomaly detection workflows.
|
|
63
|
+
- Keep outputs interpretable: scores, thresholds, timestamps, labels, and metadata.
|
|
64
|
+
- Stay modular enough to power the Anomx platform without coupling the library to
|
|
65
|
+
the platform's storage or orchestration layer.
|
|
66
|
+
- Integrate with the broader time-series ecosystem, especially Darts, through
|
|
67
|
+
optional adapters.
|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
|
|
71
|
+
The package is structured for PyPI distribution:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install anomx
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For local development:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
git clone https://github.com/anomx/anomx.git
|
|
81
|
+
cd anomx
|
|
82
|
+
python -m pip install -e ".[dev]"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Optional extras:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pip install "anomx[darts]" # Darts forecasting model adapters
|
|
89
|
+
pip install "anomx[docs]" # Documentation tooling
|
|
90
|
+
pip install "anomx[platform]" # Platform-facing IO dependencies
|
|
91
|
+
pip install "anomx[release]" # Build and PyPI publishing tooling
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Package Layout
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
src/anomx/
|
|
98
|
+
datasets/ TimeSeriesDataset, metadata, dataset loaders, transforms
|
|
99
|
+
scorers/ Anomaly score contracts and scoring implementations
|
|
100
|
+
detectors/ Batch and online anomaly detector contracts and implementations
|
|
101
|
+
models/ Forecasting model contracts and baseline forecasters
|
|
102
|
+
integrations/ Optional adapters, including Darts
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Quick Start
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from anomx.datasets import make_sine_anomaly_dataset
|
|
109
|
+
from anomx.detectors import MovingAverageDetector
|
|
110
|
+
from anomx.models import NaiveSeasonalModel
|
|
111
|
+
|
|
112
|
+
dataset = make_sine_anomaly_dataset()
|
|
113
|
+
|
|
114
|
+
detector = MovingAverageDetector(window=24, threshold=3.0)
|
|
115
|
+
result = detector.fit_predict(dataset)
|
|
116
|
+
print(result.to_dataframe().tail())
|
|
117
|
+
|
|
118
|
+
model = NaiveSeasonalModel(season_length=24).fit(dataset)
|
|
119
|
+
forecast = model.predict(12)
|
|
120
|
+
print(forecast.to_dataframe())
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Darts Integration
|
|
124
|
+
|
|
125
|
+
The default install stays lightweight. To use Darts models, install the optional
|
|
126
|
+
extra and wrap any compatible Darts forecasting model:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from darts.models import ExponentialSmoothing
|
|
130
|
+
|
|
131
|
+
from anomx.datasets import make_sine_anomaly_dataset
|
|
132
|
+
from anomx.integrations import DartsForecastingModel
|
|
133
|
+
|
|
134
|
+
dataset = make_sine_anomaly_dataset()
|
|
135
|
+
model = DartsForecastingModel(ExponentialSmoothing())
|
|
136
|
+
forecast = model.fit(dataset).predict(24)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The intent is to let Anomx expose Darts-backed forecasting and anomaly workflows
|
|
140
|
+
without making Darts a required dependency for every user.
|
|
141
|
+
|
|
142
|
+
## Development
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
python -m pip install -e ".[dev]"
|
|
146
|
+
pytest
|
|
147
|
+
ruff check .
|
|
148
|
+
mypy src/anomx
|
|
149
|
+
python -m pip install -e ".[release]"
|
|
150
|
+
python -m build
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Platform Context
|
|
154
|
+
|
|
155
|
+
Anomx prioritizes:
|
|
156
|
+
|
|
157
|
+
- Signal over noise: surface only relevant insights.
|
|
158
|
+
- Clarity over complexity: outputs should be interpretable.
|
|
159
|
+
- Actionability: every insight should support a decision.
|
|
160
|
+
|
|
161
|
+
The platform is designed around modular pipelines, real-time and batch workers,
|
|
162
|
+
heterogeneous data sources, and versioned entities such as datasets, datasources,
|
|
163
|
+
channels, jobs, runs, findings, and model artifacts. This library is the focused
|
|
164
|
+
modeling and time-series package used by that larger system.
|
|
165
|
+
|
|
166
|
+
## Status
|
|
167
|
+
|
|
168
|
+
This repository is in pre-alpha scaffold stage. The public API should be treated
|
|
169
|
+
as provisional until the first stable release.
|
anomx-0.2.0/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# anomx
|
|
2
|
+
|
|
3
|
+
`anomx` is the core Python library for the Anomx platform: time-series datasets,
|
|
4
|
+
forecasting models, anomaly scorers, and anomaly detectors built for interpretable,
|
|
5
|
+
production-oriented workflows.
|
|
6
|
+
|
|
7
|
+
Anomx is a data intelligence platform focused on anomaly detection and predictive
|
|
8
|
+
insights in complex, data-driven systems. The platform handles orchestration,
|
|
9
|
+
workers, storage, connectors, audit trails, and human-in-the-loop feedback. This
|
|
10
|
+
repository contains the reusable modeling layer that those systems compose.
|
|
11
|
+
|
|
12
|
+
## Goals
|
|
13
|
+
|
|
14
|
+
- Provide clean primitives for time-series datasets, scorers, detectors, and models.
|
|
15
|
+
- Support both batch and online anomaly detection workflows.
|
|
16
|
+
- Keep outputs interpretable: scores, thresholds, timestamps, labels, and metadata.
|
|
17
|
+
- Stay modular enough to power the Anomx platform without coupling the library to
|
|
18
|
+
the platform's storage or orchestration layer.
|
|
19
|
+
- Integrate with the broader time-series ecosystem, especially Darts, through
|
|
20
|
+
optional adapters.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
The package is structured for PyPI distribution:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install anomx
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
For local development:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/anomx/anomx.git
|
|
34
|
+
cd anomx
|
|
35
|
+
python -m pip install -e ".[dev]"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Optional extras:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install "anomx[darts]" # Darts forecasting model adapters
|
|
42
|
+
pip install "anomx[docs]" # Documentation tooling
|
|
43
|
+
pip install "anomx[platform]" # Platform-facing IO dependencies
|
|
44
|
+
pip install "anomx[release]" # Build and PyPI publishing tooling
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Package Layout
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
src/anomx/
|
|
51
|
+
datasets/ TimeSeriesDataset, metadata, dataset loaders, transforms
|
|
52
|
+
scorers/ Anomaly score contracts and scoring implementations
|
|
53
|
+
detectors/ Batch and online anomaly detector contracts and implementations
|
|
54
|
+
models/ Forecasting model contracts and baseline forecasters
|
|
55
|
+
integrations/ Optional adapters, including Darts
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from anomx.datasets import make_sine_anomaly_dataset
|
|
62
|
+
from anomx.detectors import MovingAverageDetector
|
|
63
|
+
from anomx.models import NaiveSeasonalModel
|
|
64
|
+
|
|
65
|
+
dataset = make_sine_anomaly_dataset()
|
|
66
|
+
|
|
67
|
+
detector = MovingAverageDetector(window=24, threshold=3.0)
|
|
68
|
+
result = detector.fit_predict(dataset)
|
|
69
|
+
print(result.to_dataframe().tail())
|
|
70
|
+
|
|
71
|
+
model = NaiveSeasonalModel(season_length=24).fit(dataset)
|
|
72
|
+
forecast = model.predict(12)
|
|
73
|
+
print(forecast.to_dataframe())
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Darts Integration
|
|
77
|
+
|
|
78
|
+
The default install stays lightweight. To use Darts models, install the optional
|
|
79
|
+
extra and wrap any compatible Darts forecasting model:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from darts.models import ExponentialSmoothing
|
|
83
|
+
|
|
84
|
+
from anomx.datasets import make_sine_anomaly_dataset
|
|
85
|
+
from anomx.integrations import DartsForecastingModel
|
|
86
|
+
|
|
87
|
+
dataset = make_sine_anomaly_dataset()
|
|
88
|
+
model = DartsForecastingModel(ExponentialSmoothing())
|
|
89
|
+
forecast = model.fit(dataset).predict(24)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The intent is to let Anomx expose Darts-backed forecasting and anomaly workflows
|
|
93
|
+
without making Darts a required dependency for every user.
|
|
94
|
+
|
|
95
|
+
## Development
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
python -m pip install -e ".[dev]"
|
|
99
|
+
pytest
|
|
100
|
+
ruff check .
|
|
101
|
+
mypy src/anomx
|
|
102
|
+
python -m pip install -e ".[release]"
|
|
103
|
+
python -m build
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Platform Context
|
|
107
|
+
|
|
108
|
+
Anomx prioritizes:
|
|
109
|
+
|
|
110
|
+
- Signal over noise: surface only relevant insights.
|
|
111
|
+
- Clarity over complexity: outputs should be interpretable.
|
|
112
|
+
- Actionability: every insight should support a decision.
|
|
113
|
+
|
|
114
|
+
The platform is designed around modular pipelines, real-time and batch workers,
|
|
115
|
+
heterogeneous data sources, and versioned entities such as datasets, datasources,
|
|
116
|
+
channels, jobs, runs, findings, and model artifacts. This library is the focused
|
|
117
|
+
modeling and time-series package used by that larger system.
|
|
118
|
+
|
|
119
|
+
## Status
|
|
120
|
+
|
|
121
|
+
This repository is in pre-alpha scaffold stage. The public API should be treated
|
|
122
|
+
as provisional until the first stable release.
|
anomx-0.2.0/docs/api.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# API Outline
|
|
2
|
+
|
|
3
|
+
## Datasets
|
|
4
|
+
|
|
5
|
+
- `anomx.datasets.TimeSeriesDataset`
|
|
6
|
+
- `anomx.datasets.ChannelMetadata`
|
|
7
|
+
- `anomx.datasets.make_sine_anomaly_dataset`
|
|
8
|
+
|
|
9
|
+
## Scorers
|
|
10
|
+
|
|
11
|
+
- `anomx.scorers.AnomalyScorer`
|
|
12
|
+
- `anomx.scorers.ZScoreScorer`
|
|
13
|
+
- `anomx.scorers.ThresholdScorer`
|
|
14
|
+
|
|
15
|
+
## Detectors
|
|
16
|
+
|
|
17
|
+
- `anomx.detectors.AnomalyDetector`
|
|
18
|
+
- `anomx.detectors.DetectionResult`
|
|
19
|
+
- `anomx.detectors.MovingAverageDetector`
|
|
20
|
+
|
|
21
|
+
## Models
|
|
22
|
+
|
|
23
|
+
- `anomx.models.ForecastingModel`
|
|
24
|
+
- `anomx.models.Forecast`
|
|
25
|
+
- `anomx.models.NaiveSeasonalModel`
|
|
26
|
+
|
|
27
|
+
## Integrations
|
|
28
|
+
|
|
29
|
+
- `anomx.integrations.DartsForecastingModel`
|
|
30
|
+
- `anomx.integrations.is_darts_available`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Anomx
|
|
2
|
+
|
|
3
|
+
Anomx is a Python library for time-series datasets, forecasting models, anomaly
|
|
4
|
+
scorers, and anomaly detectors.
|
|
5
|
+
|
|
6
|
+
The library is designed to be the modeling core for the Anomx platform while
|
|
7
|
+
remaining useful as a standalone package.
|
|
8
|
+
|
|
9
|
+
## Main Concepts
|
|
10
|
+
|
|
11
|
+
- `TimeSeriesDataset`: a typed wrapper around timestamp-indexed data and metadata.
|
|
12
|
+
- `AnomalyScorer`: converts observations or residuals into anomaly scores.
|
|
13
|
+
- `AnomalyDetector`: converts datasets into scores and anomaly labels.
|
|
14
|
+
- `ForecastingModel`: produces future values for a time horizon.
|
|
15
|
+
- `DartsForecastingModel`: optional adapter for Darts models.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Run a baseline anomaly detector on a synthetic dataset."""
|
|
2
|
+
|
|
3
|
+
from anomx.datasets import make_sine_anomaly_dataset
|
|
4
|
+
from anomx.detectors import MovingAverageDetector
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def main() -> None:
|
|
8
|
+
dataset = make_sine_anomaly_dataset()
|
|
9
|
+
detector = MovingAverageDetector(window=24, threshold=3.0)
|
|
10
|
+
result = detector.fit_predict(dataset)
|
|
11
|
+
print(result.to_dataframe().query("is_anomaly").head())
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if __name__ == "__main__":
|
|
15
|
+
main()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Fit a naive seasonal forecast model."""
|
|
2
|
+
|
|
3
|
+
from anomx.datasets import make_sine_anomaly_dataset
|
|
4
|
+
from anomx.models import NaiveSeasonalModel
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def main() -> None:
|
|
8
|
+
dataset = make_sine_anomaly_dataset()
|
|
9
|
+
model = NaiveSeasonalModel(season_length=24).fit(dataset)
|
|
10
|
+
forecast = model.predict(12)
|
|
11
|
+
print(forecast.to_dataframe())
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if __name__ == "__main__":
|
|
15
|
+
main()
|
anomx-0.2.0/mkdocs.yml
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.25"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "anomx"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Installable time-series anomaly library with forecasting, reconstruction, and representation base approaches."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Theo Rieken" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"anomaly-detection",
|
|
17
|
+
"forecasting",
|
|
18
|
+
"time-series",
|
|
19
|
+
"machine-learning",
|
|
20
|
+
"observability",
|
|
21
|
+
"data-intelligence"
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"Intended Audience :: Science/Research",
|
|
27
|
+
"License :: OSI Approved :: Apache Software License",
|
|
28
|
+
"Programming Language :: Python :: 3",
|
|
29
|
+
"Programming Language :: Python :: 3.11",
|
|
30
|
+
"Programming Language :: Python :: 3.12",
|
|
31
|
+
"Programming Language :: Python :: 3.13",
|
|
32
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
33
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
34
|
+
"Typing :: Typed"
|
|
35
|
+
]
|
|
36
|
+
dependencies = [
|
|
37
|
+
"numpy>=1.24",
|
|
38
|
+
"pandas>=2.0",
|
|
39
|
+
"scikit-learn>=1.3"
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[project.optional-dependencies]
|
|
43
|
+
darts = [
|
|
44
|
+
"u8darts[all]>=0.30"
|
|
45
|
+
]
|
|
46
|
+
dev = [
|
|
47
|
+
"mypy>=1.10",
|
|
48
|
+
"pandas-stubs>=2.2",
|
|
49
|
+
"pytest>=8.0",
|
|
50
|
+
"pytest-cov>=5.0",
|
|
51
|
+
"ruff>=0.5"
|
|
52
|
+
]
|
|
53
|
+
release = [
|
|
54
|
+
"build>=1.2",
|
|
55
|
+
"docutils>=0.21.2,<0.22",
|
|
56
|
+
"twine>=6.2,<7.0"
|
|
57
|
+
]
|
|
58
|
+
docs = [
|
|
59
|
+
"mkdocs>=1.6",
|
|
60
|
+
"mkdocs-material>=9.5"
|
|
61
|
+
]
|
|
62
|
+
platform = [
|
|
63
|
+
"fsspec>=2024.6",
|
|
64
|
+
"pyarrow>=16.0",
|
|
65
|
+
"redis>=5.0"
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
[project.urls]
|
|
69
|
+
Homepage = "https://www.anomx.io"
|
|
70
|
+
Repository = "https://github.com/theorieken/anomx"
|
|
71
|
+
Issues = "https://github.com/theorieken/anomx/issues"
|
|
72
|
+
|
|
73
|
+
[project.scripts]
|
|
74
|
+
anomx = "anomx.cli:main"
|
|
75
|
+
|
|
76
|
+
[tool.hatch.build.targets.wheel]
|
|
77
|
+
packages = ["src/anomx"]
|
|
78
|
+
|
|
79
|
+
[tool.hatch.build.targets.wheel.force-include]
|
|
80
|
+
"src/anomx/py.typed" = "anomx/py.typed"
|
|
81
|
+
|
|
82
|
+
[tool.pytest.ini_options]
|
|
83
|
+
addopts = "-ra"
|
|
84
|
+
testpaths = ["tests"]
|
|
85
|
+
|
|
86
|
+
[tool.ruff]
|
|
87
|
+
line-length = 100
|
|
88
|
+
target-version = "py311"
|
|
89
|
+
src = ["src", "tests"]
|
|
90
|
+
|
|
91
|
+
[tool.ruff.lint]
|
|
92
|
+
select = [
|
|
93
|
+
"E",
|
|
94
|
+
"F",
|
|
95
|
+
"I",
|
|
96
|
+
"UP",
|
|
97
|
+
"B",
|
|
98
|
+
"SIM",
|
|
99
|
+
"ANN"
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
[tool.ruff.lint.per-file-ignores]
|
|
103
|
+
"tests/**/*.py" = ["ANN"]
|
|
104
|
+
|
|
105
|
+
[tool.mypy]
|
|
106
|
+
python_version = "3.11"
|
|
107
|
+
files = ["src/anomx"]
|
|
108
|
+
strict = true
|
|
109
|
+
warn_unused_ignores = true
|
|
110
|
+
warn_redundant_casts = true
|
|
111
|
+
|
|
112
|
+
[tool.coverage.run]
|
|
113
|
+
branch = true
|
|
114
|
+
source = ["anomx"]
|
|
115
|
+
|
|
116
|
+
[tool.coverage.report]
|
|
117
|
+
show_missing = true
|
|
118
|
+
skip_covered = true
|