Package: s2gpp
Series2Graph++Series2Graph++(S2G++) is a time series anomaly detection algorithm based on theSeries2Graph(S2G) and theDADSalgorithms.
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 inRustand leverages theactixandactix-telepathylibraries.Quick StartRequirementsRust 1.58openblas(Docker)To haveopenblasavailable to the Rust build process, do the following on Debian (Linux):sudoaptinstallbuild-essentialgfortranlibopenblas-baselibopenblas-devgccInstallationFrom sourcegitpullhttps://gitlab.hpi.de/akita/s2gppcds2gpp
cargobuildDockerThe base imageakita/rust-basemust be available to your machine.gitpullhttps://gitlab.hpi.de/akita/s2gppcds2gpp
dockerbuilds2gpp.Usage (bin)ParametersPattern: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:main(The head computer in a cluster)data-path(The path to the input time series)sub(The other computers in a cluster; only necessary in a distributed setting)mainhost(The ip-address to the main computer in a cluster)Before these sub-commands are used, general parameters must be defined:local-host(The ip-address with port to bind the listener on.)pattern-length(Size of the sliding window, independent of anomaly length, but should in the best case be larger.)latent(Size of latent embedding space. This space is the input for the PCA calculation afterwards.)query-length(Size of the sliding windows used to find anomalies (query subsequences). query-length must be >= pattern-length!)rate(Number of angles used to extract pattern nodes. A higher value will lead to high precision, but at the cost of increased computation time.)threads(Number of helper threads started besides the main thread. (min=1))cluster-nodes(Size of the computer cluster.)score-output-path(Path the score are written to.)column-start-idx(How many columns to skip)column-end-idx(Until which column to use (exclusive). Can also take negative numbers to count from the end.)self-correction(Whether S2G++ will correct the direction of the time embedding if too few
transactions are available)Input FormatThe 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 thecolumn-start-idx/column-end-idxrange pattern. It behave like Python ranges.Usage (lib)Cargo.toml[dependencies]s2gpp="1.0.2"your Rust appfnsome_fn(timeseries:Array2<f32>)->Result<Array1<f32>,()>{letparams=s2gpp::Parameters::default();letanomaly_score=s2gpp::s2gpp(params,Some(timeseries))?.unwrap();Ok(anomaly_score)}PythonWe have wrapped the Rust code in aPython package, that can be used without installing Rust.InstallationPyPIpipinstalls2gppBuild with Dockermakebuild-docker
pipinstallwheels/s2gpp-*.whlBuild from SourcemakeinstallUsageSingle Machinefroms2gppimportSeries2GraphPPimportpandasaspdts=pd.read_csv("data/ts_0.csv").valuesmodel=Series2GraphPP(pattern_length=100)anomaly_scores=model.fit_predict(ts)Distributedfroms2gppimportDistributedSeries2GraphPPfrompathlibimportPath# run on one machinedefmain_node():dataset_path=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 machinedefsub_node():model=DistributedSeries2GraphPP.sub(local_host="127.0.0.1:1993",mainhost="127.0.0.1:1992",n_cluster_nodes=2,pattern_length=100)model.fit_predict()CitePlease cite this work, when using it!@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