I did this project using machine learning to classify ECG (Electrocardiogram) signals as normal or abnormal using real heartbeat data. It was inspired by the idea of using AI in predictive healthcare — helping detect irregular heart activity automatically using signal data.
The project uses ECG datasets from the PTB Diagnostic ECG Database. The files used are:
ptbdb_normal.xlsx– contains normal ECG signalsptbdb_abnormal.xlsx– contains abnormal ECG signals
Each row in these files contains 187 numerical values representing a patient's heartbeat signal.
- Loaded the normal and abnormal ECG datasets using pandas
- Each sample was labeled:
0→ normal1→ abnormal
- Added a
labelcolumn to both datasets - Combined both into a single DataFrame
- Shuffled the rows randomly for unbiased learning
- Used
train_test_split()to divide the data:- 80% for training
- 20% for testing
- Trained a RandomForestClassifier using the signal data
- The model learned to detect patterns in ECG signals
- The model achieved 100% accuracy on the test set
- Evaluated using:
- Accuracy score
- Confusion matrix
- Precision, recall, and F1-score
The model's performance was perfect:
- Accuracy: 100%
- Precision, Recall, F1-score: All 1.00
Accuracy: 1.0
Confusion Matrix: [[ 787 0] [ 0 2123]]
Classification Report: precision recall f1-score support
0 1.00 1.00 1.00 787
1 1.00 1.00 1.00 2123
accuracy 1.00 2910
macro avg 1.00 1.00 1.00 2910
weighted avg 1.00 1.00 1.00 2910
Shows first 5 rows of normal and abnormal ECG data used for training.
Combined dataset with over 14,000 samples and 310 features.
Model performance showing 100% accuracy and perfect classification report.
Install the dependencies using:
pip install -r requirements.txt

