Inspiration Cardiovascular diseases are one of the top reasons for deaths around the world. Although AI algorithms are able to identify arrhythmias with a high degree of success, most of them are “black boxes,” which makes physicians reluctant to rely on them. I wanted to develop an algorithm that is not only correct but also transparent.

What I Learned

How to preprocess ECG data for deep learning models.

How to create a 1D Convolutional Neural Network (CNN) for time-series signals.

How to use SHAP (Shapley Additive Explanations) to explain neural network predictions.

How to combine data science, deep learning, and explainability for a real-world healthcare problem.

How I Built It

Data Preparation:

Used MIT-BIH Arrhythmia CSV dataset.

Normalized ECG signals and split into train/test sets

Model Architecture:

 > Built a 1D CNN:

X∈RN×187×1→Conv1D + MaxPooling→Dense + SoftmaxX \in \mathbb{R}^{N \times 187 \times 1} \quad \rightarrow \quad \text{Conv1D + MaxPooling} \quad \rightarrow \quad \text{Dense + Softmax}X∈RN×187×1→Conv1D + MaxPooling→Dense + Softmax

  > Output: probability distribution over 5 arrhythmia classes.

Explainability:

Applied SHAP to highlight which ECG time steps influenced predictions.

Overlayed SHAP values on ECG plots for visual interpretation.

Evaluation:

Achieved 98% accuracy, high precision, and recall.

Visualized results with ECG waveforms and SHAP overlays.

Challenges I Faced

SHAP explanation for time series data: Required reshaping of inputs and flattening of arrays for KernelExplainer.

Handling large CSV files for ECG data: Required memory management in Google Colab.

Troubleshooting CNN mistakes: Modified input dimensions and architecture to suit ECG data format.

Interpreting results: Overlaying SHAP explanations on ECG graphs was a trial-and-error process to get the scaling right.

Impact & Future Vision

This project converts a black-box AI model into a clinically interpretable model, which will help doctors trust the predictions made by AI. In the future, this project can be extended to:

Real-time ECG monitoring on wearable devices.

Multi-lead ECG analysis for better diagnosis.

Use as a clinical decision support system in hospitals

Accomplishment

Being a pre-medical student, this was my first Hackathon project. Despite many hurdles and struggles related to the coding etc. as it was not my domain, I still succeeded in completing my project with accuracy. There is still much software left to understand, but I will learn it slowly and steadily. I learned a lot and will continue to participate to sharpen my skills.

Built With

  • googlecollab
  • pandas
  • shap
  • tensorflow
Share this project:

Updates