DeepECG-Kit
A deep learning library for ECG analysis and arrhythmia classification. Provides a CLI for training, evaluation, inference, feature extraction, and explainability across 26 model architectures and 5 ECG datasets.
Documentation: https://stevenah.github.io/deepecg-kit/
Installation
pip install deepecgkit
For local development (Python ≥ 3.10):
uv sync --group dev # blessed path
pip install -e ".[dev]" # pip alternative
See CONTRIBUTING.md for the development workflow.
Usage
deepecg train -m kanres -d af-classification # train (downloads the dataset, ~100 MB)
deepecg evaluate --checkpoint runs/<run> -d af-classification
deepecg predict --checkpoint runs/<run> --input ecg.npy --sampling-rate 300
deepecg extract-features --checkpoint runs/<run> -d af-classification -o features.npz
deepecg explain --checkpoint runs/<run> --input ecg.npy -o explanations/
deepecg list-models # all 26 architectures
deepecg list-datasets # sizes, signal shape, local status
deepecg info -m kanres
Training writes a run directory runs/{timestamp}-{model}-{dataset}-seed{seed}/ containing
checkpoints (top 3 by validation loss), training plots, test metrics
(classification_metrics.csv, confusion matrix, calibration curve), and run metadata, and ends
by printing the best checkpoint. Anywhere a checkpoint is expected, the run directory can be
passed instead and stands for that best checkpoint.
Checkpoints describe themselves: they record the architecture, the class names, and the
preprocessing the training data went through (sampling rate, segment length, normalisation).
That is why --model is optional above, why deepecg evaluate rebuilds the dataset the way
the model was trained, and why deepecg predict can take a raw recording: it is resampled,
segmented and normalised to match before it reaches the model.
Run deepecg list-models and deepecg list-datasets for the full catalogs — datasets cover
PhysioNet 2017 (af-classification), PTB-XL (ptbxl), MIT-BIH AFDB (mitbih-afdb),
Long-Term AFDB (ltafdb), and the combined unified-af. Each dataset is used at its own
sampling rate (300 Hz for the AF datasets, 500 Hz for PTB-XL) unless --sampling-rate says
otherwise.
Datasets are downloaded on first use into ~/.deepecgkit/datasets; set DEEPECGKIT_HOME to
keep them somewhere else. Downloads come from PhysioNet's open-data mirror, fall back to
physionet.org, and resume if interrupted.
Experiments
Experiment sweeps are defined in experiments.yaml and run via
python scripts/run_experiments.py. Each experiment trains every configured model on every
dataset across multiple seeds (default seeds: [42, 43, 44, 45, 46] — 5 runs per
model/dataset pair), saving to runs/{model}-{dataset}-seed{seed}/.
Aggregate and analyse finished runs with:
deepecg aggregate --runs-dir runs --output-dir analysis --emit-latex
deepecg rank --runs-dir runs --metric f1
Default Training Parameters
Defined once in deepecgkit/cli/defaults.py:
| Parameter | Value |
|---|---|
| Epochs | 50 |
| Batch size | 32 |
| Learning rate | 0.001 |
| Optimizer | Adam |
| LR scheduler | ReduceLROnPlateau (factor=0.5, patience=5) |
| Early stopping patience | 10 |
| Validation split | 0.2 |
| Test split | 0.1 |
| Seed | 42 |
| Sampling rate | the dataset's own (override with --sampling-rate) |
| Data loader workers | 0 |
References
Datasets
-
af-classification — Clifford GD, Liu C, Moody B, Li-wei HL, Silva I, Li Q, Johnson AE, Mark RG. "AF Classification from a Short Single Lead ECG Recording: The PhysioNet/Computing in Cardiology Challenge 2017." Computing in Cardiology (CinC), 2017. [PhysioNet]
-
ptbxl — Wagner P, Strodthoff N, Bousseljot RD, Kreiseler D, Lunze FI, Samek W, Schaeffter T. "PTB-XL, a Large Publicly Available Electrocardiography Dataset." Scientific Data, 7(1):154, 2020. [PhysioNet]
-
mitbih-afdb — Moody GB, Mark RG. "A New Method for Detecting Atrial Fibrillation Using R-R Intervals." Computers in Cardiology, 10:227–230, 1983. [PhysioNet]
-
ltafdb — Petrutiu S, Sahakian AV, Swiryn S. "Abrupt Changes in Fibrillatory Wave Characteristics at the Termination of Paroxysmal Atrial Fibrillation in Humans." Europace, 9(7):466–470, 2007. [PhysioNet]
-
unified-af — Combined cross-dataset using af-classification, mitbih-afdb, and ltafdb (see references above).
Models
-
convnext-v2 — Woo S, Debnath S, Hu R, Chen X, Liu Z, Kweon IS, Xie S. "ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders." CVPR, 2023. [GitHub]
-
deep-res-cnn — Elyamani H. "ECG Classification Using Deep Residual CNN." 2022. [GitHub]
-
inception-time — Fawaz HI, Lucas B, Forestier G, Pelletier C, Schmidt DF, Weber J, Webb GI, Idoumghar L, Muller PA, Petitjean F. "InceptionTime: Finding AlexNet for Time Series Classification." Data Mining and Knowledge Discovery, 34:1936–1962, 2020. [GitHub]
-
xresnet / xresnet1d-benchmark — Strodthoff N, Wagner P, Schaeffter T, Samek W. "Deep Learning for ECG Analysis: Benchmarks and Insights from PTB-XL." IEEE Journal of Biomedical and Health Informatics, 25(5):1519–1528, 2021. [GitHub]
Metadata
Release files for deepecgkit 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| deepecgkit-0.3.0.tar.gz | 324.8 kB | With provenance | Details for deepecgkit-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| deepecgkit-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for deepecgkit-0.3.0-py3-none-any.whl |
Total release size: 604.2 kB
Release files / deepecgkit-0.3.0.tar.gz
| Download URL | deepecgkit-0.3.0.tar.gz |
|---|---|
| Size | 324.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
964e7dc499f27f2a5ee42983ba39b3b81f2f3807689a03b4ee3640df25632713
|
|
BLAKE2b-256 checksum How to use checksums |
aa4d6d5e891d293529f180e071cce7f7a48e0cf34821a36fe64610cba21c75ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logRelease files / deepecgkit-0.3.0-py3-none-any.whl
| Download URL | deepecgkit-0.3.0-py3-none-any.whl |
|---|---|
| Size | 279.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c11e4239e67b103067fc9e7f7b6e248e3d144412a08928b3ce83b9d8dbd7b583
|
|
BLAKE2b-256 checksum How to use checksums |
830de860e9e7633e9fa49befb30f297c2c17f9c99ce4957d46e5b191fbc7fa1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logSecurity for deepecgkit 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for deepecgkit-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.