libspot

A safe Rust wrapper (using FFI) for the libspot time series anomaly detection library.
Quick Start
use libspot::{SpotDetector, SpotConfig, SpotStatus};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = SpotConfig::default();
let mut detector = SpotDetector::new(config)?;
let training_data: Vec<f64> = (0..1000)
.map(|i| 5.0 + (i as f64 * 0.01).sin() * 2.0)
.collect();
detector.fit(&training_data)?;
let test_value = 50.0; match detector.step(test_value)? {
SpotStatus::Normal => println!("Normal data point"),
SpotStatus::Excess => println!("In the tail distribution"),
SpotStatus::Anomaly => println!("Anomaly detected! 🚨"),
}
Ok(())
}
Alternative
For a pure Rust implementation without FFI dependencies, see the libspot-rs crate.
License
This project is licensed under the GNU Lesser General Public License v3.0 (LGPL-3.0).