Skip to content

Commit abeb2e0

Browse files
Update README.md
1 parent 92d10a8 commit abeb2e0

File tree

1 file changed

+143
-2
lines changed

1 file changed

+143
-2
lines changed

README.md

Lines changed: 143 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,143 @@
1-
# template
2-
A Template Repository for OpenSpringFest (OSF)
1+
# ECG Arrhythmia Classification using DL Models
2+
3+
This project implements a **deep learning model using LSTM networks** to classify ECG heartbeats from the **MIT-BIH Arrhythmia Database** into different arrhythmia categories.
4+
5+
---
6+
7+
## Overview
8+
9+
- **Goal:** Automatic classification of ECG heartbeats into arrhythmia types.
10+
- **Model:** Stacked LSTM architecture for multi-class classification.
11+
- **Processing:** Automated ECG preprocessing — filtering, R-peak detection, segmentation, normalization.
12+
- **Evaluation:** Includes metrics and visualizations.
13+
- **Accuracy:** Achieves around **98% test accuracy** on MIT-BIH dataset.
14+
15+
---
16+
17+
## Dataset
18+
19+
**MIT-BIH Arrhythmia Database (PhysioNet)**
20+
- 48 half-hour two-channel ECG recordings
21+
- Sampling Rate: 360 Hz
22+
- Expert-annotated beats
23+
24+
**Classes:**
25+
- N — Normal beats
26+
- S — Supraventricular ectopic beats
27+
- V — Ventricular ectopic beats
28+
- F — Fusion beats
29+
- Q — Unknown/Other beats
30+
31+
---
32+
33+
## Model Architecture
34+
```
35+
Input (250, 1)
36+
37+
LSTM(128, return_sequences=True)
38+
39+
Dropout + BatchNormalization
40+
41+
LSTM(64, return_sequences=True)
42+
43+
Dropout + BatchNormalization
44+
45+
LSTM(32)
46+
47+
Dropout + BatchNormalization
48+
49+
Dense(64, ReLU) → Dense(32, ReLU)
50+
51+
Dense(num_classes, Softmax)
52+
```
53+
54+
**Training Details:**
55+
- Optimizer: Adam (lr = 0.001)
56+
- Loss: Categorical Crossentropy
57+
- Batch Size: 128
58+
- Max Epochs: 100
59+
- Early Stopping and Learning Rate Scheduling enabled
60+
61+
---
62+
63+
## Performance
64+
65+
| Metric | Value |
66+
|--------|--------|
67+
| Accuracy | ~98% |
68+
| Precision | ~97% |
69+
| Recall | ~96% |
70+
| F1-Score | ~97% |
71+
72+
**Generated Visualizations:**
73+
- Training history (accuracy/loss)
74+
- Confusion matrices
75+
- Sample predictions with confidence scores
76+
- Raw vs filtered signal comparisons
77+
78+
---
79+
80+
## Workflow
81+
82+
1. **Preprocessing** — Run:
83+
```bash
84+
python ecg_preprocessing.ipynb
85+
86+
```
87+
- Downloads MIT-BIH data
88+
- Filters noise
89+
- Segments beats and normalizes them
90+
91+
2. **Training** — Run:
92+
93+
```python
94+
lstm_model.ipynb
95+
96+
```
97+
- Trains the LSTM model
98+
- Saves best and final model checkpoints
99+
100+
3. **Prediction Example:**
101+
```python
102+
from tensorflow import keras
103+
import numpy as np
104+
105+
model = keras.models.load_model('best_lstm_model.keras')
106+
data = np.load('ecg_mitdb_processed.npz')
107+
preds = model.predict(data['X'][:10])
108+
classes = np.argmax(preds, axis=1)
109+
```
110+
111+
## Project Structure
112+
``` ecg-arrhythmia-classification/
113+
├── ecg_preprocessing.ipynb
114+
├── lstm_model.py
115+
├── requirements.txt
116+
├── README.md
117+
├── data
118+
├── ecg_mitdb_processed.npz
119+
├── mitdb
120+
├── final_lstm_model.keras
121+
├── best_lstm_model.keras
122+
├── evaluation_results.json
123+
└── *.png (visualizations)
124+
```
125+
## Requirements
126+
```
127+
numpy>=1.21.0
128+
matplotlib>=3.4.0
129+
scipy>=1.7.0
130+
scikit-learn>=0.24.0
131+
tensorflow>=2.8.0
132+
wfdb>=4.0.0
133+
seaborn>=0.11.0
134+
tqdm>=4.62.0
135+
```
136+
137+
138+
139+
140+
141+
142+
143+

0 commit comments

Comments
 (0)