quantrs2_circuit/profiler/
analyzers.rs

1//! Performance analysis, anomaly detection, and prediction engines
2//!
3//! This module provides comprehensive performance analysis capabilities
4//! including statistical analysis, anomaly detection, alert systems,
5//! and performance prediction using machine learning models.
6
7use scirs2_core::ndarray::Array2;
8use scirs2_core::Complex64;
9use serde::{Deserialize, Serialize};
10use std::collections::{HashMap, HashSet, VecDeque};
11use std::sync::Arc;
12use std::time::{Duration, SystemTime};
13
14// Import types from sibling modules
15use super::collectors::*;
16use super::metrics::*;
17
18pub struct PerformanceAnalyzer {
19    /// Analysis configuration
20    pub config: AnalysisConfig,
21    /// Historical performance data
22    pub historical_data: HistoricalPerformanceData,
23    /// Performance models
24    pub performance_models: PerformanceModels,
25    /// Anomaly detector
26    pub anomaly_detector: AnomalyDetector,
27    /// Prediction engine
28    pub prediction_engine: PredictionEngine,
29}
30
31/// Analysis configuration
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct AnalysisConfig {
34    /// Analysis depth
35    pub analysis_depth: AnalysisDepth,
36    /// Statistical methods to use
37    pub statistical_methods: HashSet<StatisticalMethod>,
38    /// Machine learning models to use
39    pub ml_models: HashSet<MlModel>,
40    /// Confidence level for analysis
41    pub confidence_level: f64,
42    /// Minimum data points for analysis
43    pub min_data_points: usize,
44}
45
46/// Analysis depth levels
47#[derive(Debug, Clone, Serialize, Deserialize)]
48pub enum AnalysisDepth {
49    /// Basic statistical analysis
50    Basic,
51    /// Standard analysis with trends
52    Standard,
53    /// Advanced analysis with predictions
54    Advanced,
55    /// Comprehensive analysis with ML
56    Comprehensive,
57}
58
59/// Statistical methods for analysis
60#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
61pub enum StatisticalMethod {
62    /// Descriptive statistics
63    Descriptive,
64    /// Correlation analysis
65    Correlation,
66    /// Regression analysis
67    Regression,
68    /// Time series analysis
69    TimeSeries,
70    /// Hypothesis testing
71    HypothesisTesting,
72}
73
74/// Machine learning models for analysis
75#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
76pub enum MlModel {
77    /// Linear regression
78    LinearRegression,
79    /// Random forest
80    RandomForest,
81    /// Neural networks
82    NeuralNetwork,
83    /// Support vector machines
84    SupportVectorMachine,
85    /// Clustering algorithms
86    Clustering,
87}
88
89/// Historical performance data storage
90#[derive(Debug, Clone)]
91pub struct HistoricalPerformanceData {
92    /// Performance snapshots over time
93    pub snapshots: VecDeque<PerformanceSnapshot>,
94    /// Data retention policy
95    pub retention_policy: DataRetentionPolicy,
96    /// Data compression settings
97    pub compression_settings: CompressionSettings,
98    /// Data integrity checks
99    pub integrity_checks: IntegrityChecks,
100}
101
102/// Performance snapshot at a point in time
103#[derive(Debug, Clone, Serialize, Deserialize)]
104pub struct PerformanceSnapshot {
105    /// Snapshot timestamp
106    pub timestamp: SystemTime,
107    /// Performance metrics
108    pub metrics: HashMap<String, f64>,
109    /// System state
110    pub system_state: SystemState,
111    /// Environment information
112    pub environment: EnvironmentInfo,
113    /// Snapshot metadata
114    pub metadata: HashMap<String, String>,
115}
116
117/// System state information
118#[derive(Debug, Clone, Serialize, Deserialize)]
119pub struct SystemState {
120    /// CPU state
121    pub cpu_state: CpuState,
122    /// Memory state
123    pub memory_state: MemoryState,
124    /// I/O state
125    pub io_state: IoState,
126    /// Network state
127    pub network_state: NetworkState,
128}
129
130/// CPU state information
131#[derive(Debug, Clone, Serialize, Deserialize)]
132pub struct CpuState {
133    /// CPU utilization
134    pub utilization: f64,
135    /// CPU frequency
136    pub frequency: f64,
137    /// CPU temperature
138    pub temperature: Option<f64>,
139    /// Active processes
140    pub active_processes: usize,
141}
142
143/// Memory state information
144#[derive(Debug, Clone, Serialize, Deserialize)]
145pub struct MemoryState {
146    /// Total memory
147    pub total_memory: usize,
148    /// Used memory
149    pub used_memory: usize,
150    /// Free memory
151    pub free_memory: usize,
152    /// Cached memory
153    pub cached_memory: usize,
154}
155
156/// I/O state information
157#[derive(Debug, Clone, Serialize, Deserialize)]
158pub struct IoState {
159    /// Disk usage
160    pub disk_usage: f64,
161    /// Read IOPS
162    pub read_iops: f64,
163    /// Write IOPS
164    pub write_iops: f64,
165    /// Queue depth
166    pub queue_depth: f64,
167}
168
169/// Network state information
170#[derive(Debug, Clone, Serialize, Deserialize)]
171pub struct NetworkState {
172    /// Bandwidth utilization
173    pub bandwidth_utilization: f64,
174    /// Active connections
175    pub active_connections: usize,
176    /// Packet rate
177    pub packet_rate: f64,
178    /// Error rate
179    pub error_rate: f64,
180}
181
182/// Environment information
183#[derive(Debug, Clone, Serialize, Deserialize)]
184pub struct EnvironmentInfo {
185    /// Operating system
186    pub operating_system: String,
187    /// Hardware configuration
188    pub hardware_config: HardwareConfig,
189    /// Software versions
190    pub software_versions: HashMap<String, String>,
191    /// Environment variables
192    pub environment_variables: HashMap<String, String>,
193}
194
195/// Hardware configuration
196#[derive(Debug, Clone, Serialize, Deserialize)]
197pub struct HardwareConfig {
198    /// CPU model
199    pub cpu_model: String,
200    /// CPU cores
201    pub cpu_cores: u32,
202    /// Total memory
203    pub total_memory: usize,
204    /// GPU information
205    pub gpu_info: Option<GpuInfo>,
206    /// Storage information
207    pub storage_info: StorageInfo,
208}
209
210/// GPU information
211#[derive(Debug, Clone, Serialize, Deserialize)]
212pub struct GpuInfo {
213    /// GPU model
214    pub model: String,
215    /// GPU memory
216    pub memory: usize,
217    /// Compute capability
218    pub compute_capability: String,
219}
220
221/// Storage information
222#[derive(Debug, Clone, Serialize, Deserialize)]
223pub struct StorageInfo {
224    /// Storage type
225    pub storage_type: StorageType,
226    /// Total capacity
227    pub total_capacity: usize,
228    /// Available capacity
229    pub available_capacity: usize,
230}
231
232/// Storage types
233#[derive(Debug, Clone, Serialize, Deserialize)]
234pub enum StorageType {
235    /// Hard disk drive
236    HDD,
237    /// Solid state drive
238    SSD,
239    /// `NVMe` SSD
240    NVMe,
241    /// Network storage
242    Network,
243}
244
245/// Data retention policy
246#[derive(Debug, Clone, Serialize, Deserialize)]
247pub struct DataRetentionPolicy {
248    /// Maximum age for data
249    pub max_age: Duration,
250    /// Maximum number of snapshots
251    pub max_snapshots: usize,
252    /// Compression threshold
253    pub compression_threshold: Duration,
254    /// Archival policy
255    pub archival_policy: ArchivalPolicy,
256}
257
258/// Archival policy for old data
259#[derive(Debug, Clone, Serialize, Deserialize)]
260pub enum ArchivalPolicy {
261    /// Delete old data
262    Delete,
263    /// Compress old data
264    Compress,
265    /// Archive to external storage
266    Archive { location: String },
267    /// Keep all data
268    KeepAll,
269}
270
271/// Data compression settings
272#[derive(Debug, Clone, Serialize, Deserialize)]
273pub struct CompressionSettings {
274    /// Compression algorithm
275    pub algorithm: CompressionAlgorithm,
276    /// Compression level
277    pub compression_level: u8,
278    /// Enable real-time compression
279    pub realtime_compression: bool,
280}
281
282/// Compression algorithms
283#[derive(Debug, Clone, Serialize, Deserialize)]
284pub enum CompressionAlgorithm {
285    /// No compression
286    None,
287    /// LZ4 compression
288    LZ4,
289    /// Gzip compression
290    Gzip,
291    /// Zstd compression
292    Zstd,
293    /// Custom compression
294    Custom { name: String },
295}
296
297/// Data integrity checks
298#[derive(Debug, Clone, Serialize, Deserialize)]
299pub struct IntegrityChecks {
300    /// Enable checksums
301    pub enable_checksums: bool,
302    /// Checksum algorithm
303    pub checksum_algorithm: ChecksumAlgorithm,
304    /// Verification frequency
305    pub verification_frequency: Duration,
306}
307
308/// Checksum algorithms
309#[derive(Debug, Clone, Serialize, Deserialize)]
310pub enum ChecksumAlgorithm {
311    /// CRC32 checksum
312    CRC32,
313    /// MD5 hash
314    MD5,
315    /// SHA256 hash
316    SHA256,
317    /// Blake3 hash
318    Blake3,
319}
320
321/// Performance models for prediction
322#[derive(Debug, Clone)]
323pub struct PerformanceModels {
324    /// Statistical models
325    pub statistical_models: HashMap<String, StatisticalModel>,
326    /// Machine learning models
327    pub ml_models: HashMap<String, MachineLearningModel>,
328    /// Hybrid models
329    pub hybrid_models: HashMap<String, HybridModel>,
330    /// Model evaluation results
331    pub evaluation_results: ModelEvaluationResults,
332}
333
334/// Statistical performance model
335#[derive(Debug, Clone)]
336pub struct StatisticalModel {
337    /// Model type
338    pub model_type: StatisticalModelType,
339    /// Model parameters
340    pub parameters: HashMap<String, f64>,
341    /// Model accuracy
342    pub accuracy: f64,
343    /// Training data size
344    pub training_data_size: usize,
345}
346
347/// Types of statistical models
348#[derive(Debug, Clone)]
349pub enum StatisticalModelType {
350    /// Linear regression
351    LinearRegression,
352    /// Autoregressive model
353    Autoregressive,
354    /// Moving average model
355    MovingAverage,
356    /// ARIMA model
357    Arima,
358    /// Exponential smoothing
359    ExponentialSmoothing,
360}
361
362/// Machine learning performance model
363#[derive(Debug, Clone)]
364pub struct MachineLearningModel {
365    /// Model type
366    pub model_type: MlModelType,
367    /// Model hyperparameters
368    pub hyperparameters: HashMap<String, f64>,
369    /// Model accuracy
370    pub accuracy: f64,
371    /// Training data size
372    pub training_data_size: usize,
373    /// Feature importance
374    pub feature_importance: HashMap<String, f64>,
375}
376
377/// Types of ML models
378#[derive(Debug, Clone)]
379pub enum MlModelType {
380    /// Random forest
381    RandomForest,
382    /// Gradient boosting
383    GradientBoosting,
384    /// Neural network
385    NeuralNetwork,
386    /// Support vector regression
387    SupportVectorRegression,
388    /// Gaussian process
389    GaussianProcess,
390}
391
392/// Hybrid performance model
393#[derive(Debug, Clone)]
394pub struct HybridModel {
395    /// Component models
396    pub component_models: Vec<ComponentModel>,
397    /// Ensemble weights
398    pub ensemble_weights: HashMap<String, f64>,
399    /// Model accuracy
400    pub accuracy: f64,
401    /// Combination strategy
402    pub combination_strategy: CombinationStrategy,
403}
404
405/// Component model in hybrid ensemble
406#[derive(Debug, Clone)]
407pub struct ComponentModel {
408    /// Model name
409    pub name: String,
410    /// Model type
411    pub model_type: ComponentModelType,
412    /// Model weight
413    pub weight: f64,
414    /// Model accuracy
415    pub accuracy: f64,
416}
417
418/// Types of component models
419#[derive(Debug, Clone)]
420pub enum ComponentModelType {
421    /// Statistical model
422    Statistical(StatisticalModelType),
423    /// Machine learning model
424    MachineLearning(MlModelType),
425    /// Physics-based model
426    PhysicsBased,
427    /// Empirical model
428    Empirical,
429}
430
431/// Strategies for combining models
432#[derive(Debug, Clone)]
433pub enum CombinationStrategy {
434    /// Weighted average
435    WeightedAverage,
436    /// Voting ensemble
437    Voting,
438    /// Stacking ensemble
439    Stacking,
440    /// Bayesian model averaging
441    BayesianAveraging,
442}
443
444/// Model evaluation results
445#[derive(Debug, Clone, Serialize, Deserialize)]
446pub struct ModelEvaluationResults {
447    /// Cross-validation scores
448    pub cv_scores: HashMap<String, f64>,
449    /// Test set performance
450    pub test_performance: HashMap<String, f64>,
451    /// Model comparison
452    pub model_comparison: ModelComparison,
453    /// Feature analysis
454    pub feature_analysis: FeatureAnalysis,
455}
456
457/// Model comparison results
458#[derive(Debug, Clone, Serialize, Deserialize)]
459pub struct ModelComparison {
460    /// Best performing model
461    pub best_model: String,
462    /// Performance rankings
463    pub performance_rankings: Vec<ModelRanking>,
464    /// Statistical significance tests
465    pub significance_tests: HashMap<String, f64>,
466}
467
468/// Individual model ranking
469#[derive(Debug, Clone, Serialize, Deserialize)]
470pub struct ModelRanking {
471    /// Model name
472    pub model_name: String,
473    /// Performance score
474    pub performance_score: f64,
475    /// Ranking position
476    pub rank: u32,
477    /// Confidence interval
478    pub confidence_interval: (f64, f64),
479}
480
481/// Feature analysis results
482#[derive(Debug, Clone, Serialize, Deserialize)]
483pub struct FeatureAnalysis {
484    /// Feature importance scores
485    pub feature_importance: HashMap<String, f64>,
486    /// Feature correlations
487    pub feature_correlations: HashMap<String, f64>,
488    /// Feature selection results
489    pub feature_selection: FeatureSelectionResults,
490}
491
492/// Feature selection results
493#[derive(Debug, Clone, Serialize, Deserialize)]
494pub struct FeatureSelectionResults {
495    /// Selected features
496    pub selected_features: Vec<String>,
497    /// Feature selection method
498    pub selection_method: String,
499    /// Selection criteria
500    pub selection_criteria: HashMap<String, f64>,
501}
502
503/// Anomaly detection system
504#[derive(Debug, Clone)]
505pub struct AnomalyDetector {
506    /// Detection algorithms
507    pub algorithms: HashMap<String, AnomalyDetectionAlgorithm>,
508    /// Detected anomalies
509    pub detected_anomalies: Vec<PerformanceAnomaly>,
510    /// Detection configuration
511    pub config: AnomalyDetectionConfig,
512    /// Alert system
513    pub alert_system: AlertSystem,
514}
515
516/// Anomaly detection algorithm
517#[derive(Debug, Clone)]
518pub struct AnomalyDetectionAlgorithm {
519    /// Algorithm type
520    pub algorithm_type: AnomalyAlgorithmType,
521    /// Algorithm parameters
522    pub parameters: HashMap<String, f64>,
523    /// Detection threshold
524    pub threshold: f64,
525    /// False positive rate
526    pub false_positive_rate: f64,
527}
528
529/// Types of anomaly detection algorithms
530#[derive(Debug, Clone)]
531pub enum AnomalyAlgorithmType {
532    /// Statistical outlier detection
533    StatisticalOutlier,
534    /// Isolation forest
535    IsolationForest,
536    /// One-class SVM
537    OneClassSVM,
538    /// DBSCAN clustering
539    DBSCAN,
540    /// Autoencoder
541    Autoencoder,
542}
543
544/// Performance anomaly information
545#[derive(Debug, Clone, Serialize, Deserialize)]
546pub struct PerformanceAnomaly {
547    /// Anomaly ID
548    pub id: String,
549    /// Detection timestamp
550    pub timestamp: SystemTime,
551    /// Anomaly type
552    pub anomaly_type: AnomalyType,
553    /// Severity level
554    pub severity: AnomySeverity,
555    /// Affected metrics
556    pub affected_metrics: Vec<String>,
557    /// Anomaly score
558    pub anomaly_score: f64,
559    /// Root cause analysis
560    pub root_cause: Option<String>,
561    /// Recommended actions
562    pub recommended_actions: Vec<String>,
563}
564
565/// Types of performance anomalies
566#[derive(Debug, Clone, Serialize, Deserialize)]
567pub enum AnomalyType {
568    /// Performance degradation
569    PerformanceDegradation,
570    /// Resource spike
571    ResourceSpike,
572    /// Error rate increase
573    ErrorRateIncrease,
574    /// Latency increase
575    LatencyIncrease,
576    /// Throughput decrease
577    ThroughputDecrease,
578    /// Memory leak
579    MemoryLeak,
580    /// Custom anomaly
581    Custom { name: String },
582}
583
584/// Anomaly severity levels
585#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
586pub enum AnomySeverity {
587    /// Low severity
588    Low,
589    /// Medium severity
590    Medium,
591    /// High severity
592    High,
593    /// Critical severity
594    Critical,
595}
596
597/// Anomaly detection configuration
598#[derive(Debug, Clone, Serialize, Deserialize)]
599pub struct AnomalyDetectionConfig {
600    /// Enable real-time detection
601    pub enable_realtime: bool,
602    /// Detection sensitivity
603    pub sensitivity: f64,
604    /// Minimum anomaly duration
605    pub min_duration: Duration,
606    /// Alert thresholds
607    pub alert_thresholds: HashMap<AnomySeverity, f64>,
608}
609
610/// Alert system for anomalies
611#[derive(Debug, Clone)]
612pub struct AlertSystem {
613    /// Alert channels
614    pub alert_channels: Vec<AlertChannel>,
615    /// Alert history
616    pub alert_history: VecDeque<Alert>,
617    /// Alert rules
618    pub alert_rules: Vec<AlertRule>,
619    /// Alert suppression rules
620    pub suppression_rules: Vec<SuppressionRule>,
621}
622
623/// Alert channel configuration
624#[derive(Debug, Clone)]
625pub struct AlertChannel {
626    /// Channel type
627    pub channel_type: AlertChannelType,
628    /// Channel configuration
629    pub config: HashMap<String, String>,
630    /// Enabled status
631    pub enabled: bool,
632}
633
634/// Types of alert channels
635#[derive(Debug, Clone)]
636pub enum AlertChannelType {
637    /// Email alerts
638    Email,
639    /// Slack notifications
640    Slack,
641    /// Webhook calls
642    Webhook,
643    /// Log file entries
644    LogFile,
645    /// System notifications
646    SystemNotification,
647}
648
649/// Alert information
650#[derive(Debug, Clone, Serialize, Deserialize)]
651pub struct Alert {
652    /// Alert ID
653    pub id: String,
654    /// Alert timestamp
655    pub timestamp: SystemTime,
656    /// Alert level
657    pub level: AlertLevel,
658    /// Alert message
659    pub message: String,
660    /// Associated anomaly
661    pub anomaly_id: Option<String>,
662    /// Alert source
663    pub source: String,
664}
665
666/// Alert severity levels
667#[derive(Debug, Clone, Serialize, Deserialize)]
668pub enum AlertLevel {
669    /// Info level
670    Info,
671    /// Warning level
672    Warning,
673    /// Error level
674    Error,
675    /// Critical level
676    Critical,
677}
678
679/// Alert rule configuration
680#[derive(Debug, Clone)]
681pub struct AlertRule {
682    /// Rule name
683    pub name: String,
684    /// Rule condition
685    pub condition: AlertCondition,
686    /// Alert level
687    pub alert_level: AlertLevel,
688    /// Alert message template
689    pub message_template: String,
690    /// Enabled status
691    pub enabled: bool,
692}
693
694/// Alert condition
695#[derive(Debug, Clone)]
696pub enum AlertCondition {
697    /// Threshold condition
698    Threshold {
699        metric: String,
700        operator: ComparisonOperator,
701        value: f64,
702    },
703    /// Rate condition
704    Rate {
705        metric: String,
706        rate_threshold: f64,
707        time_window: Duration,
708    },
709    /// Composite condition
710    Composite {
711        conditions: Vec<Self>,
712        operator: LogicalOperator,
713    },
714}
715
716/// Comparison operators
717#[derive(Debug, Clone)]
718pub enum ComparisonOperator {
719    /// Greater than
720    GreaterThan,
721    /// Less than
722    LessThan,
723    /// Equal to
724    EqualTo,
725    /// Not equal to
726    NotEqualTo,
727    /// Greater than or equal
728    GreaterThanOrEqual,
729    /// Less than or equal
730    LessThanOrEqual,
731}
732
733/// Logical operators
734#[derive(Debug, Clone)]
735pub enum LogicalOperator {
736    /// Logical AND
737    And,
738    /// Logical OR
739    Or,
740    /// Logical NOT
741    Not,
742}
743
744/// Alert suppression rule
745#[derive(Debug, Clone)]
746pub struct SuppressionRule {
747    /// Rule name
748    pub name: String,
749    /// Suppression condition
750    pub condition: SuppressionCondition,
751    /// Suppression duration
752    pub duration: Duration,
753    /// Enabled status
754    pub enabled: bool,
755}
756
757/// Suppression condition
758#[derive(Debug, Clone)]
759pub enum SuppressionCondition {
760    /// Time-based suppression
761    TimeBased {
762        start_time: SystemTime,
763        end_time: SystemTime,
764    },
765    /// Metric-based suppression
766    MetricBased { metric: String, threshold: f64 },
767    /// Event-based suppression
768    EventBased { event_type: String },
769}
770
771/// Prediction engine for performance forecasting
772#[derive(Debug, Clone)]
773pub struct PredictionEngine {
774    /// Prediction models
775    pub models: HashMap<String, PredictionModel>,
776    /// Prediction results
777    pub predictions: HashMap<String, PredictionResult>,
778    /// Prediction configuration
779    pub config: PredictionConfig,
780    /// Forecast accuracy tracking
781    pub accuracy_tracking: AccuracyTracking,
782}
783
784/// Prediction model
785#[derive(Debug, Clone)]
786pub struct PredictionModel {
787    /// Model name
788    pub name: String,
789    /// Model type
790    pub model_type: PredictionModelType,
791    /// Model parameters
792    pub parameters: HashMap<String, f64>,
793    /// Training status
794    pub training_status: TrainingStatus,
795    /// Model accuracy
796    pub accuracy: f64,
797}
798
799/// Types of prediction models
800#[derive(Debug, Clone)]
801pub enum PredictionModelType {
802    /// Time series forecasting
803    TimeSeries,
804    /// Regression prediction
805    Regression,
806    /// Classification prediction
807    Classification,
808    /// Ensemble prediction
809    Ensemble,
810    /// Deep learning prediction
811    DeepLearning,
812}
813
814/// Prediction result
815#[derive(Debug, Clone, Serialize, Deserialize)]
816pub struct PredictionResult {
817    /// Prediction timestamp
818    pub timestamp: SystemTime,
819    /// Predicted value
820    pub predicted_value: f64,
821    /// Confidence interval
822    pub confidence_interval: (f64, f64),
823    /// Prediction accuracy
824    pub accuracy: f64,
825    /// Time horizon
826    pub time_horizon: Duration,
827    /// Prediction metadata
828    pub metadata: HashMap<String, String>,
829}
830
831/// Training status of models
832#[derive(Debug, Clone)]
833pub enum TrainingStatus {
834    /// Not trained
835    NotTrained,
836    /// Currently training
837    Training,
838    /// Trained successfully
839    Trained,
840    /// Training failed
841    Failed { error: String },
842    /// Needs retraining
843    NeedsRetraining,
844}
845
846/// Prediction configuration
847#[derive(Debug, Clone, Serialize, Deserialize)]
848pub struct PredictionConfig {
849    /// Prediction horizon
850    pub prediction_horizon: Duration,
851    /// Update frequency
852    pub update_frequency: Duration,
853    /// Minimum data points for prediction
854    pub min_data_points: usize,
855    /// Confidence level
856    pub confidence_level: f64,
857    /// Enable ensemble predictions
858    pub enable_ensemble: bool,
859}
860
861/// Accuracy tracking for predictions
862#[derive(Debug, Clone)]
863pub struct AccuracyTracking {
864    /// Accuracy history
865    pub accuracy_history: VecDeque<AccuracyMeasurement>,
866    /// Model performance comparison
867    pub model_comparison: HashMap<String, f64>,
868    /// Accuracy trends
869    pub accuracy_trends: HashMap<String, TrendDirection>,
870}
871
872/// Accuracy measurement
873#[derive(Debug, Clone, Serialize, Deserialize)]
874pub struct AccuracyMeasurement {
875    /// Measurement timestamp
876    pub timestamp: SystemTime,
877    /// Model name
878    pub model_name: String,
879    /// Actual value
880    pub actual_value: f64,
881    /// Predicted value
882    pub predicted_value: f64,
883    /// Accuracy score
884    pub accuracy_score: f64,
885}