1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
//! Constants for F-score metrics calculations and demo data generation
/// Mathematical constants for F-score calculations
pub mod calculation {
/// Harmonic mean multiplier for F1 score
pub const F1_MULTIPLIER: f64 = 2.0;
/// Beta value for standard F1 score
pub const STANDARD_BETA: f64 = 1.0;
/// Beta value for F2 score (emphasizes recall)
pub const F2_BETA: f64 = 2.0;
/// Beta value for F0.5 score (emphasizes precision)
pub const F05_BETA: f64 = 0.5;
}
/// Constants for demo data generation
pub mod demo_generation {
/// Time-based trends and variance
pub mod trends {
/// Daily precision decline rate for demo data
pub const PRECISION_DECLINE_RATE: f64 = 0.001;
/// Daily recall decline rate for demo data
pub const RECALL_DECLINE_RATE: f64 = 0.0015;
/// Precision variance amplitude for realistic fluctuation
pub const PRECISION_VARIANCE_AMPLITUDE: f64 = 0.02;
/// Recall variance amplitude for realistic fluctuation
pub const RECALL_VARIANCE_AMPLITUDE: f64 = 0.015;
/// Sine wave frequency for precision variance
pub const PRECISION_WAVE_FREQUENCY: f64 = 7.0;
/// Cosine wave frequency for recall variance
pub const RECALL_WAVE_FREQUENCY: f64 = 5.0;
}
/// Bounds and thresholds
pub mod bounds {
/// Minimum acceptable precision/recall for demo data
pub const MIN_DEMO_VALUE: f64 = 0.5;
/// Maximum precision/recall value
pub const MAX_VALUE: f64 = 1.0;
/// Lower bound for application-specific demo data
pub const APPLICATION_MIN_VALUE: f64 = 0.3;
/// Critical threshold for "Critical Issues" category
pub const CRITICAL_PRECISION_THRESHOLD: f64 = 0.45;
/// Critical threshold for recall in "Critical Issues" category
pub const CRITICAL_RECALL_THRESHOLD: f64 = 0.42;
}
/// Application-specific trend rates
pub mod application_trends {
/// Improving application trend rate (positive)
pub const IMPROVING_TREND_RATE: f64 = 0.001;
/// Slightly declining application trend rate
pub const SLIGHT_DECLINE_RATE: f64 = -0.0005;
/// Rapidly declining application trend rate
pub const RAPID_DECLINE_RATE: f64 = -0.002;
/// Recall trend factor relative to precision
pub const RECALL_TREND_FACTOR: f64 = 0.8;
}
/// Sample count increments and base values
pub mod sample_increments {
/// Base increment for sample count variation
pub const BASE_SAMPLE_INCREMENT: u64 = 50;
/// Sample count modulo for cycling through sizes
pub const SAMPLE_CYCLE_MODULO: i64 = 3;
}
}
/// Performance categorization thresholds
pub mod performance_thresholds {
/// Threshold for excellent performance
pub const EXCELLENT_THRESHOLD: f64 = 0.9;
/// Threshold for good performance
pub const GOOD_THRESHOLD: f64 = 0.8;
/// Threshold for acceptable performance
pub const ACCEPTABLE_THRESHOLD: f64 = 0.7;
/// Threshold for needs improvement
pub const NEEDS_IMPROVEMENT_THRESHOLD: f64 = 0.6;
/// Below this threshold is considered critical
pub const CRITICAL_THRESHOLD: f64 = 0.5;
}
/// Quality rating thresholds for precision/recall balance
pub mod quality_thresholds {
/// High precision/recall threshold
pub const HIGH_THRESHOLD: f64 = 0.8;
/// Moderate precision/recall threshold
pub const MODERATE_THRESHOLD: f64 = 0.6;
/// Good but not great threshold for imbalance detection
pub const GOOD_THRESHOLD: f64 = 0.7;
/// Poor performance threshold for imbalance detection
pub const POOR_THRESHOLD: f64 = 0.5;
}
/// Statistical significance constants
pub mod statistical {
/// Minimum sample size for statistical significance (Central Limit Theorem)
pub const MIN_SIGNIFICANT_SAMPLE_SIZE: u64 = 30;
/// Recommended minimum sample size for reliable metrics
pub const RECOMMENDED_MIN_SAMPLE_SIZE: u64 = 100;
/// Large sample size threshold
pub const LARGE_SAMPLE_THRESHOLD: u64 = 1000;
/// Default stability threshold for trend analysis
pub const DEFAULT_STABILITY_THRESHOLD: f64 = 0.01; // 1%
/// Default confidence level
pub const DEFAULT_CONFIDENCE_LEVEL: f64 = 0.95; // 95%
}
/// Time-based constants
pub mod time_intervals {
/// Hours in a day
pub const HOURS_PER_DAY: i64 = 24;
/// Maximum reasonable lookback period in days
pub const MAX_LOOKBACK_DAYS: i64 = 365;
/// Default demo period in days
pub const DEFAULT_DEMO_PERIOD_DAYS: i64 = 30;
/// Default points per day for demo data
pub const DEFAULT_DEMO_POINTS_PER_DAY: usize = 4;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_calculation_constants() {
assert_eq!(calculation::F1_MULTIPLIER, 2.0);
assert_eq!(calculation::STANDARD_BETA, 1.0);
assert_eq!(calculation::F2_BETA, 2.0);
assert_eq!(calculation::F05_BETA, 0.5);
}
#[test]
fn test_performance_thresholds_are_ordered() {
// Compile-time checks for threshold ordering
const _: () = assert!(
performance_thresholds::EXCELLENT_THRESHOLD > performance_thresholds::GOOD_THRESHOLD
);
const _: () = assert!(
performance_thresholds::GOOD_THRESHOLD > performance_thresholds::ACCEPTABLE_THRESHOLD
);
const _: () = assert!(
performance_thresholds::ACCEPTABLE_THRESHOLD
> performance_thresholds::NEEDS_IMPROVEMENT_THRESHOLD
);
const _: () = assert!(
performance_thresholds::NEEDS_IMPROVEMENT_THRESHOLD
> performance_thresholds::CRITICAL_THRESHOLD
);
}
#[test]
fn test_statistical_constants() {
// Compile-time checks for statistical constants
const _: () = assert!(
statistical::RECOMMENDED_MIN_SAMPLE_SIZE >= statistical::MIN_SIGNIFICANT_SAMPLE_SIZE
);
const _: () =
assert!(statistical::LARGE_SAMPLE_THRESHOLD > statistical::RECOMMENDED_MIN_SAMPLE_SIZE);
}
}