Patient Risk Stratification
Mortality Prediction
Logistic Regression
APACHE Scoring
import numpy as np
class MortalityPredictor:
def __init__(self, n_features):
self.weights = np.random.randn(n_features) * 0.01
self.bias = 0.0
def predict_proba(self, X):
z = X @ self.weights + self.bias
return 1 / (1 + np.exp(-z))
def compute_apache(self, phys_vars, age_score, chronic_score):
phys_score = sum(4 for k, v in phys_vars.items()
if k in ('heart_rate', 'respiratory_rate', 'sodium')
and (v > 140 or v < 50))
return phys_score + age_score + chronic_score
Readmission Risk Scoring
LACE Index
| Component | Points |
|---|---|
| Length of stay > 4 days | 1 |
| Acute care at discharge | 1 |
| Charlson index > 3 | 1 |
| Emergency visits in past 6 months | 1-5 |
class ReadmissionScorer:
def compute_lace(self, los, acute_discharge, charlson, ed_visits):
return (1 if los > 4 else 0) + (1 if acute_discharge else 0) + (1 if charlson > 3 else 0) + min(ed_visits, 5) * 0.5
def predict(self, lace_score):
if lace_score >= 10: return 'high_risk'
elif lace_score >= 7: return 'moderate_risk'
return 'low_risk'
Early Warning Systems
MEWS (Modified Early Warning Score)
Survival Analysis
Cox Proportional Hazards
Risk Stratification Bands
| Risk Level | Score Range | Intervention |
|---|---|---|
| Very Low | < 5% | Routine care |
| Low | 5-15% | Enhanced monitoring |
| Moderate | 15-30% | Specialist consultation |
| High | > 30% | Intensive care |