| Crates.io | libspot |
| lib.rs | libspot |
| version | 2.0.0-beta.6.0 |
| created_at | 2025-07-11 01:21:45.388797+00 |
| updated_at | 2025-12-18 02:52:41.729485+00 |
| description | Rust FFI bindings for libspot, a fast time series anomaly detector |
| homepage | |
| repository | https://github.com/shenxiangzhuang/libspot-rs |
| max_upload_size | |
| id | 1747258 |
| size | 104,164 |
A safe Rust wrapper (using FFI) for the libspot time series anomaly detection library.
use libspot::{SpotDetector, SpotConfig, SpotStatus};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create detector with default configuration
let config = SpotConfig::default();
let mut detector = SpotDetector::new(config)?;
// Fit with training data
let training_data: Vec<f64> = (0..1000)
.map(|i| 5.0 + (i as f64 * 0.01).sin() * 2.0)
.collect();
detector.fit(&training_data)?;
// Detect anomalies in real-time
let test_value = 50.0; // This should be an anomaly
match detector.step(test_value)? {
SpotStatus::Normal => println!("Normal data point"),
SpotStatus::Excess => println!("In the tail distribution"),
SpotStatus::Anomaly => println!("Anomaly detected! 🚨"),
}
Ok(())
}
For a pure Rust implementation without FFI dependencies, see the libspot-rs crate.
This project is licensed under the GNU Lesser General Public License v3.0 (LGPL-3.0).