This is a CNN based model which aims to automatically classify the ECG signals of a normal patient vs. a patient with AF and has been trained to achieve up to 93.33% validation accuracy. The dataset details are given at the How to use section.
Additionally, Github often fails to load iPython Notebook files for preview. Hence, the Notebooks can also be viewed at the following links:
- Python 3
- Pandas
- Numpy
- Matplotlib
- Tensorflow
- Keras
Visit: https://www.python.org/downloads/ and download the version suitable for your System
Open Command Prompt (Windows) or Terminal (Linux) and type in the following command:
pip install pandas
Visit: Pandas Install Instructions for details.
Open Command Prompt (Windows) or Terminal (Linux) and type in the following command:
pip install numpy
Visit: Numpy Install Instructions for details.
Open Command Prompt (Windows) or Terminal (Linux) and type in the following command:
pip install matplotlib
Visit: Matplotlib Install Instructions for details.
There are two formats of Tensorflow. One is for the CPU version and the other is for GPU version (Nvidia only)
The CPU installation is quite straight forward installation by the following command:
pip install tensorflow
The GPU version requires the installation of CUDA and cuDNN drivers from Nvidia. This is a relatively complicated process and it is suggested to visit the official guide for this.
Visit: Tensorflow GPU Install Instructions for details.
Even though Keras comes built inside tensorflow, in this repository, the code that is used is using the external Keras library. It can be downloaded using the following method.
Open Command Prompt (Windows) or Terminal (Linux) and type in the following command:
pip install keras
Visit: Keras Install Instructions for details.
- Download the dataset from MIT-BIH Atrial Fibrillation Database
and select the following parameters:EDIT: The dataset source has changed, and I have not verfieid this data, it may be the same or different from the one I had used for training.Database -PAF Prediction Challenge Database (afpdb)Record - nXX (for eachNormal Patientdata) and pXX (for eachAbnoramal Patientdata)Length -to endTime Format -SamplesToolbox -Export signals to CSV
- Put them in the desired path and change the path of the
Data_Preprocessing.ipynbto be able to read the signals from the downloaded CSVs. - Save the processed dataset as a Numpy Object in the desired location.
- In the file
Model.ipynbread the saved processed dataset and train the model. - Any unknown dataset can be then classified by using
model.predict()function after themodelhas been trained successfully.
This is a preliminary attempt and is a work-in-progress.
- In this particular implementation, only 10 Normal patients' data and 10 Abnormal patients' data has been taken and used. The entire dataset has not been used. Using the complete dataset may significantly improve the model accuracy.
- The CNN architecture can be further modified so as to find an optimal architecture that will learn better than the existing one.
- As per experimentation, SGD (Stochastic Gradient Descent) optimizer works the best. However, with further change in model architecture, other optimizers like Adam and RMSProp may outperform the rather primitive SGD optimizer.