skills/timeseries/sensor-phase-visualization/SKILL.md
EDA visualization of multi-modal sensor data with axvspan shading for labeled behavioral phases and contiguous span detection
npx skillsauth add wenmin-wu/ds-skills timeseries-sensor-phase-visualizationInstall 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.
For labeled time-series data with behavioral phases (gesture, transition, activity), visualize multi-modal sensor signals with color-shaded phase regions. Detects contiguous spans from phase labels using index-diff grouping, and overlays them on sensor plots. Essential EDA for understanding sensor-behavior relationships.
import numpy as np
import matplotlib.pyplot as plt
def shade_phases(ax, timestamps, phase_labels, phase_colors):
"""Overlay colored regions for each behavioral phase.
Args:
ax: matplotlib axis
timestamps: array of time values
phase_labels: array of phase strings per timestep
phase_colors: dict mapping phase name → color
"""
for phase, color in phase_colors.items():
mask = phase_labels == phase
if not mask.any():
continue
indices = np.where(mask)[0]
# Group contiguous indices into spans
breaks = np.where(np.diff(indices) != 1)[0]
spans = np.split(indices, breaks + 1)
for span in spans:
t0, t1 = timestamps[span[0]], timestamps[span[-1]]
ax.axvspan(t0, t1, color=color, alpha=0.25, label=None)
# Usage
fig, axes = plt.subplots(3, 1, figsize=(14, 8), sharex=True)
phases = {"Gesture": "salmon", "Transition": "lightgray"}
for ax, (name, cols) in zip(axes, sensor_groups.items()):
ax.plot(df['time'], df[cols])
shade_phases(ax, df['time'].values, df['phase'].values, phases)
ax.set_ylabel(name)
np.diff(indices) != 1 finds boundaries between non-adjacent labeled regionsdata-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