skills/timeseries/sensor-modality-dropout/SKILL.md
Randomly zero out entire sensor modalities during training with a learned gate to handle missing modalities at inference
npx skillsauth add wenmin-wu/ds-skills timeseries-sensor-modality-dropoutInstall 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.
In multi-sensor systems, some modalities may be missing at inference time (sensor failure, power saving). Train robustness by randomly zeroing entire modality channels with probability p, while a gating network learns to predict whether a modality is active. At inference, the gate automatically downweights missing modalities.
import torch
import torch.nn as nn
import numpy as np
class ModalityDropout(nn.Module):
def __init__(self, n_channels, drop_prob=0.3):
super().__init__()
self.drop_prob = drop_prob
self.gate = nn.Sequential(
nn.AdaptiveAvgPool1d(1), nn.Flatten(),
nn.Linear(n_channels, 16), nn.ReLU(),
nn.Linear(16, 1), nn.Sigmoid()
)
def forward(self, x): # x: (B, C, T)
gate_val = self.gate(x) # (B, 1)
if self.training:
mask = (torch.rand(x.size(0), 1, 1, device=x.device) > self.drop_prob).float()
x = x * mask
return x * gate_val.unsqueeze(2)
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