# cvxtz/ecg_heartbeat_classification architecture

> Architecture diagram of the GitHub repository cvxtz/ecg_heartbeat_classification, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cvxtz/ecg_heartbeat_classification
- Repository: https://github.com/cvxtz/ecg_heartbeat_classification

## Overview

This repository is a set of standalone ECG heartbeat classification experiments, not a deployed service. The main workflow loads preprocessed MIT-BIH or PTB heartbeat CSVs, trains a 1D convolutional classifier, and reports test accuracy and F1; PTB transfer variants initialize from MIT-BIH weights, with one freezing convolutional layers. A separate EDA script summarizes and plots test heartbeats. Each experiment implements its own data preparation, model, and evaluation inline; the graph keeps those workflows together. Evidence is limited to the README and the sampled scripts.

Main entry points: [`code/baseline_ptbdb_transfer_freeze.py`](https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/baseline_ptbdb_transfer_freeze.py) (Frozen transfer), [`code/baseline_ptbdb_transfer_fullupdate.py`](https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/baseline_ptbdb_transfer_fullupdate.py) (Full-update transfer), [`code/baseline_mitbih.py`](https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/baseline_mitbih.py) (MIT-BIH classifier), [`code/baseline_ptbdb.py`](https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/baseline_ptbdb.py) (PTB classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experiments["Classification experiments"]
  node_mitbih_experiment["MIT-BIH classifier<br/>[baseline_mitbih.py]"]
  node_ptbdb_experiment["PTB classifier<br/>[baseline_ptbdb.py]"]
  node_transfer_freeze["Frozen transfer"]
  node_transfer_full["Full-update transfer"]
end

subgraph group_analysis["Dataset analysis"]
  node_eda["Heartbeat EDA<br/>[eda.py]"]
end

subgraph group_inputs["Data and weights"]
  node_mitbih_data["MIT-BIH CSVs"]
  node_ptbdb_data["PTB CSVs"]
  node_mitbih_weights["MIT-BIH weights"]
  node_ptbdb_weights["PTB checkpoints"]
end

node_researcher(("Researcher"))

node_researcher -->|"runs experiment"| node_mitbih_experiment
node_researcher -->|"runs experiment"| node_ptbdb_experiment
node_researcher -->|"runs experiment"| node_transfer_freeze
node_researcher -->|"runs experiment"| node_transfer_full
node_researcher -->|"runs analysis"| node_eda
node_mitbih_experiment -->|"reads CSVs"| node_mitbih_data
node_mitbih_experiment -->|"writes checkpoint"| node_mitbih_weights
node_ptbdb_experiment -->|"reads CSVs"| node_ptbdb_data
node_ptbdb_experiment -->|"writes checkpoint"| node_ptbdb_weights
node_transfer_freeze -->|"reads CSVs"| node_ptbdb_data
node_transfer_freeze -->|"loads weights"| node_mitbih_weights
node_transfer_freeze -->|"writes checkpoint"| node_ptbdb_weights
node_transfer_full -->|"reads CSVs"| node_ptbdb_data
node_transfer_full -->|"loads weights"| node_mitbih_weights
node_transfer_full -->|"writes checkpoint"| node_ptbdb_weights
node_eda -->|"reads test CSV"| node_mitbih_data

click node_mitbih_experiment "https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/baseline_mitbih.py"
click node_ptbdb_experiment "https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/baseline_ptbdb.py"
click node_transfer_freeze "https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/baseline_ptbdb_transfer_freeze.py"
click node_transfer_full "https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/baseline_ptbdb_transfer_fullupdate.py"
click node_eda "https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/eda.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mitbih_experiment,node_ptbdb_experiment,node_transfer_freeze,node_transfer_full toneBlue
class node_eda toneAmber
class node_mitbih_data,node_ptbdb_data,node_mitbih_weights,node_ptbdb_weights toneMint
class node_researcher toneIndigo
```

## Components

### Classification experiments

- [MIT-BIH classifier](https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/baseline_mitbih.py): `code/baseline_mitbih.py`
- [PTB classifier](https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/baseline_ptbdb.py): `code/baseline_ptbdb.py`
- [Frozen transfer](https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/baseline_ptbdb_transfer_freeze.py): `code/baseline_ptbdb_transfer_freeze.py`
- [Full-update transfer](https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/baseline_ptbdb_transfer_fullupdate.py): `code/baseline_ptbdb_transfer_fullupdate.py`

### Dataset analysis

- [Heartbeat EDA](https://github.com/cvxtz/ecg_heartbeat_classification/blob/master/code/eda.py): `code/eda.py`

### Data and weights

- **MIT-BIH CSVs**
- **PTB CSVs**
- **MIT-BIH weights**
- **PTB checkpoints**

### Other components

- **Researcher**

## Connections

- Researcher → MIT-BIH classifier: runs experiment (evidence: `README.md`)
- Researcher → PTB classifier: runs experiment (evidence: `README.md`)
- Researcher → Frozen transfer: runs experiment (evidence: `README.md`)
- Researcher → Full-update transfer: runs experiment (evidence: `README.md`)
- Researcher → Heartbeat EDA: runs analysis (evidence: `code/eda.py`)
- MIT-BIH classifier → MIT-BIH CSVs: reads CSVs (evidence: `code/baseline_mitbih.py`)
- MIT-BIH classifier → MIT-BIH weights: writes checkpoint (evidence: `code/baseline_mitbih.py`)
- PTB classifier → PTB CSVs: reads CSVs (evidence: `code/baseline_ptbdb.py`)
- PTB classifier → PTB checkpoints: writes checkpoint (evidence: `code/baseline_ptbdb.py`)
- Frozen transfer → PTB CSVs: reads CSVs (evidence: `code/baseline_ptbdb_transfer_freeze.py`)
- Frozen transfer → MIT-BIH weights: loads weights (evidence: `code/baseline_ptbdb_transfer_freeze.py`)
- Frozen transfer → PTB checkpoints: writes checkpoint (evidence: `code/baseline_ptbdb_transfer_freeze.py`)
- Full-update transfer → PTB CSVs: reads CSVs (evidence: `code/baseline_ptbdb_transfer_fullupdate.py`)
- Full-update transfer → MIT-BIH weights: loads weights (evidence: `code/baseline_ptbdb_transfer_fullupdate.py`)
- Full-update transfer → PTB checkpoints: writes checkpoint (evidence: `code/baseline_ptbdb_transfer_fullupdate.py`)
- Heartbeat EDA → MIT-BIH CSVs: reads test CSV (evidence: `code/eda.py`)
