Skip to content

Repository files navigation

Healthcare Risk Detection POC

AI-powered patient risk prediction and clinical Q&A system using ML + RAG.

🚀 Quick Start (Windows)

Prerequisites

  • Python 3.10+
  • Ollama (for LLM-powered Q&A) - Download

Setup & Run

# 1. Install dependencies
pip install -r requirements.txt

# 2. Start Ollama and pull model (in separate terminal)
ollama serve
ollama pull llama2

# 3. Run the demo
.\run_demo.ps1

# Or run components manually:
python src/data/generate_synthetic.py   # Generate patient data
python -m src.ml.train                   # Train ML model
python src/embeddings/build_index.py    # Build knowledge index
uvicorn src.api.main:app --reload        # Start API (port 8000)
streamlit run src/ui/streamlit_app.py   # Start UI (port 8501)

Access

📊 Features

Risk Prediction

  • ML model trained on synthetic patient data
  • Features: age, heart rate, BP, WBC, creatinine, comorbidities
  • Returns probability, risk level, and feature importances

Clinical Q&A (RAG)

  • SBERT embeddings + FAISS vector search
  • Ollama (Llama2) for answer generation
  • Knowledge base: hypertension, diabetes, sepsis, AKI, cardiac risk

🏗️ Architecture

┌─────────────┐     ┌──────────────┐     ┌─────────────┐
│  Streamlit  │────▶│   FastAPI    │────▶│  ML Model   │
│     UI      │     │   Backend    │     │  (sklearn)  │
└─────────────┘     └──────┬───────┘     └─────────────┘
                          │
                          ▼
              ┌───────────────────────┐
              │    RAG Pipeline       │
              │  SBERT → FAISS → LLM  │
              └───────────────────────┘

📁 Project Structure

healthcare-risk-poc/
├── src/
│   ├── api/           # FastAPI backend
│   ├── data/          # Synthetic data generation
│   ├── embeddings/    # FAISS index & knowledge base
│   ├── ml/            # Model training utilities
│   └── ui/            # Streamlit frontend
├── run_demo.ps1       # Windows run script
├── requirements.txt   # Python dependencies
└── .env               # Configuration

🔧 Configuration

Edit .env to customize:

LLM_PROVIDER=ollama           # LLM provider
OLLAMA_MODEL=llama2           # Ollama model to use
MLFLOW_TRACKING_URI=file:./mlruns  # MLflow storage

📋 API Endpoints

Endpoint Method Description
/health GET API health check
/predict POST Risk prediction
/query POST Clinical Q&A
/patients GET Sample patients

For demonstration purposes only. Not for clinical use.

About

this project adds value by bridging multiple cutting-edge technologies (FHIR-based ETL, robust ML tracking, vector-augmented LLMs, and containerized cloud deployment) into a cohesive platform. It advances the state of the art in healthcare AI by making an advanced risk-detection and QA system demonstrably deployable in a real-world context.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages