skills/timeseries/multi-scale-rolling-features/SKILL.md
Computes rolling mean/max/std at multiple window sizes plus total variation (abs first differences) for multi-resolution temporal context.
npx skillsauth add wenmin-wu/ds-skills timeseries-multi-scale-rolling-featuresInstall 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.
Create rolling aggregates at multiple window sizes (minutes to hours) to capture patterns at different temporal scales. Add total variation features (rolling stats of absolute first differences) to distinguish gradual drift from sudden jumps. This gives tree models and NNs rich temporal context without explicit sequence modeling.
import polars as pl
def make_rolling_features(df, value_cols, windows_min, sample_rate=12):
"""Generate multi-scale rolling features.
Args:
df: DataFrame with sensor columns
value_cols: columns to aggregate (e.g., ['enmo', 'anglez'])
windows_min: list of window sizes in minutes (e.g., [5, 30, 120, 480])
sample_rate: samples per minute
"""
features = []
for mins in windows_min:
win = sample_rate * mins
for var in value_cols:
# Raw signal aggregates
features.extend([
pl.col(var).rolling_mean(win, center=True, min_periods=1).alias(f'{var}_{mins}m_mean'),
pl.col(var).rolling_max(win, center=True, min_periods=1).alias(f'{var}_{mins}m_max'),
pl.col(var).rolling_std(win, center=True, min_periods=1).alias(f'{var}_{mins}m_std'),
])
# Total variation (abs first differences)
features.extend([
pl.col(var).diff().abs().rolling_mean(win, center=True, min_periods=1).alias(f'{var}_tv_{mins}m_mean'),
pl.col(var).diff().abs().rolling_std(win, center=True, min_periods=1).alias(f'{var}_tv_{mins}m_std'),
])
return df.with_columns(features)
.diff().abs())center=True so features look both forward and backwarddata-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