skills/timeseries/gradient-event-boundary-detection/SKILL.md
Detect event start/end boundaries in time series by finding extrema of the first derivative (steepest gradient points)
npx skillsauth add wenmin-wu/ds-skills timeseries-gradient-event-boundary-detectionInstall 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 events with gradual onset and offset (transits, dips, ramps), locate boundaries by computing the first derivative and finding its extrema. The steepest descent marks event start (ingress); steepest ascent marks event end (egress). Works without threshold tuning.
import numpy as np
def detect_event_boundaries(signal, search_start=None, search_end=None):
"""Find event ingress/egress via gradient extrema.
Args:
signal: 1D array of the time series
search_start/end: optional tuple (lo, hi) to constrain search region
Returns:
(ingress_idx, egress_idx)
"""
event_min = np.argmin(signal)
# Search for steepest descent before minimum
pre = signal[:event_min]
grad_pre = np.gradient(pre)
ingress = np.argmin(grad_pre) # most negative gradient
# Search for steepest ascent after minimum
post = signal[event_min:]
grad_post = np.gradient(post)
egress = np.argmax(grad_post) + event_min
return ingress, egress
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