Patient Mortality Prediction and Early Warning Systems
Module: Healthcare AI | Difficulty: Advanced
APACHE II Score
SOFA Score Components
Cox Proportional Hazards
Survival Function
Mortality Prediction Performance
| Model | AUC-ROC | Sensitivity | Specificity | Calibration |
|---|---|---|---|---|
| APACHE II | 0.75 | 0.70 | 0.72 | Moderate |
| SOFA | 0.78 | 0.73 | 0.74 | Moderate |
| NEWS2 | 0.72 | 0.68 | 0.70 | Good |
| Deep Learning | 0.85 | 0.80 | 0.82 | Good |
| Hybrid (DL+APACHE) | 0.88 | 0.83 | 0.85 | Excellent |
import torch
import torch.nn as nn
import numpy as np
class SurvivalModel(nn.Module):
def __init__(self, input_dim=50, hidden_dim=64):
super().__init__()
self.feature_net = nn.Sequential(
nn.Linear(input_dim, hidden_dim), nn.ReLU(),
nn.Dropout(0.3), nn.Linear(hidden_dim, hidden_dim), nn.ReLU())
self.hazard_head = nn.Linear(hidden_dim, 1)
def forward(self, x):
features = self.feature_net(x)
return self.hazard_head(features)
def cox_partial_likelihood(log_hazards, events, times):
sorted_idx = torch.argsort(times, descending=True)
log_hazards = log_hazards[sorted_idx]
events = events[sorted_idx]
log_cumsum = torch.logcumsum(torch.exp(log_hazards), dim=0)
partial_ll = log_hazards - log_cumsum
partial_ll = partial_ll * events
return -partial_ll.sum() / events.sum()
def c_index(log_hazards, events, times):
concordant = 0
permissible = 0
for i in range(len(times)):
for j in range(i + 1, len(times)):
if events[i] == 1 or events[j] == 1:
if times[i] != times[j]:
permissible += 1
if times[i] < times[j] and log_hazards[i] > log_hazards[j]:
concordant += 1
elif times[i] > times[j] and log_hazards[j] > log_hazards[i]:
concordant += 1
return concordant / permissible if permissible > 0 else 0.5
model = SurvivalModel(input_dim=50)
x = torch.randn(100, 50)
events = torch.randint(0, 2, (100,)).float()
times = torch.rand(100) * 365
log_hazards = model(x).squeeze()
loss = cox_partial_likelihood(log_hazards, events, times)
ci = c_index(log_hazards.detach(), events, times)
print(f'Cox partial likelihood loss: {loss.item():.4f}')
print(f'Concordance index: {ci:.4f}')
Research Insight: Deep learning mortality prediction models consistently outperform traditional scoring systems in discrimination, but often poorly calibrated. Ensemble approaches that combine deep learning predictions with traditional scores achieve both high discrimination and good calibration.