Inspiration
Cardiovascular disease kills approximately 17.9 million people every year, making it the leading cause of death worldwide. ECGs are performed in virtually every hospital and clinic, yet that data almost always stops at a diagnosis on paper. A cardiologist reads it, writes a report, and moves on. I asked myself: what if a system could take that same raw ECG signal and go all the way from waveform to action plan? Not just tell you what is wrong, but tell you what to do about it, how much it would help, and which patients to prioritize first. That gap between diagnosis and clinical decision-making is what inspired HeartGuard.
How we built it
I built the entire system in a single Jupyter notebook using the PTB-XL dataset, which contains 21,799 clinical 12-lead ECGs from 18,869 patients, recorded at 500 Hz. I started with signal processing, detecting R-peaks in Lead II and extracting 165 engineered features, including:
- HRV time-domain metrics: SDNN, RMSSD, pNN50
- per-lead statistical features across all 12 leads
- morphological descriptors of QRS complex geometry I designed a composite risk score that combines ECG diagnostic severity, age-based risk stratified by decade, and sex adjustment into a normalized score discretized into four classes. I then trained and compared four model architectures:
- XGBoost on the tabular features
- 1D CNN with four convolutional blocks operating directly on raw signals
- CNN-LSTM hybrid adding bidirectional LSTMs for temporal modeling
- Multi-Modal fusion architecture combining a CNN branch with a tabular dense branch
All deep learning models were implemented in PyTorch with: - class-weighted cross-entropy loss
- Adam optimizer
- early stopping
For explainability, I used: - SHAP TreeExplainer on XGBoost
- Grad-CAM adapted for 1D convolutions
The clinical recommendation engine uses a rule-based system that maps findings to evidence-based interventions and projects risk reduction using a multiplicative model capped at 70%.
Challenges we ran into
My GPU had only 4 GB of VRAM, so training three deep learning models sequentially required careful batch sizing and memory monitoring to avoid out-of-memory crashes. SHAP's DeepExplainer had shape mismatch errors with my multi-class deep learning outputs, so I pivoted to TreeExplainer on XGBoost and built custom visualizations instead of using the built-in summary plots. Adapting Grad-CAM from its standard 2D image format to 1D time-series ECG signals required rethinking how to upsample activation maps and overlay attention on waveform traces. The biggest conceptual challenge was engineering meaningful risk labels from a dataset that provides diagnoses but not actual patient outcomes like mortality or heart attacks, which required building a severity-tiered scoring system grounded in cardiology literature.
Accomplishments that we're proud of
My best model achieves an AUC of 0.8345 on a human-validated test set, which is strong performance for four-class ECG risk classification. But what I am most proud of is that HeartGuard does not stop at a number. It produces:
- full patient reports with explainable predictions
- prioritized intervention plans with specific risk reduction percentages backed by published trial data
- population-level analytics that could help a hospital plan cardiology resources
I also successfully adapted two explainability techniques (SHAP and Grad-CAM) to confirm that my models focus on clinically relevant features and ECG regions, which is essential for any system that would need physician trust.
What we learned
A simpler 1D CNN outperformed the more complex CNN-LSTM, teaching me that for 10-second ECG windows, local morphological patterns matter more than long-range temporal dependencies. The Multi-Modal architecture achieved the highest accuracy at 70.3%, confirming that hand-crafted domain features and deep learned representations are complementary rather than competing. Building the recommendation engine forced me to deeply understand how risk reduction is quantified in cardiology trials and how to translate clinical guidelines into a computational framework. I also learned that explainability is not just a nice-to-have but a requirement for clinical AI, since without it the best predictions in the world will not be trusted by doctors.
What's next for HeartGuard
The most important next step is validating with true outcome data such as mortality and major adverse cardiovascular events rather than diagnosis-derived labels. I want to integrate with electronic health records to use real patient vitals and lab values instead of synthetic clinical features. A real-time monitoring mode that continuously analyzes ECG streams rather than single 10-second windows would extend the system to ICU and ambulatory settings. Multi-center validation across diverse patient populations is needed to test generalization. Ultimately, a prospective clinical study comparing HeartGuard-guided interventions against standard care would be required before any real-world deployment.
Log in or sign up for Devpost to join the conversation.