A Python-based service for detecting anomalies in time series data using Random Cut Forest and Isolation Forest algorithms.
- REST API endpoints for training and inference
- Support for multiple anomaly detection algorithms:
- Random Cut Forest (AWS)
- Isolation Forest
- Integration with NAB (Numenta Anomaly Benchmark) datasets
- Easy-to-use training and prediction interfaces
anomaly_detection/
├── api/ # FastAPI endpoints
├── core/ # Core anomaly detection logic
├── data/ # Data processing and loading
├── models/ # Model implementations
├── utils/ # Utility functions
└── tests/ # Test suite
- Create a virtual environment:
python -m venv ./.venv
source ./.venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
cp .env.example .env
# Edit .env with your AWS credentials if using RCF
- Start the API server:
uvicorn anomaly_detection.api.main:app --reload
- Train a model:
curl -X POST "http://localhost:8000/train" -H "Content-Type: application/json" -d '{"algorithm": "isolation_forest", "data_path": "path/to/data.csv"}'
- Make predictions:
curl -X POST "http://localhost:8000/predict" -H "Content-Type: application/json" -d '{"algorithm": "isolation_forest", "data": [1.2, 2.3, 3.4]}'
Run tests with coverage:
pytest --cov=anomaly_detection tests/
MIT