Skip to content

05 — Class imbalance

flowchart LR
    RARE["rare F/Q beats"] --> W["weight mistakes 50x\nforce into batches"] --> SEEN["model actually learns them"]
Class group Rough share What the model wants to do
N the bulk guess this always
V, S small learn if forced
F, Q tiny (<1%) ignore completely

The lazy trick (always guess common classes) scores well overall while catching nothing rare. Fixes used in heartbeat literature:

  • Class weights: rare-class mistakes count extra (missing F can count 50x missing N).
  • Weighted sampling: every training batch forced to include rare beats.
  • Focal loss: auto-focuses learning on hard examples, down-weights easy ones.

Expectation: Q and F stay weak everywhere — all papers struggle there. Winning means N, V, S strong while F/Q degrade gracefully. That is honest science, and ../research/results.md will say so plainly.

Next: 06-ecg-signal-processing.md