Training a deep neural network on ECG signals to detect cardiac arrhythmias.
View the properly rendered notebook with nbviewer here.
Cardiac arrhythmias occur when the electrical impulses of the heart don't function properly. These irregular impulses may manifest themselves as anxiety, fatigue, and dizziness. While some cases of cardiac arrhythmias are relatively harmless, others are indicative of larger issues including high blood pressure, diabetes, and heart attacks. An electrocardiogram (ECG or EKG) is a tool medical professionals can use to visualize the electrical workings of the heart. Analysis of these ECG signals accompanied by other testing measures allows for the diagnosis of cardiac problems such as arrhythmias. Quickly and accurately detecting cardiac arrhythmias through analyzing ECG signals would allow healthcare professionals to better apply appropriate intervention techniques
This project emphasizes the following skills:
- Creating static and dynamic signal visualizations using Matplotlib and Seaborn.
- Process large, high-dimensionality datasets for machine learning applications using Pandas and Numpy.
- Develop and tune a deep neural network on a validation set suing TensorFlow's Keras.
- Evaluate the effectiveness of a neural network using Scikit-Learn and Keras.
- Providing instructions for easily reproducible results.
This repository is written using Python v3.7.4 and Jupyter Notebook v6.0.3.
The following packages are recommended for proper function:
Requirement | Version |
---|---|
Pandas | 1.0.1 |
Matplotlib | 3.1.3 |
Numpy | 1.18.1 |
Seaborn | 0.10.0 |
Scikit-learn | 0.22.1 |
TensorFlow | 2.3.0 |
Keras | 2.4.3 |
Installation instructions for these packages can be found in their respective documentation.
This project has the following architecture:
arrhythmia-detector
├─ arrhythmia_detector.ipynb
└─ resources
├─ scripts
├─ model
├─ data
├─ images
└─ plots
The results of this analysis (i.e. the model, plots, and metric) have been included for ease of use. However, all scripts necessary to replicate the results have been included. To validate the results of this analysis do the following:
-
Remove
best_model.h5
from themodel
folder -
Remove all plots from the
plots
folder -
In the
scripts
folder executemodel_training.py
andvisualization_creation.py
.- This can be done through the terminal as follows:
$pwd ../resources/scripts $python model_training.py Data has been processed. Model construction has begun. Testing: layer_units: (128, 96) dropout_1_rate : 0 dropout_2_rate: 0 ... Training complete. Saving model and visualizing training data. $python visualization All plots successfully created.
-
Run
arrhythmia_detector.ipynb
in your preferred notebook viewer - Jupyter Notebook is reccomended. -
Note: Training machine learning models is an inherently stochastic process. Due to this, results may vary slightly.
The foundation of this analysis is built on data collected and processed by the Beth Israel Deaconess Medical Center and MIT. Their MIT-BIH Arrhythmia database has acted as the foundation for many influential cardiac arrhythmia studies.
The data used in this analysis is divided among two csv files:
mitbih_test.csv
- This dataset contains 87553 ECG signals of a single heartbeat measured at 187 instances. Each instance notes the signal's normalized amplitude ranging between 0 and 1. The signal's respective arrhythmia type is also noted.
mitbih_train.csv
- This dataset contains 21891 instances of ECG signals in the same fashion as
mitbih_train
.
- This dataset contains 21891 instances of ECG signals in the same fashion as
More information about the data used in this analysis can be found here.
- Acknowledgments:
- Moody GB, Mark RG. The impact of the MIT-BIH Arrhythmia Database. IEEE Eng in Med and Biol 20(3):45-50 (May-June 2001). (PMID: 11446209)
- Goldberger, A., Amaral, L., Glass, L., Hausdorff, J., Ivanov, P. C., Mark, R., ... & Stanley, H. E. (2000). PhysioBank, PhysioToolkit, and PhysioNet: Components of a new research resource for complex physiologic signals. Circulation [Online]. 101 (23), pp. e215–e220.
Clone this repository to your computer here.