Crates.io | anomaly_detection |
lib.rs | anomaly_detection |
version | 0.3.0 |
source | src |
created_at | 2021-10-15 21:23:11.207843 |
updated_at | 2023-09-26 02:02:42.704812 |
description | Time series anomaly detection for Rust |
homepage | |
repository | https://github.com/ankane/AnomalyDetection.rs |
max_upload_size | |
id | 465642 |
size | 49,192 |
Time series AnomalyDetection for Rust
Learn how it works
Add this line to your application’s Cargo.toml
under [dependencies]
:
anomaly_detection = "0.3"
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();
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
This library was ported from the AnomalyDetection R package and is available under the same license.
View the changelog
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