Skip to content

Open-source library for probabilistic anomaly detection in time series

License

Notifications You must be signed in to change notification settings

Bayes-Works/canari

Repository files navigation

What is Canari?

Canari is an open-source library for online change point detection in univariate time series. It has been developed in the context of long-term online monitoring where we aim for the early detection of subtle change points in the baseline response, while limiting to a minimum the number of false alarms.

Because Canari’s probabilistic change-point detection relies on 1-step ahead predictions, it is inherently capable of performing short- and long-term forecasting, as well as online data imputation; One-step ahead predictions can either rely solely on a target time series, or on explanatory time series that can be non-linearly related to the target.

In addition to change-point detection and forecasting capabilities, it returns an interpretable decomposition of time series into baseline components representing the irreversible responses, recurrent pattern components caused by external effects, and residual components allowing the characterization of both the model prediction and the observation uncertainties.

How does it work?

Canari SSM LSTM

The methodological core behind the canary library consists of a seamless integration between state-space models (SSM) and Bayesian neural networks. On the one hand, the Gaussian SSM theory enables modelling baseline responses and residuals, while on the other, Tractable Approximate Gaussian Inference (TAGI) also enables treating all parameters and hidden states in neural networks as Gaussians.

Canari uses LSTM neural networks to model recurrent patterns as well as non-linear dependencies with respect to explanatory variables. Because both the SSM and LSTM rely on the same Gaussian conditional inference mechanism, their hidden states can be inferred analytically in a same unified probabilistic framework.

Canari example

The figure above presents an example where the raw data in red is decomposed in a baseline that is characterized by a baseline “level” component where its rate of change is described by the “trend”. The recurrent pattern is modelled by a LSTM Bayesian neural network where the training and validation set consists only in 4 years of data. The residual characterizing the model errors is itself modelled by a white “noise” component. The change point detection can be performed either online or offline after the training and validation period; The presence of change points is indicated by the probability of regime switches that rise toward 1 on several occasions.

Getting started

You can get started with Canari by going through our tutorials covering all the main features of the library.

Installation

Canari available on PyPI, for installation, execute the following command in Terminal:

pip install pycanari

For more info. on how to install, visit our installation guide.

Contributors

The principal developer of canary is Van Dai Vuong with the mentoring of Luong Ha Nguyen and oversight by James-A. Goulet. The major contributors to the library are:

  • Zhanwen Xin (Online AR, Bounded AR & several+++ bug fixes through PRs)
  • David Wardan (SLSTM component & several+++ bug fixes through PRs)

Acknowledgements

We acknowledge the financial support from Hydro-Québec and the Natural Sciences and Engineering Research Council of Canada in the development of the Canari library.

License

Canari is released under the MIT license. THIS IS AN OPEN SOURCE SOFTWARE FOR RESEARCH PURPOSES ONLY. THIS IS NOT A PRODUCT. NO WARRANTY EXPRESSED OR IMPLIED.

Related references

Papers

Theses

*Analytically Tractable Bayesian Recurrent Neural Networks with Structural Health Monitoring Applications (Van-Dai Vuong, 2024)

Book chapter

About

Open-source library for probabilistic anomaly detection in time series

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 6

Languages