PresentSelective Prediction for ECG AI

Reduced Leads

Can a two-lead ECG be trusted for a given diagnosis? This project answers that one recording at a time, and knows when to say "get a full 12-lead instead."

Wearables and portable devices only record a few ECG leads. A good average accuracy doesn't tell you what you need in practice: for this recording and this diagnosis, should you trust the reduced-lead call, grab a full 12-lead ECG, or ask an expert? I trained lead-aware transformers on the PTB-XL dataset, tested them on reduced lead sets, and turned their calibrated scores into one of those three actions.

I was strict about evaluation. Every decision policy is fitted on a validation fold with patient-level risk control, frozen, and then audited exactly once on a locked test fold. Before it reads a single test prediction, the audit checks hashes, schemas, and provenance, so thresholds can't sneak in from the test set.

01

Patient-Disjoint Data Protocol

PTB-XL comes with ten folds that never share a patient, so I gave each one a job: folds 1-7 train the weights, fold 8 picks the checkpoint, fold 9 calibrates and fits the decision policy, and fold 10 gets audited once. I turned the SCP-ECG codes into multi-hot labels and froze the label schema and evaluation protocol as machine-readable contracts.

02

Lead-Aware Transformer Training

Each lead gets cut into 0.5 s patches with its own embedding, then the model alternates between attending across leads and across time before the diagnosis heads. I trained matched models on all 12 leads, on just leads I+II, and with random lead dropping, logging manifests, curves, and RNG state so any run can resume exactly.

03

Calibration, Routing & Locked Audits

On the validation fold, I calibrated the scores and fitted routing policies that either trust the reduced-lead call, ask for a 12-lead ECG and hand it to a rescue model, or refer to an expert, all with Bonferroni-corrected patient-level risk bounds. Every policy was frozen before any test predictions were exported. Then came the fit-free audits and a few post-hoc checks on looser risk limits.

Built a ~9.8M-parameter transformer in PyTorch that attends across leads and across time, uses learned tokens for missing leads, and predicts 5 superclasses, 44 diagnostic subcodes, and 12 rhythm labels at once.

Found that reduced-lead quality depends on the diagnosis. Training directly on leads I+II raised two-lead superclass macro-AUROC from 0.859 to 0.867 and helped with MI and conduction disorders, but AFIB/AFLT ranking dropped from 0.958 to 0.929.

Added patient-level risk control with exact binomial bounds, conformal risk control, and clustered bootstrap stats. At the prespecified 2% error limit, no model was safe enough to automatically rule out AFIB/AFLT, so the system escalated every case, which is exactly what it should do.

My favorite result was a negative one: a model with high AUROC still couldn't be trusted with a single automated decision at a clinically meaningful risk limit. Making "I'm not sure" the safe default, and locking the test set before peeking, mattered more than chasing another point of accuracy.