scirs2_series/streaming/config.rs
1//! Configuration types for streaming time series analysis
2//!
3//! This module defines configuration structures and enums used throughout
4//! the streaming time series analysis framework.
5
6use std::time::Instant;
7
8/// Configuration for streaming analysis
9#[derive(Debug, Clone)]
10pub struct StreamConfig {
11 /// Maximum window size for online calculations
12 pub window_size: usize,
13 /// Minimum number of observations before starting analysis
14 pub min_observations: usize,
15 /// Update frequency for model parameters
16 pub update_frequency: usize,
17 /// Memory threshold for automatic cleanup
18 pub memory_threshold: usize,
19 /// Enable adaptive windowing
20 pub adaptive_windowing: bool,
21 /// Detection threshold for change points
22 pub change_detection_threshold: f64,
23}
24
25impl Default for StreamConfig {
26 fn default() -> Self {
27 Self {
28 window_size: 1000,
29 min_observations: 10,
30 update_frequency: 10,
31 memory_threshold: 10000,
32 adaptive_windowing: false,
33 change_detection_threshold: 3.0,
34 }
35 }
36}
37
38/// Real-time change point detection result
39#[derive(Debug, Clone)]
40pub struct ChangePoint {
41 /// Index of the change point
42 pub index: usize,
43 /// Timestamp of the change point
44 pub timestamp: Option<Instant>,
45 /// Confidence score (higher = more confident)
46 pub confidence: f64,
47 /// Type of change detected
48 pub change_type: ChangeType,
49}
50
51/// Types of changes that can be detected
52#[derive(Debug, Clone)]
53pub enum ChangeType {
54 /// Change in mean
55 MeanShift,
56 /// Change in variance
57 VarianceShift,
58 /// Change in trend
59 TrendChange,
60 /// Change in seasonality
61 SeasonalityChange,
62 /// General structural break
63 StructuralBreak,
64}