AI for Remote Patient Monitoring
Module: Healthcare AI | Difficulty: Advanced
Time Series Anomaly Score
Alert Threshold
Personalized Baseline
RPM AI Applications
| Condition | Sensor | Alert Accuracy | False Alarm Rate | |-----------|--------|---------------|------------------| | AF Detection | Smartwatch | 0.94 | 5% | | Fall Detection | Accelerometer | 0.96 | 3% | | Hypoglycemia | CGM | 0.92 | 8% | | Heart Failure | Weight + BP | 0.88 | 12% | | COPD Exacerbation | SpO2 + RR | 0.85 | 15% |
import torch
import torch.nn as nn
class WearableAnomalyDetector(nn.Module):
def __init__(self, input_dim=6, hidden_dim=32):
super().__init__()
self.encoder = nn.LSTM(input_dim, hidden_dim, batch_first=True)
self.decoder = nn.LSTM(hidden_dim, hidden_dim, batch_first=True)
self.output = nn.Linear(hidden_dim, input_dim)
def forward(self, x):
_, (h, c) = self.encoder(x)
decoder_input = torch.zeros_like(x[:, :1, :])
hidden = (h, c)
outputs = []
for t in range(x.shape[1]):
out, hidden = self.decoder(decoder_input, hidden)
pred = self.output(out)
outputs.append(pred)
decoder_input = pred
return torch.cat(outputs, dim=1)
class VitalSignMonitor(nn.Module):
def __init__(self, num_vitals=5):
super().__init__()
self.temporal = nn.Sequential(
nn.Conv1d(num_vitals, 32, kernel_size=7, padding=3), nn.ReLU(),
nn.Conv1d(32, 64, kernel_size=5, padding=2), nn.ReLU(),
nn.Conv1d(64, 128, kernel_size=3, padding=1))
self.alert_head = nn.Linear(128, 1)
self.trend_head = nn.Linear(128, 1)
def forward(self, vitals):
features = self.temporal(vitals)
pooled = features.mean(dim=-1)
alert_prob = torch.sigmoid(self.alert_head(pooled))
trend = self.trend_head(pooled)
return alert_prob, trend
def compute_rolling_stats(data, window=10):
means = []
stds = []
for i in range(len(data) - window + 1):
window_data = data[i:i+window]
means.append(np.mean(window_data))
stds.append(np.std(window_data))
return np.array(means), np.array(stds)
def detect_trend(values, threshold=0.1):
if len(values) < 2:
return 'stable'
slope = np.polyfit(range(len(values)), values, 1)[0]
if slope > threshold:
return 'increasing'
elif slope < -threshold:
return 'decreasing'
return 'stable'
model = WearableAnomalyDetector(input_dim=6)
sensor_data = torch.randn(1, 100, 6)
reconstructed = model(sensor_data)
anomaly_score = torch.mean((sensor_data - reconstructed) ** 2, dim=-1)
print(f'Anomaly scores shape: {anomaly_score.shape}')
vital_monitor = VitalSignMonitor(num_vitals=5)
vitals = torch.randn(1, 5, 200)
alert, trend = vital_monitor(vitals)
print(f'Alert probability: {alert.item():.4f}')
print(f'Trend prediction: {trend.item():.4f}')
heart_rates = np.random.uniform(60, 100, 50)
means, stds = compute_rolling_stats(heart_rates, window=10)
print(f'Rolling means shape: {means.shape}')
Research Insight: Remote patient monitoring AI must balance sensitivity with specificity. The key innovation is personalized baselines: instead of using population-level thresholds, models learn individual patient patterns and detect deviations from their own baseline. Federated learning across patients enables collaborative model training while preserving privacy.