AI-powered patient risk prediction and clinical Q&A system using ML + RAG.
- Python 3.10+
- Ollama (for LLM-powered Q&A) - Download
# 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)- UI Dashboard: http://localhost:8501
- API Docs: http://localhost:8000/docs
- MLflow UI:
mlflow ui --backend-store-uri file:./mlruns
- ML model trained on synthetic patient data
- Features: age, heart rate, BP, WBC, creatinine, comorbidities
- Returns probability, risk level, and feature importances
- SBERT embeddings + FAISS vector search
- Ollama (Llama2) for answer generation
- Knowledge base: hypertension, diabetes, sepsis, AKI, cardiac risk
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ Streamlit │────▶│ FastAPI │────▶│ ML Model │
│ UI │ │ Backend │ │ (sklearn) │
└─────────────┘ └──────┬───────┘ └─────────────┘
│
▼
┌───────────────────────┐
│ RAG Pipeline │
│ SBERT → FAISS → LLM │
└───────────────────────┘
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
Edit .env to customize:
LLM_PROVIDER=ollama # LLM provider
OLLAMA_MODEL=llama2 # Ollama model to use
MLFLOW_TRACKING_URI=file:./mlruns # MLflow storage| 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.