8000 GitHub - kladak/motioncode: MotionCode classifies synthetic ECG waveforms with reproducible baselines and a NumPy 1D CNN. · GitHub
[go: up one dir, main page]

Skip to content

About

MotionCode classifies synthetic ECG waveforms with reproducible baselines and a NumPy 1D CNN.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

MotionCode

ECG-like waveform classification with a reproducible pipeline and real baselines.

Spec: SPEC.md.

Visual

Logistic baseline, test confusion matrix (synthetic CI, seed=42)

Regenerated by make train-ci. A committed copy of the logistic plot lives at docs/confusion_logistic.png; reports/confusion_*.png from a fresh train are gitignored.

Demo / Results

Metrics from a make train-ci run (2026-09-13): n_per_class=24, length 256, split 66/15/15, leakage_ok=true.

Model Accuracy Macro-F1 AUROC (ovr)
dummy (most_frequent) 0.267 0.105 0.500
logistic (features) 0.733 0.698 0.869
random forest (features) 0.733 0.697 0.907
cnn1d (25 epochs, numpy) 0.467 0.357 0.723

Notes:

  • Feature baselines beat a majority dummy on a leakage-checked split.
  • A tiny teaching CNN beats dummy after more epochs but still trails handcrafted features on this short synthetic draw.
  • Absolute numbers move with seed / n_per_class; regenerate with make train-ci and trust reports/metrics.json.

Walkthrough: make train-ci → inspect reports/metrics.json + confusion plots → python -m motioncode.cli infer --model logistic --class-name irregular.

Run Locally

Offline (no network):

python -m pip install -e ".[dev]"
make test
make train-ci          # configs/ci.yaml → reports/metrics.json
python -m motioncode.cli infer --model logistic --class-name irregular
# or:
make demo

Local (larger synthetic draw):

make train             # configs/synthetic.yaml

Data

motioncode/data/synthetic.py generates waveforms with four morphology labels: regular, irregular, wide and burst. CI trains on this generator. An optional PhysioNet path is documented in PROVENANCE.md.

What you get

preprocess → grouped train/val/test (record_id) + leakage checks
  → dummy / logistic / forest (handcrafted features)
  → tiny numpy 1D CNN (raw window)
  → accuracy, macro-F1, AUROC (ovr), confusion plots
  → reports/metrics.json
Piece Path
Spec SPEC.md
Experiment YAMLs configs/
Generator + schema motioncode/data/
Leakage-aware split motioncode/data/splits.py
Features / baselines / CNN motioncode/features.py, motioncode/models/
Train + metrics motioncode/pipeline.py
CLI python -m motioncode.cli {train,infer,demo}
Optional PhysioNet helper scripts/download_physionet.py
CI .github/workflows/ci.yml

Dataset paths

  1. Synthetic (default, and what CI uses): in-repo generator, no network.
  2. PhysioNet (optional): python scripts/download_physionet.py after pip install '.[physionet]'. See PROVENANCE.md.

Tests

make test

Covers split leakage (record id + waveform hash), tensor shapes, deterministic seed for synthetic + sklearn baselines, CNN forward shapes, and an end-to-end CI-config smoke (baselines).

License

MIT. See LICENSE.

About

MotionCode classifies synthetic ECG waveforms with reproducible baselines and a NumPy 1D CNN.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0