skills/cv/lateralized-label-flip-tta-disable/SKILL.md
Disable horizontal-flip augmentation (both train-time and TTA) when label columns encode left/right anatomy — flipping silently corrupts the targets because "Left ICA" must map to "Right ICA" after a flip, not stay as "Left ICA"
npx skillsauth add wenmin-wu/ds-skills cv-lateralized-label-flip-tta-disableInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Horizontal flip is one of the cheapest TTA tricks and almost always improves classification. But on datasets where labels are lateralized — left/right kidney, left/right common carotid, left/right ICA aneurysm — naive RandomHorizontalFlip is a silent disaster: the pixels flip but the target string still says "Left X". The model learns a wrong mapping and TTA averages predictions of two opposite labels. There are two valid responses: (A) disable horizontal flip everywhere, or (B) implement a flip+label-swap transform that simultaneously mirrors the image and swaps the corresponding column pairs in the target vector. (A) is simpler and bulletproof; (B) recovers the augmentation budget if you control the transforms tightly. Default to (A) unless you have label-pair metadata.
import albumentations as A
# Option A — safest: just disable horizontal flip
TRAIN_TFM = A.Compose([
A.Resize(384, 384),
# NO HorizontalFlip
A.VerticalFlip(p=0.5), # safe if no up/down semantics
A.Rotate(limit=15, p=0.5),
A.Normalize(),
])
TTA_TRANSFORMS = [] # no flip TTA
# Option B — flip + label swap (only if you have a pair table)
LR_PAIRS = [('Left ICA', 'Right ICA'), ('Left MCA', 'Right MCA'), ...]
def flip_with_label_swap(img, label_vec, cols):
img = img[:, ::-1, :].copy()
new = label_vec.copy()
for l, r in LR_PAIRS:
new[cols.index(l)], new[cols.index(r)] = label_vec[cols.index(r)], label_vec[cols.index(l)]
return img, new
HorizontalFlip from the train transform pipeline (or wrap in a custom class for option B)data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF