skills/tabular/next-click-time-delta/SKILL.md
Computes seconds until the next event within a group using diff().shift(-1) on sorted timestamps, capturing user behavior velocity.
npx skillsauth add wenmin-wu/ds-skills tabular-next-click-time-deltaInstall 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 click-stream, transaction, and event-log data, the time gap between consecutive events from the same entity (user, IP, device) is a powerful behavioral signal. Short gaps indicate bots or burst activity; long gaps indicate re-engagement. This technique computes forward-looking time deltas via groupby().transform(lambda x: x.diff().shift(-1)) — no join needed, stays aligned with the original index. Can be computed for multiple group granularities (IP only, IP+app, IP+app+device+os).
import pandas as pd
NEXT_CLICK_GROUPS = [
{'groupby': ['ip']},
{'groupby': ['ip', 'app']},
{'groupby': ['ip', 'app', 'device', 'os', 'channel']},
]
for spec in NEXT_CLICK_GROUPS:
feature_name = '{}_nextClick'.format('_'.join(spec['groupby']))
df[feature_name] = (
df.groupby(spec['groupby'])['click_time']
.transform(lambda x: x.diff().shift(-1))
.dt.seconds
)
# Previous click (backward-looking)
for spec in NEXT_CLICK_GROUPS:
feature_name = '{}_prevClick'.format('_'.join(spec['groupby']))
df[feature_name] = (
df.groupby(spec['groupby'])['click_time']
.transform(lambda x: x.diff())
.dt.seconds
)
diff().shift(-1) gives time to next eventdiff() gives time since previous event.dt.seconds for numeric feature; NaN for first/last in group.transform() avoids merge; for very large data, compute per-group in chunksdata-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