ECG-like waveform classification with a reproducible pipeline and real baselines.
Spec: SPEC.md.
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.
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 withmake train-ciand trustreports/metrics.json.
Walkthrough: make train-ci → inspect reports/metrics.json + confusion plots → python -m motioncode.cli infer --model logistic --class-name irregular.
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 demoLocal (larger synthetic draw):
make train # configs/synthetic.yamlmotioncode/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.
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 |
- Synthetic (default, and what CI uses): in-repo generator, no network.
- PhysioNet (optional):
python scripts/download_physionet.pyafterpip install '.[physionet]'. SeePROVENANCE.md.
make testCovers 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).
MIT. See LICENSE.