Overview
The early warning system detects critical patient conditions by analyzing anomaly scores against configurable thresholds. It measures detection latency to ensure timely alerts for healthcare providers.Alert Generation
Generate alerts when anomaly scores exceed a threshold:anomaly_detection/early_warning.py:7-14
Alert Metrics
Thesimulate_early_warning() function returns:
alert_count: Total number of alerts triggeredfirst_alert_latency_s: Seconds from start until first alert- Returns
inflatency if no alerts triggered
Detection Latency Evaluation
Measure how quickly the system detects actual events:anomaly_detection/early_warning.py:17-26
Hardware-Constrained Early Warning
Run experiments under resource constraints:evaluation/early_warning_experiment.py:64-107
Constraint Scenarios
TheConstraintScenario dataclass defines resource limits:
evaluation/early_warning_experiment.py:16-20
Experiment Results
The experiment produces a DataFrame with metrics:memory_limit_mb: Memory constraintcompute_budget: Compute constraintstream_interval_ms: Streaming intervaleffective_batch_size: Auto-adjusted batch sizedetection_latency_s: Time to detect eventsprediction_accuracy: Prediction accuracyfalse_positives: Count of false positive alertsfalse_positive_rate: FP ratiocompute_utilization: Resource utilizationdetection_quality: Quality metric (accuracy - 0.5 × FPR)
evaluation/early_warning_experiment.py:50-61
Experiment Artifacts
The experiment generates:- CSV results:
early_warning_hardware_experiment.csv - Latency vs Accuracy plot: Shows tradeoff colored by compute budget
- Resource vs Quality plot: Resource score vs detection quality
Performance Summary
Summarize experiment results:evaluation/early_warning_experiment.py:110-120
Best Practices
- Set threshold based on acceptable false positive rate
- Monitor
first_alert_latency_sfor critical conditions - Use
evaluate_detection_latency()to validate against ground truth - Test under realistic hardware constraints
- Balance detection quality with resource utilization
- Target events: conditions like appendicitis, pregnancy complications
- Use 90th percentile threshold for high-confidence alerts