Metadata-Version: 2.4
Name: anomaly-grid-py
Version: 0.4.0
Requires-Dist: numpy>=1.20.0
Requires-Dist: pytest>=6.0 ; extra == 'dev'
Requires-Dist: maturin>=1.0 ; extra == 'dev'
Requires-Dist: psutil ; extra == 'dev'
Requires-Dist: psutil ; extra == 'benchmarks'
Requires-Dist: matplotlib ; extra == 'benchmarks'
Requires-Dist: sphinx>=5.0 ; extra == 'docs'
Requires-Dist: sphinx-rtd-theme>=1.0 ; extra == 'docs'
Requires-Dist: myst-parser>=0.18 ; extra == 'docs'
Requires-Dist: pytest>=6.0 ; extra == 'test'
Requires-Dist: pytest-benchmark>=4.0 ; extra == 'test'
Provides-Extra: dev
Provides-Extra: benchmarks
Provides-Extra: docs
Provides-Extra: test
License-File: LICENSE
Summary: High-performance sequence anomaly detection with minimal dependencies
Author-email: Juan Abimael Santos Castillo <juanabimael@gmail.com>
License: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/abimael10/anomaly-grid-py
Project-URL: Repository, https://github.com/abimael10/anomaly-grid-py
Project-URL: Bug Tracker, https://github.com/abimael10/anomaly-grid-py/issues

# Anomaly Grid Python

[![PyPI version](https://badge.fury.io/py/anomaly-grid-py.svg)](https://badge.fury.io/py/anomaly-grid-py)
[![Python versions](https://img.shields.io/pypi/pyversions/anomaly-grid-py.svg)](https://pypi.org/project/anomaly-grid-py/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Downloads](https://img.shields.io/pypi/dm/anomaly-grid-py.svg)](https://pypi.org/project/anomaly-grid-py/)

Sequence anomaly detection using Markov models.

## Installation

```bash
pip install anomaly-grid-py
```

## Usage

```python
import anomaly_grid_py

# Create detector
detector = anomaly_grid_py.AnomalyDetector(max_order=3)

# Train on normal sequences
normal_sequences = [
    ['A', 'B', 'C'],
    ['A', 'B', 'D'],
    ['A', 'C', 'D']
] * 50  # Need enough data for training

detector.fit(normal_sequences)

# Get anomaly scores
test_sequences = [
    ['A', 'B', 'C'],  # Normal
    ['X', 'Y', 'Z']   # Anomalous
]

scores = detector.predict_proba(test_sequences)
print(scores)  # [0.26, 0.62] - higher = more anomalous

# Binary predictions
anomalies = detector.predict(test_sequences, threshold=0.5)
print(anomalies)  # [False, True]
```

## API

```python
# Create detector
AnomalyDetector(max_order=3)

# Train on normal sequences
detector.fit(sequences)

# Get anomaly scores [0,1]
detector.predict_proba(sequences)

# Get binary predictions
detector.predict(sequences, threshold=0.5)

# Get model info
detector.get_performance_metrics()
```

## Requirements

- Python 3.8+
- NumPy

## Development

```bash
git clone https://github.com/abimael10/anomaly-grid-py.git
cd anomaly-grid-py
./setup.sh
source venv/bin/activate
pytest tests/
```

## License

MIT
