duartebranco/cardiovascular-disease
Cardiovascular Disease Prognosis: ML-Based Decision Support System
Overview
This project develops a machine learning-based Decision Support System that predicts a user's probability of having cardiovascular disease based on accessible health metrics. The system is designed to be adaptive (work with partial information and improves predictions as users provide more clinical data) and to output a Risk Probability Percentage rather than a rigid binary classification.
Problem Statement
"Cardiovascular diseases are the leading cause of death globally. While early detection significantly improves survival rates, many individuals lack immediate access to complete clinical blood panels". This system bridges that gap by providing an adaptive risk assessment tool.
Why Adaptive?
A typical user might know their height, weight, and age but not their exact glucose or cholesterol levels. Instead of failing, our system:
- Provides baseline risk probabilities with available inputs
- Updates predictions as more clinical data becomes available
Dataset
- Source: Cardiovascular Disease Dataset (S. Ulianova on Kaggle)
- Size: 70,000 clinical records
- Features: 11 objective, subjective, and examination features including:
- Demographics: age, gender
- Anthropometric: height, weight
- Clinical: blood pressure, cholesterol, glucose
- Behavioral: smoking habits, physical activity
Running Locally
pip install -r requirements.txt
uvicorn api.main:app --reloadThen open http://localhost:8000.
Themodels/directory must exist locally (runmain.ipynbfirst to generate it).
Project Structure
├── main.ipynb # Central orchestration notebook
├── Dockerfile # Container definition for HF Spaces
├── start.sh # Downloads models then starts the server
├── requirements.txt
├── data/
│ ├── raw/
│ │ └── cardio_train.csv # Original dataset
│ └── processed/
│ └── cardio_train_cleaned.csv # Cleaned & preprocessed data
├── src/
│ ├── data/
│ │ ├── missing_data.py # Imputation & prediction logic
│ │ ├── recommendations.py # Actionable recommendations
│ │ ├── explainability.py # SHAP-based feature explanations
│ │ ├── pipeline.py # Adapter that loads the above for the API
│ │ └── explore.py # Data exploration & analysis
│ ├── features/
│ │ └── build_features.py # Data cleaning & feature engineering
│ └── models/
│ ├── train.py # Model training functions
│ ├── predict.py # Prediction interface
│ ├── confidence_analysis.py # Confidence scoring
│ ├── threshold_analysis.py # Threshold optimization
│ └── learning_curves.py # Learning curve analysis
├── api/
│ └── main.py # FastAPI backend (predict, recommendations, explain)
├── frontend/
│ └── static/
│ ├── index.html # Single-page UI
│ ├── style.css
│ └── js/
│ ├── api.js # Fetch wrappers
│ ├── render.js # DOM rendering
│ └── main.js # Form submit handler
├── docs/
│ ├── Proposal.md # Project proposal document
│ └── ModelingStrategy.md # Modeling strategy report
├── models/ # Trained model artifacts (.pkl)
└── output/ # Plots and metrics (generated by main.ipynb)Team
- [Duarte Branco - 119253](https://github.com/duartebranco)
- [Filipe Viseu - 119192](https://github.com/FilipeNV1)
- [Samuel Vinhas - 119405](https://github.com/samuelvinhas)
