time-series-sports
Skill54 starsChanged 8 days agoMITView on GitHub
Engineer and compare time-safe sports form features. Use for rolling windows, EWMA, rest, schedule gaps, early-season handling, and chronological evaluation.
- Installs packages
In this repository19 other files it gives its agents.
- anti-slop-analyticsSkill
- baseline-modelsSkill
- calibration-checkSkill
- data-sourcesSkill
- eda-sportsSkill
- environment-setupSkill
- experiment-logSkill
- feature-rulesSkill
- leakage-auditSkill
- model-cardSkill
- model-interpretationSkill
- predictive-modelingSkill
- ratings-strength-modelsSkill
- results-reportingSkill
- simulation-sportsSkill
- sports-modeling-doctrineSkill
- sports-visualizationSkill
- statistical-modelingSkill
- validation-designSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 6 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 39
Do not use when:
- Distinctive: line 68
Document window/span, shift rule, and min history.
- Distinctive: line 84
Read form_feature_recipes.md when implementing rolling, expanding, or EWMA features.
- Distinctive: line 106
Use identical expanding folds and the complete cases shared by both feature sets.
- Distinctive: line 131
No centered rolling windows that peek forward.
- Distinctive: line 136
Document shift rule in every feature card / experiment log.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Time Series & Form (Sports)
Overview
Sports performance is ordered in time. This skill builds form features and simple trajectory forecasts that are legal at decision time T:
- rolling means
- expanding rates
- EWMA / decay
- rest gaps
- regime flags
Build shifted EWMA features on a user-owned event table, then compare already-computed feature sets on the same folds.
Non-negotiable: shift (or as-of) so the current game is never inside the feature.
When to Use This Skill
Use when:
- Team/player form features for pre-game models
- Rolling averages, EWMA, half-life decay
- Forecasting next-game stats from trajectories
- Handling bye weeks, missing games, season breaks
- Comparing recency-weighted form vs static season averages
- User says “hot streak,” “last 5,” or “recent form”
Do not use when:
| Need | Go instead |
| Pure cross-sectional comparison with no recency | EDA / stats skills |
| Opponent-adjusted strength is the real goal | also ratings-strength-models |
| Static season aggregates already sufficient and time-safe | simpler baselines |
| Feature legality review of a finished matrix | leakage-audit |
Installation
python -m pip install pandas numpy scikit-learn pyarrowBuild features in the user's environment. This repository does not ship a form-feature program.
Workflow
- Define the entity and frequency (team-game, player-game, week).
- Sort by entity + time; handle missing games explicitly.
- Choose window/decay rules; tune only inside training folds.
- Apply
shift(1)/ as-of so current game is never inside the feature. - Compare form features against static baselines under walk-forward validation.
- Watch early-season small-sample explosions — min-games thresholds or shrinkage.
- Document window/span, shift rule, and min history.
- Hand off to baselines / predictive models / leakage audit.
Core Techniques
| Technique | Sports use | Time-safety rule |
| Expanding mean | season-to-date win % / PF | shift before expand |
| Rolling mean | last K games form | shift then rolling |
| EWMA | recency-weighted form | ewm on shifted series |
| Rest days | schedule gaps | diff of game dates |
| Season phase | week number, month | known pre-game |
| Regime split | rule changes, coaching eras | flag by date known at T |
Read form_feature_recipes.md when implementing rolling, expanding, or EWMA features. Read early_season.md when choosing priors, minimum history, or shrinkage. Read rest_and_gaps.md for byes, calendar gaps, and elapsed-time features.
Feature construction
Require non-null entity keys, a parseable time or order field, and numeric or boolean values. Reject infinite values and contradictory event order. Leave missing observations missing. Do not fill them with zero. Shift each value by one event, then apply the rolling or EWMA summary.
Name generated fields so the shift is obvious, for example pre_ewma_points. Group by season when history should not cross the offseason; otherwise say that history carries across seasons. Team files have game_date as a date and no start_time. Convert it with pd.to_datetime before using .dt. Order same-day games with event_time from the data-sources panel (games.start_time). An arbitrary row id is not order.
Opponent features
Compute each participant's history independently, then join the participant and opponent snapshots by stable event/entity keys. Assert that both snapshots were available before the event. Never derive opponent form from the focal row's current result.
Compare feature sets
Use identical expanding folds and the complete cases shared by both feature sets. Validate binary targets and finite numeric features, and do not impute them in the comparison. The comparison evaluates columns that already exist. It does not make an illegal feature legal.
Early-Season Handling
| Problem | Mitigation |
| Week 1 empty history | NA features + drop or league prior |
| Tiny n rolling windows | require pre_games_played >= k |
| Noisy short rolls | shrinkage toward league mean / expanding mean |
| Bye weeks | rest_days feature; don’t fill with zeros blindly |
| Offseason gaps | don’t treat long rest as a normal short-week rest without care |
Validation
Form features are hypotheses. Evaluate alternative windows on identical chronological folds, against a static or simpler baseline.
Tune window/span inside training folds only.
Hard Constraints
- No centered rolling windows that peek forward.
- No “season average including current game.”
- Early-season priors/shrinkage when n is tiny.
- Validate across seasons, not one hot streak.
- Opponent strength still matters — raw form ≠ opponent-adjusted strength (
ratings-strength-models). - Document shift rule in every feature card / experiment log.
Anti-Patterns
- Fixed 5-game mean with no shrinkage
- Ignoring opponent strength in raw form
- Treating playoffs and regular season as identical without a flag
- Tuning window length on the final test season only
- Filling NA form with 0.0 silently
- Claiming “hot streak” causality from one rolling mean
Reporting Template
Form model: rolling / EWMA / expanding
Entity/frequency:
Windows/span:
Shift rule: shift(1) before aggregate
Min history:
Validation: vs static baseline under walk-forward
Limits: early season, injuries, opponent strength…
Reproduce:Output Contract
Done means:
- Entity/frequency stated
- Shift/as-of rule stated
- Window/span documented
- Min history rule stated
- Walk-forward comparison planned or done
- Leakage check planned or done
Worked Example
On a team-game file, sort by team_id and game_date, shift the result, then take an EWMA. Compare that column with a shifted three-game mean under the same season folds before preferring either window.
import pandas as pd
g = pd.read_parquet("team_games.parquet").sort_values(["team_id", "game_date"])
g["pre_points"] = g.groupby("team_id")["score"].shift(1)
g["pre_ewma_points"] = g.groupby("team_id")["pre_points"].transform(
lambda s: s.ewm(span=5, min_periods=1).mean()
)References
references/
| File | Contents |
| form_feature_recipes.md | shift/roll/expand/EWMA recipes |
| early_season.md | small-sample handling |
| rest_and_gaps.md | byes and calendar gaps |
Related Skills
| Need | Skill |
| Feature legality | feature-rules |
| Ratings (opponent-adjusted) | ratings-strength-models |
| EDA | eda-sports |
| Models | baseline-models, predictive-modeling |
| Leakage | leakage-audit |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

