#time-series #detection #anomaly

anomaly_detection

Time series anomaly detection for Rust

8 releases

0.3.0 Sep 26, 2023
0.2.3 Mar 19, 2022
0.2.2 Jan 4, 2022
0.2.1 Dec 16, 2021
0.1.2 Oct 18, 2021

#38 in #time-series

Download history 9/week @ 2024-06-10 22/week @ 2024-06-17 12/week @ 2024-06-24 83/week @ 2024-07-08 23/week @ 2024-07-22 31/week @ 2024-07-29 30/week @ 2024-08-05 25/week @ 2024-08-12 3/week @ 2024-08-19 50/week @ 2024-09-02 40/week @ 2024-09-09 4/week @ 2024-09-16 55/week @ 2024-09-23

149 downloads per month
Used in zbusdg

GPL-3.0-or-later

18KB
246 lines

AnomalyDetection.rs

Time series AnomalyDetection for Rust

Learn how it works

Build Status

Installation

Add this line to your application’s Cargo.toml under [dependencies]:

anomaly_detection = "0.3"

Getting Started

Detect anomalies in a time series

use anomaly_detection::AnomalyDetector;

let series = vec![
    5.0, 9.0, 2.0, 9.0, 0.0, 6.0, 3.0, 8.0, 5.0, 18.0,
    7.0, 8.0, 8.0, 0.0, 2.0, 15.0, 0.0, 5.0, 6.0, 7.0,
    3.0, 6.0, 1.0, 4.0, 4.0, 4.0, 30.0, 7.0, 5.0, 8.0
];
let period = 7; // number of observations in a single period

let res = AnomalyDetector::fit(&series, period).unwrap();

Get anomalies

res.anomalies();

Parameters

Set parameters

AnomalyDetector::params()
    .alpha(0.05)                    // level of statistical significance
    .max_anoms(0.1)                 // maximum number of anomalies as percent of data
    .direction(Direction::Both)     // Positive, Negative, or Both
    .verbose(false)                 // show progress

Credits

This library was ported from the AnomalyDetection R package and is available under the same license.

References

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone https://github.com/ankane/AnomalyDetection.rs.git
cd AnomalyDetection.rs
cargo test

Dependencies

~63KB