Skip to content

singh-vinit/heart_failure_predictor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heart Failure Predictor

Heart Failure Readmission Predictor

This project is a machine learning-powered web application designed to predict the likelihood of 30-day hospital readmission for heart failure patients, it enables clinicians to identify high-risk patients early and make informed care decisions.

Team - Codiologist

Demo

Features

  • Predicts 30-day readmission risk using clinical and lab data
  • Clean, responsive UI with modern design
  • Medical form with validation and dynamic lab test input
  • Real-time prediction via Flask API
  • Visual patient report with risk percentage & printable summary
  • Google or Email-based Sign-Up/Sign-In via Supabase

ML Model

  • Model Type: XGBoost Classifier
  • Tuning: Hyperparameter optimization with Optuna
  • Inputs:
    • Discharge location
    • Gender
    • Length of stay
    • Abnormal lab count
    • Lab test count
    • ICD9-based severity
  • Backend: Flask API hosted on Render
  • Frontend: Built using React.js (Next.js) and Tailwind CSS
  • Integration: CORS-enabled for seamless frontend-backend communication

How It Works

  1. User signs up or signs in via email or Google.
  2. Fills in medical form with clinical details.
  3. Submits form → data sent to /predict API endpoint.
  4. Receives a risk score (0–100%) and a diagnosis report.
  5. Can print or download the generated report.

Authentication (Supabase)

This project uses Supabase Auth for secure authentication with Email/Password and Google OAuth providers.

Method Route Description
POST /signup Register a new user with email/password
POST /signin Login user with email and password
POST /auth/callback Sign in user with Google OAuth

Database Schema: patientDetail

Column Type Description
id UUID Primary key for the patient record
userId UUID Supabase Auth user ID (foreign key reference)
patientId TEXT Custom patient identifier (e.g., PAT1654)
name TEXT Full name of the patient
age INTEGER Age of the patient
gender TEXT Gender of the patient (Male, Female, etc.)
admitDate DATE Date when the patient was admitted
dischargeDate DATE Date when the patient was discharged
dischargeLocation TEXT Discharge destination (e.g., HOSPICE-HOME)
labTests JSONB List of lab test results (status and ICD-9 code)
probability FLOAT Model-predicted probability (e.g., readmission risk)
created_at TIMESTAMP Timestamp when the record was created

Backend API Route – Store Patient Data

Method Route Description
POST /api/store Create and store a new patient record

Tech Stack

Layer Technologies
Frontend Next.js, TailwindCSS, Framer Motion
Backend Flask, Python
Machine Learning XGBoost, Optuna, NumPy, Joblib
Authentication Supabase Auth (Email & Google OAuth)

Deployment

-Backend: Flask API hosted on [Render] (https://heart-failure-predictor-z0j1.onrender.com/predict) -Frontend: Next.js, deployable on [Vercel] (https://heart-failure-predictor-brown.vercel.app/)

Installation & Setup Guide

  1. clone the repo
  git clone https://github.com/your-username/heart-failure-prediction.git
  cd heart-failure-prediction
  1. Backend Setup (Flask API + XGBoost)
cd backend
python -m venv venv
source venv/bin/activate       # For Windows: venv\Scripts\activate
pip install -r requirements.txt
python app.py  #run the flask api
  1. Frontend Setup (Next.js)
cd ../frontend
npm install
  1. setup environment variable for frontend
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
  1. Start the development server:
npm run dev
  1. Access the application at http://localhost:3000.

License

This project is licensed under the MIT License.