DEV Community

hossein ahmadi
hossein ahmadi

Posted on

Why Your ML Model Should Sometimes Say 'I Don't Know': Building Uncertainty-Aware Clinical AI

🚨 Predictive models tell us what will happen.
🧠 Causal models tell us what happens IF we intervene.
❓ But neither tells us what we should DO.

In healthcare, this gap is dangerous.


I just finished building CausalSepsis-DI v2, an end-to-end Healthcare Decision Intelligence system that bridges the gap between causal estimation and safe clinical action.

🏥 The Clinical Question:
Should we administer early antibiotics to this ICU patient to reduce length of stay?

Traditional ML answers: "Predicted ICU stay: 8.5 days"
❌ This doesn't help clinicians make decisions.


💡 The Core Innovation: A Three-Class Decision Policy

Instead of forcing binary treat / don't treat decisions (which can be dangerous when uncertainty is high), the system outputs three actions:

TREAT — High-confidence benefit (even worst-case CI is beneficial)
🛑 STANDARD CARE — High-confidence no benefit/harm (even best-case is harmful)
🩺 DEFER TO CLINICIAN — Uncertainty zone (safest choice)

This is not a limitation — it's a feature. A trustworthy clinical AI knows when it doesn't know.


🛠️ Technical Stack

🧠 Causal Inference: LinearDML (EconML) with cross-fitting for valid CATE + confidence intervals
📊 Propensity Diagnostics: Positivity/overlap checks before estimation
⚖️ Decision Policy: Cost-sensitive, utility-based, uncertainty-aware
🔬 Policy Evaluation: Inverse Propensity Weighting (IPW) with bootstrap CIs for counterfactual estimation
📚 RAG Layer: Guideline-grounded explanations (TF-IDF retrieval + template generation → no LLM hallucinations)
⚙️ MLOps: FastAPI service with Pydantic validation, model cards, health checks, and unit tests


📈 Key Results

  • 62.1% of patients → Recommend early antibiotics
  • 33.8% → Recommend standard care
  • 4.1% → Defer to clinician (uncertainty zone)

Policy evaluation (IPW): Estimated 3.70 days reduction in mean ICU length of stay vs. observed practice.


🎓 Why Synthetic Data?

The MIMIC-IV demo dataset has only 117 patients — insufficient for Double ML, which requires thousands of observations. I generated a realistic synthetic cohort (N=1500) with:

  • Known ground-truth CATE (for validation)
  • Heterogeneous treatment effects (emergency vs elective patients)
  • Realistic propensity distributions

The pipeline is fully modular and can be directly plugged into real EHR data (MIMIC-IV full, eICU, hospital systems).


📂 Check it out

🔗 Full interactive notebook + architecture: https://www.kaggle.com/code/ahmadihossein/sepsisdecision-di


Would love feedback from:

  • Clinicians working with decision support systems
  • Causal inference practitioners
  • MLOps engineers building production ML

What's the biggest challenge you've seen in deploying clinical ML? 👇

CausalInference #DecisionIntelligence #HealthcareAI #MachineLearning #MLOps #RAG #EconML #DataScience #ResponsibleAI #ClinicalML #PrecisionMedicine

Top comments (0)