Machine Learning Models
Anomaly detection algorithms and statistical methods used in this platform
Statistical approach measuring how many standard deviations a data point is from the mean. Fast, interpretable, and effective for univariate anomaly detection.
| Threshold | |z| > 2.1 |
| Lookback Window | 168 hours (7 days) |
| Min Samples | 10 readings |
| Metrics Monitored | 4 (cough, steps, audio) |
Detection Pipeline
Sensor readings received via BLE API endpoint and stored in SQLite database.
Calculate rolling mean (mu) and standard deviation (sigma) from 7-day historical window.
Compute z-score for each metric. Flag if |z| > threshold.
Create AnomalyFlag record with severity, description, and statistical context.
Severity Classification
| Severity | Z-Score Range | Interpretation | Recommended Action |
|---|---|---|---|
| LOW | 2.0 <= |z| < 3.0 | Unusual but within normal variation | Monitor, no immediate action |
| MEDIUM | 3.0 <= |z| < 4.0 | Significant deviation from baseline | Review patient status |
| HIGH | 4.0 <= |z| < 5.0 | Major anomaly detected | Priority attention required |
| CRITICAL | |z| >= 5.0 | Extreme outlier, possible emergency | Immediate intervention |
Implementation
Model Performance Metrics
Planned Enhancements
Autoencoders are unsupervised neural networks that learn to compress data into a lower-dimensional representation (encoding) and then reconstruct it (decoding). For anomaly detection, the model is trained on normal data; anomalies produce high reconstruction error because the model hasn't learned to represent them.
- Multivariate Anomalies: Detect when multiple metrics (cough + steps + keywords) deviate together in unusual combinations
- Subtle Pattern Shifts: Identify gradual changes in patient behavior that single-metric z-scores might miss
- Unsupervised Learning: No need for labeled anomaly data; learns what "normal" looks like for each patient
- Sensor Fusion: Combine data from accelerometer, microphone, and environmental sensors into unified anomaly score
| Architecture | Encoder: 6->4->2, Decoder: 2->4->6 |
| Input Features | 6 (cough, steps, 4 audio keywords) |
| Latent Dimension | 2 (for visualization) |
| Threshold Method | 95th percentile of training error |
Prophet is an open-source forecasting tool developed by Meta (Facebook) designed for business time-series that exhibit strong seasonal patterns and have multiple seasons of historical data. It automatically detects changepoints, handles missing data, and accounts for holidays/special events.
- Baseline Forecasting: Predict expected cough/step counts for each patient, flag when actuals deviate significantly
- Seasonal Health Patterns: Model daily rhythms (more coughs at night), weekly patterns (less activity on weekends), seasonal effects
- Trend Analysis: Detect if a patient's overall health metrics are improving or declining over weeks/months
- Resource Planning: Forecast hospital resource needs based on predicted patient activity levels
- Uncertainty Quantification: Provides confidence intervals for predictions, enabling risk-aware decision making
| Seasonality | Daily + Weekly + Yearly |
| Changepoint Detection | Automatic (Bayesian) |
| Forecast Horizon | 7 days ahead |
| Confidence Interval | 80% and 95% bounds |
Model Comparison
| Approach | Best For | Pros | Cons |
|---|---|---|---|
| Z-Score | Real-time, single-metric anomalies | Fast, interpretable, no training needed | Misses complex patterns |
| Z-Score | Temporal sequences, predictions | Learns long-term dependencies | Requires substantial training data |
| Autoencoder | Multivariate, unsupervised detection | No labeled data needed | Black box, harder to interpret |
| Prophet | Forecasting with seasonality | Handles missing data, automatic tuning | Less suited for real-time detection |