Skip to content

project-delphi/anomaly_detection

Repository files navigation

Anomaly Detection Service

A Python-based service for detecting anomalies in time series data using Random Cut Forest and Isolation Forest algorithms.

Features

  • 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

Project Structure

anomaly_detection/
├── api/           # FastAPI endpoints
├── core/          # Core anomaly detection logic
├── data/          # Data processing and loading
├── models/        # Model implementations
├── utils/         # Utility functions
└── tests/         # Test suite

Setup

  1. Create a virtual environment:
python -m venv ./.venv
source ./.venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables:
cp .env.example .env
# Edit .env with your AWS credentials if using RCF

Usage

  1. Start the API server:
uvicorn anomaly_detection.api.main:app --reload
  1. 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"}'
  1. 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]}'

Testing

Run tests with coverage:

pytest --cov=anomaly_detection tests/

License

MIT

About

anomaly detection using isolation forests and random cut forests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published