libspot-rs
A pure Rust implementation of the SPOT (Streaming Peaks Over Threshold) algorithm for real-time anomaly detection in time series data.
Quick Start
use ;
Features
Serialization (Model Persistence)
Serialization support is enabled by default. SPOT detectors can be serialized and deserialized for model deployment:
[]
= { = "0.2.1" } # serde is enabled by default
= "1.0"
To disable serialization support (e.g., for minimal dependencies), use:
[]
= { = "0.2.1", = false }
This enables:
- Model persistence: Save trained models to disk and load them later
- Model deployment: Export models for use in production systems
- Model sharing: Share trained models between applications
- Checkpointing: Save model state during long-running processes
Example usage:
use ;
use serde_json;
// Train a model
let config = default;
let mut spot = new.unwrap;
let training_data: = .map.collect;
spot.fit.unwrap;
// Save the model to a JSON file
let json = to_string_pretty.unwrap;
write.unwrap;
// Later, load the model and continue using it
let json = read_to_string.unwrap;
let mut loaded: SpotDetector = from_str.unwrap;
// The loaded model is ready to use immediately
let status = loaded.step.unwrap;
The serialization handles special float values (NaN, Infinity) correctly, ensuring that models can be reliably saved and restored.
Alternative
For C FFI bindings to the original libspot library, see the libspot crate.
License
This project is licensed under the GNU Lesser General Public License v3.0 - see the LICENSE file for details. }