Skip to content

wellDeadpan/Weaver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Weaver

Heart Failure Risk Prediction using Synthetic EHR Data

A machine learning pipeline that predicts heart failure risk using synthetic electronic health record (EHR) data from Synthea. The model is deployed via FastAPI and packaged in Docker for easy deployment.

πŸ“Œ Project Features Predicts risk of heart failure (HFYN) from patient data.

Uses Naive Bayes (GaussianNB) with custom priors for balanced classification.

Encodes categorical features using LabelEncoder + OneHotEncoder.

Evaluated with ROC-AUC, classification reports, and threshold tuning.

Deployed with FastAPI + Docker β€” includes interactive API docs via Swagger.

πŸ—‚οΈ Project Structure

Weaver/
β”œβ”€β”€ app/                      # FastAPI app
β”‚   └── main.py
β”œβ”€β”€ data/                     # Data loading & processing
β”‚   β”œβ”€β”€ DataLoad.py
β”‚   └── DataProcessing.py
β”œβ”€β”€ model/                    # Saved model + encoders
β”‚   β”œβ”€β”€ model_NB.pkl
β”‚   β”œβ”€β”€ onehot_encoder.pkl
β”‚   └── label_encoders.pkl
β”œβ”€β”€ synthea/                  # Synthetic data
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ requirements.txt
└── README.md

βš™οΈ Setup Instructions

  1. Clone the Repository git clone https://github.com/wellDeadpan/Weaver.git cd Weaver
  2. Build Docker Image docker build -t weaver-app .
  3. Run Docker Container docker run -p 8000:8000 weaver-app
  4. Access API Docs Open http://localhost:8000/docs for Swagger UI.

Test the /predict endpoint interactively.

πŸ“Š Example API Request

Endpoint: POST /predict Request Body:

{
  "features": [1.0, 0.5, 2.3, 4.4, ..., 29.1]  # Total 29 features expected
}

Response:

{
  "prediction": [1]
}

πŸ“ˆ Model Training Summary

Model: GaussianNB(priors=[0.5, 0.5])

Features: Encoded patient demographic + medical data

Target: HFYN (Heart Failure Yes/No)

Evaluation:

ROC-AUC: 

Threshold tuned at 0.3 for better recall

🧠 Future Improvements Automate data preprocessing in FastAPI

Add logging and error handling

Explore deployment to cloud (e.g., AWS, Render)

Add CI/CD (e.g., GitHub Actions)

πŸ“„ License MIT License

πŸ™Œ Acknowledgements Synthetic data from Synthea

Built with love, FastAPI, and Docker 🐳

πŸ’¬ Want Help With... Writing unit tests?

Deploying to cloud?

Improving model performance?

Just ask β€” I’m happy to collaborate!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages