← All work
Explainable AI · Time series · Open source

LIME for time series: explaining a 12-lead ECG classifier

LIME was built for images and tables. I adapted it to 1-D physiological signals so a CNN's diagnosis of a 12-lead ECG can be traced back to the beats and intervals that produced it, and released the method as a reusable package.

LIME for time series: explaining a 12-lead ECG classifier

The problem

Image LIME perturbs super-pixels, and a signal has no such regions. Perturbing individual samples creates physiologically meaningless variants far from the data manifold, so the surrogate ends up explaining noise. The perturbation units had to respect the structure of the signal.

Approach

  • Data: PhysioNet / Computing in Cardiology Challenge 2020, with 12-lead ECGs from the CPSC, INCART, PTB, PTB-XL and Georgia databases. Classes: normal sinus rhythm, atrial fibrillation, ventricular tachycardia/fibrillation and myocardial infarction.
  • Model: a 1-D CNN classifier trained on the pre-processed records.
  • Segment the signal into fixed-width windows, the time-series analogue of super-pixels.
  • Perturb by switching windows off and replacing each with its own mean voltage, which keeps variants smooth and plausible.
  • Score every variant with the CNN, weight variants by cosine similarity to the original, fit a weighted linear surrogate, and rank windows by coefficient.
  • Packaged as modules (preprocessing, training, LIME explanation, visualisation) with an end-to-end notebook under GPL-3.0.

Result

Explanations concentrate on clinically meaningful regions, such as the QRS complex and the ST segment that follows it. The same segment-and-perturb idea later became LIMEXplainer in TelescopeML, with wavelength bands in place of time windows.

Next

Auditable malaria-cell CNN →