Skip to content

ONAD: Online Anomaly Detection Toolkit

Python License GitHub

ONAD is a comprehensive Python toolkit for Online Anomaly Detection, designed for real-time streaming data analysis. It provides state-of-the-art algorithms and utilities for detecting anomalies in continuous data streams with minimal latency and memory footprint.

πŸš€ Key Features

Streaming-First Design

  • Low Memory Footprint: Designed for constant memory usage regardless of stream length
  • Real-time Processing: Process data points as they arrive with minimal latency
  • Incremental Learning: Models adapt and learn from new data without full retraining

Comprehensive Algorithm Library

  • Forest-based Models: Online Isolation Forest, Mondrian Forest
  • SVM-based Models: Adaptive SVM, GADGET SVM with graph structures
  • Statistical Models: Moving averages, covariance analysis, Mahalanobis distance
  • Distance-based Models: K-Nearest Neighbors, similarity search engines

Flexible Pipeline System

  • Modular Architecture: Compose complex detection pipelines from simple components
  • Data Transformers: Built-in scaling, PCA, and preprocessing utilities
  • Stream Processing: Efficient data streaming with configurable batch processing

Production-Ready

  • Memory Management: Configurable memory limits and automatic cleanup
  • Robust Error Handling: Comprehensive validation and graceful failure recovery
  • Extensive Logging: Detailed logging for monitoring and debugging
  • Type Safety: Full type hints for better IDE support and code reliability

🎯 Use Cases

  • IoT Sensor Monitoring: Detect anomalies in sensor readings from industrial equipment
  • Network Security: Identify unusual network traffic patterns and potential threats
  • Financial Fraud Detection: Monitor transactions for fraudulent activities
  • System Monitoring: Detect performance anomalies in server metrics
  • Quality Control: Identify defective products in manufacturing processes

πŸ“¦ Quick Installation

# Basic installation
pip install onad

# With evaluation tools
pip install onad[eval]

# With deep learning support
pip install onad[dl]

# Full installation with all features
pip install onad[all]

πŸƒβ€β™‚οΈ Quick Start

Here's a simple example to get you started:

from onad.model.iforest import OnlineIsolationForest
from onad.stream import ParquetStreamer, Dataset

# Initialize the model
model = OnlineIsolationForest(
    num_trees=100,
    window_size=1000,
    max_leaf_samples=32
)

# Stream data and detect anomalies
with ParquetStreamer(Dataset.FRAUD) as streamer:
    for features, label in streamer:
        # Learn from the data point
        model.learn_one(features)

        # Get anomaly score
        score = model.score_one(features)

        # Check if it's an anomaly
        if score > 0.7:  # threshold
            print(f"Anomaly detected! Score: {score:.3f}")

πŸ—οΈ Architecture Overview

ONAD follows a modular architecture with clear separation of concerns:

onad/
β”œβ”€β”€ base/           # Abstract base classes and interfaces
β”œβ”€β”€ model/          # Anomaly detection algorithms
β”‚   β”œβ”€β”€ unsupervised/   # Unsupervised learning models
β”‚   β”œβ”€β”€ supervised/     # Supervised learning models
β”‚   └── statistics/     # Statistical methods
β”œβ”€β”€ transform/      # Data preprocessing and transformation
β”œβ”€β”€ stream/         # Data streaming and I/O utilities
└── utils/          # Helper functions and utilities

πŸ“š What's Next?

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details on how to:

  • Report bugs and request features
  • Submit code contributions
  • Improve documentation
  • Share examples and use cases

πŸ“„ License

This project is licensed under the BSD License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Authors: Oliver Hennhoefer, Pascal Heinzelmann, Marius HΓΆll, Marco Catoir
  • Maintainer: Oliver Hennhoefer
  • Built with ❀️ for the anomaly detection community

Getting Help