skills/timeseries/event-anchored-frame-sync/SKILL.md
Align low-Hz sensor data to high-fps video by anchoring a named event (e.g. ball_snap) to a known frame index and converting time offsets via fps
npx skillsauth add wenmin-wu/ds-skills timeseries-event-anchored-frame-syncInstall 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.
Sensor and video streams are rarely recorded with perfectly synchronized clocks. In the NFL Helmet Assignment competition, player tracking (NGS) is 10Hz with wall-clock timestamps while video is ~60fps counted from frame 0 — you cannot join them by timestamp. The trick is that both streams share a discrete labeled event: the ball_snap. If you know which video frame contains the snap (a constant per dataset), you can anchor the NGS row for event == 'ball_snap' to that frame, compute a snap_offset in seconds, multiply by fps, and derive est_frame for every NGS row. Result: a deterministic join key between the two streams with millisecond-level accuracy.
def add_est_frame(tracks, fps=59.94, snap_frame=10):
tracks = tracks.copy()
tracks['game_play'] = (tracks['gameKey'].astype(str) + '_'
+ tracks['playID'].astype(str).str.zfill(6))
tracks['time'] = pd.to_datetime(tracks['time'])
# Anchor: for each play, find the wall-clock time of the ball_snap row
snap_time = (tracks.query('event == "ball_snap"')
.groupby('game_play')['time'].first().to_dict())
tracks['snap'] = tracks['game_play'].map(snap_time)
# Offset from snap in seconds, then convert to frame index
tracks['snap_offset'] = (
(tracks['time'] - tracks['snap']).dt.total_seconds()
)
tracks['est_frame'] = (
(tracks['snap_offset'] * fps) + snap_frame
).round().astype(int)
return tracks
event == <anchor> in the sensor streamoffset_sec = sensor_time - anchor_time for every sensor rowest_frame = round(offset_sec * fps + anchor_frame)find_nearest(est_frames, video_frame) to pick one.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