Home

Awesome

<!-- Improved compatibility of back to top link: See: https://github.com/othneildrew/Best-README-Template/pull/73 -->

<a name="readme-top"></a>

<!-- *** Thanks for checking out the Best-README-Template. If you have a suggestion *** that would make this better, please fork the repo and create a pull request *** or simply open an issue with the tag "enhancement". *** Don't forget to give the project a star! *** Thanks again! Now go create something AMAZING! :D --> <!-- PROJECT SHIELDS --> <!-- *** I'm using markdown "reference style" links for readability. *** Reference links are enclosed in brackets [ ] instead of parentheses ( ). *** See the bottom of this document for the declaration of the reference variables *** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use. *** https://www.markdownguide.org/basic-syntax/#reference-style-links -->

Contributors Stargazers Issues Apache 2.0 License Last Commit

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/georgian-io/oats"> <img src="https://github.com/georgian-io/pyoats/raw/main/static/oats.png" alt="Logo" width="auto" height="80"> </a> <h3 align="center"> OATS</h3> <p align="center"> Quick and Easy Outlier Detection for Time Series <br /> <a href="https://georgian-io-archive.github.io/pyoats-docs/"><strong>Explore the docs »</strong></a> <br /> <br /> <a href="https://georgian-io.medium.com/time-series-anomaly-detection-a-field-study-d13b35ee4344">View Demo</a> · <a href="https://github.com/georgian-io/pyoats/issues">Report Bug</a> · <a href="https://github.com/georgian-io/pyoats/issues">Request Feature</a> </p> </div> <!-- TABLE OF CONTENTS --> <details> <summary>Table of Contents</summary> <ol> <li> <a href="#about-the-project">About The Project</a> <ul> <li><a href="#built-with">Built With</a></li> </ul> </li> <li> <a href="#getting-started">Getting Started</a> <ul> <li><a href="#prerequisites">Prerequisites</a></li> <li><a href="#installation">Installation</a></li> </ul> </li> <li><a href="#usage">Usage</a></li> <li><a href="#models">Models</a></li> <li><a href="#roadmap">Roadmap</a></li> <li><a href="#contributing">Contributing</a></li> <li><a href="#license">License</a></li> <li><a href="#contact">Contact</a></li> <li><a href="#acknowledgments">Acknowledgments</a></li> </ol> </details> <!-- ABOUT THE PROJECT -->

About The Project

Adapting existing outlier detection & prediction methods into a time series outlier detection system is not a simple task. Good news: OATS has done the heavy lifting for you!

We present a straight-forward interface for popular, state-of-the-art detection methods to assist you in your experiments. In addition to the models, we also present different options when it comes to selecting a final threshold for predictions.

OATS seamlessly supports both univariate and multivariate time series regardless of the model choice and guarantees the same output shape, enabling a modular approach to time series anoamly detection.

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Built With

Python Poetry

Pytorch PytorchLightning TensorFlow Numpy

Darts PyOD

<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- GETTING STARTED -->

Getting Started

<br /> <div align="center"> <img src="https://github.com/georgian-io/pyoats/raw/main/static/example-sine_wave.png" alt="Usage Example" width="600" height="auto"> </a> </div>

Prerequisites

Python >=3.8, <3.11

For Docker Install:

Docker

For Local Install:

Poetry

Installation

PyPI

  1. Install package via pip
    pip install pyoats
    
    ❗ Installing using an environment manager such as conda, venv, and poetry is highly encouraged as this package contains deep learning frameworks.

Docker

  1. Clone the repo
    git clone https://github.com/georgian-io/pyoats.git && cd pyoats 
    
  2. Build image
    docker build -t pyoats . 
    
  3. Run Container
    # CPU Only
    docker run -it pyoats
    
    # with GPU
    docker run -it --gpus all pyoats
    

Local

  1. Clone the repo
    git clone https://github.com/georgian-io/pyoats.git && cd pyoats 
    
  2. Install via Poetry
    poetry install
    
<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- USAGE EXAMPLES -->

Usage

Quick Start

For a quick start, please refer to <a href="https://medium.com/@georgian-io/time-series-anomaly-detection-a-field-study-d13b35ee4344">our blog</a> or copy our <a href="https://tinyurl.com/pyoats-notebook">Colab notebook</a>!

Getting Anomaly Score

from oats.models import NHiTSModel

model = NHiTSModel(window=20, use_gpu=True)
model.fit(train)
scores = model.get_scores(test)

Getting Threshold

from oats.threshold import QuantileThreshold

t = QuantileThreshold()
threshold = t.get_threshold(scores, 0.99)
anom = scores > threshold

For more examples, please refer to the Documentation

<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- Models -->

Models

For more details about the individual models, please refer to the Documentation or <a href="https://medium.com/georgian-impact-blog/time-series-anomaly-detection-the-detectives-toolbox-9ef131dddaf9">this blog</a> for deeper explanation.

ModelTypeMultivariate Support*Requires FittingDL Framework DependencyPaperReference Model
ARIMAPredictive⚠️statsmodels.ARIMA
FluxEVPredictive⚠️📝
LightGBMPredictive⚠️darts.LightGBM
Moving AveragePredictive⚠️
N-BEATSPredictivePytorch📝darts.NBEATS
N-HiTSPredictivePytorch📝darts.NHiTS
RandomForestPredictive⚠️darts.RandomForest
RegressionPredictive⚠️darts.Regression
RNNPredictivePytorchdarts.RNN
Temporal Convolution NetworkPredictivePytorch📝darts.TCN
Temporal Fusion TransformersPredictivePytorch📝darts.TFT
TransformerPredictivePytorch📝darts.Transformer
Isolation ForestDistance-Basedpyod.IForest
Matrix ProfileDistance-Based📝stumpy
TranADReconstruction-BasedTensorFlow📝tranad
Variational AutoencoderReconstruction-BasedTensorFlow📝pyod.VAE
QuantileRule-Based⚠️

* For models with ⚠️, score calculation is done separately along each column. This implicitly assumes independence of covariates, which means that the resultant anomaly scores do not take into account of inter-variable dependency structures.

<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- ROADMAP -->

Roadmap

See the open issues for a full list of proposed features (and known issues).

<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- CONTRIBUTING -->

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/amazing_feature)
  3. Commit your Changes (git commit -m 'Add some amazing_feature')
  4. Push to the Branch (git push origin feature/amazing_feature)
  5. Open a Pull Request
<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- LICENSE -->

License

Distributed under the Apache 2.0 License. See LICENSE for more information.

<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- CONTACT -->

Contact

<div align="left"> <a href="https://www.georgian.io"> <img src="https://s34372.pcdn.co/wp-content/uploads/2022/03/Georgian_Blue.png" alt="Logo" width="auto" height="80"> </a> </div>
<!-- --><!-- --><!-- --><!-- -->
Benjamin YeGithubLinkedIneMail

Project Link: https://github.com/georgian-io/oats

<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- ACKNOWLEDGMENTS -->

Acknowledgments

I would like to thank my colleagues from Georgian for all the help and advice provided along the way.

I'd also like to extend my gratitude to all the contributors at Darts (for time series predictions) and PyOD (for general outlier detection), whose projects have enabled a straight-forward extension into the domain of time series anomaly detection.

Finally, it'll be remiss of me to not mention DATA Lab @ Rice University, whose wonderful TODS package served as a major inspiration for this project. Please check them out especially if you're looking for AutoML support.

Darts PyOD TODS

<p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- MARKDOWN LINKS & IMAGES --> <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --> <!-- Deps Links -->