skills/timeseries/mixup-sequence-augmentation/SKILL.md
Apply MixUp augmentation to padded time-series batches with Beta-distributed lambda and soft label mixing
npx skillsauth add wenmin-wu/ds-skills timeseries-mixup-sequence-augmentationInstall 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.
MixUp linearly interpolates between pairs of training samples and their labels using a Beta-distributed lambda. For time series classification, apply it to padded/fixed-length sequences. Reduces overfitting and improves calibration, especially with small datasets.
import numpy as np
import torch
import torch.nn.functional as F
def mixup_batch(x, y, alpha=0.2):
"""MixUp augmentation for time-series batches.
Args:
x: (B, T, C) input sequences
y: (B, num_classes) one-hot labels
alpha: Beta distribution parameter
"""
lam = np.random.beta(alpha, alpha) if alpha > 0 else 1.0
perm = torch.randperm(x.size(0), device=x.device)
x_mix = lam * x + (1 - lam) * x[perm]
y_mix = lam * y + (1 - lam) * y[perm]
return x_mix, y_mix
def soft_cross_entropy(pred, soft_targets):
"""Cross-entropy loss for soft (mixed) labels."""
return -torch.sum(soft_targets * F.log_softmax(pred, dim=1), dim=1).mean()
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