Series2Graph++ logo # Series2Graph++ [![release info](https://img.shields.io/badge/Release-1.0.2-blue)](https://gitlab.hpi.de/phillip.wenig/s2gpp/-/releases/1.0.2) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![pipeline status](https://gitlab.hpi.de/akita/s2gpp/badges/main/pipeline.svg)](https://gitlab.hpi.de/akita/s2gpp/-/commits/main) [![dependency status](https://deps.rs/crate/s2gpp/1.0.2/status.svg)](https://deps.rs/crate/s2gpp/1.0.2)

Series2Graph++ (S2G++) is a time series anomaly detection algorithm based on the Series2Graph (S2G) and the DADS algorithms. S2G++ can handle multivariate time series whereas S2G and DADS can cope with only univariate time series. Moreover, S2G++ takes ideas from DADS to run distributedly in a computer cluster. S2G++ is written in Rust and leverages the actix and actix-telepathy libraries.

Quick Start

Requirements

To have openblas available to the Rust build process, do the following on Debian (Linux):

shell sudo apt install build-essential gfortran libopenblas-base libopenblas-dev gcc

Installation

From source

shell git pull https://gitlab.hpi.de/akita/s2gpp cd s2gpp cargo build

Docker

The base image akita/rust-base must be available to your machine.

shell git pull https://gitlab.hpi.de/akita/s2gpp cd s2gpp docker build s2gpp .

Usage (bin)

Parameters

Pattern: shell s2gpp --local-host <IP:Port> --pattern-length <Int> --latent <Int> --query-length <Int> --rate <Int> --threads <Int> --cluster-nodes <Int> --score-output-path <Path> [main --data-path <Path> | sub --mainhost <IP:Port>]

S2G++ expects one of two sub-commands with its specific parameters:

Before these sub-commands are used, general parameters must be defined:

Input Format

The input format of the time series is expected to be a CSV with header. Each column represents a channel of the timeseries. Sometimes, time series files include also the labels and an index. You can skip columns with the column-start-idx / column-end-idx range pattern. It behave like Python ranges.

Usage (lib)

Cargo.toml toml [dependencies] s2gpp = "1.0.2"

your Rust app

rust fn some_fn(timeseries: Array2<f32>) -> Result<Array1<f32>, ()> { let params = s2gpp::Parameters::default(); let anomaly_score = s2gpp::s2gpp(params, Some(timeseries))?.unwrap(); Ok(anomaly_score) }

Python

We have wrapped the Rust code in a Python package, that can be used without installing Rust.

Installation

PyPI

shell pip install s2gpp

Build with Docker

shell make build-docker pip install wheels/s2gpp-*.whl

Build from Source

shell make install

Usage

Single Machine

```python from s2gpp import Series2GraphPP import pandas as pd

ts = pd.readcsv("data/ts0.csv").values

model = Series2GraphPP(patternlength=100) anomalyscores = model.fit_predict(ts) ```

Distributed

```python from s2gpp import DistributedSeries2GraphPP from pathlib import Path

run on one machine

def mainnode(): datasetpath = Path("data/ts_0.csv")

model = DistributedSeries2GraphPP.main(local_host="127.0.0.1:1992", n_cluster_nodes=2, pattern_length=100)
model.fit_predict(dataset_path)

run on other machine

def subnode(): model = DistributedSeries2GraphPP.sub(localhost="127.0.0.1:1993", mainhost="127.0.0.1:1992", nclusternodes=2, patternlength=100) model.fitpredict() ```

Cite

Please cite this work, when using it!

bibtex @software{Wenig_Series2Graph_2022, author = {Wenig, Phillip}, month = {6}, title = {{Series2Graph++}}, version = {1.0.2}, year = {2022} }

References

[1] P. Boniol and T. Palpanas, Series2Graph: Graph-based Subsequence Anomaly Detection in Time Series, PVLDB (2020) link

[2] Schneider, J., Wenig, P. & Papenbrock, T. Distributed detection of sequential anomalies in univariate time series. The VLDB Journal 30, 579–602 (2021). link