agentleFS
noahowshnoahowsh/endzoneapi-mcp/skills/feature-engineering/SKILL.md

feature-engineering

Skill0 starsChanged 28 days agoMITView on GitHub

Builds leak-free predictive features for NFL games and players: rolling EPA, opponent-adjusted rates, rest and travel, quarterback changes, Elo, and market-derived inputs. Use when user asks to build features, wants rolling averages, asks what to feed a model, asks about data leakage, or has a model that looks too good. Do not use for model training, evaluation or calibration, see walk-forward-validation and probability-calibration. Do not use for a single descriptive stat, see epa-analysis.

14 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use mean-reversion and position-sizing.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • agiprolabsSkill

    mean-reversion

    Mean-reversion strategy tools including Hurst exponent, half-life estimation, z-score signals, ADF testing, and Ornstein-Uhlenbeck modeling

    Also in 3 projects that use this

  • Bhala-SrinivashSkill

    position-sizing

    Calculate optimal position sizes for NSE/BSE equity trades using fixed fractional, ATR-based, and Kelly criterion methods. Includes portfolio constraints and leverage adjustments.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 1

    Distinctive

    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
  1. Distinctive:

    Keep push rows in a separate column rather than dropping or mislabeling them.

    line 106

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Feature Engineering

Default data tool: EndzoneAPI (endzoneapi-tool). get_games (5 credits) gives a whole season of results, rest days, starting QBs and consensus lines. get_team_stats (5 credits per team-season) gives weekly team lines with EPA. get_plays (10 credits per page) gives play-level data when you need your own aggregation. For your own CSV: skip the tools, no credits used.

You are an expert in turning football data into model inputs without letting the future into the past. Your goal is a feature table where every row uses only information available before kickoff of that game.

When to Use

  • "What features should I use to predict NFL games?"
  • "Build rolling EPA for each team"
  • "My model hits 70% against the spread, is that real?"
  • "How do I handle the quarterback changing?"
  • "How do I use the closing line as a feature?"

When NOT to Use

  • Fitting and tuning a model, evaluating by time, see walk-forward-validation
  • Checking probabilities, see probability-calibration
  • Just exploring a team, see epa-analysis

Commands Available

CommandFeature UseCredits
get_gamesTarget (result, total), rest, QBs, line, div_game, roof, surface5 per query
get_team_statsWeekly team lines in weeks[] (passing EPA, rushing EPA, sacks, penalties, kicking)5 per team-season
get_playsPlay-level EPA, success, CPOE, down, distance, win probability, charting10 per page
get_injuriesOut/doubtful flags by week (2009+)2
get_snap_countsUsage and availability5
get_advanced_statsTracking and pressure by week5
get_oddsOpening line vs closing line, per book (2020+)10 per game

Commands That Do NOT Exist

Not AvailableUse Instead
get_featuresBuild from the calls above
get_power_ratingsCompute your own Elo from get_games results
get_strength_of_scheduleDerive from opponents' rolling rates
get_travel_distanceUse list_teams for division and your own stadium table

The One Rule: Information Cutoff

For a game at week W of season S, a feature may use only games with kickoff earlier than this game's kickoff, in a strictly earlier week. In pandas, sort by team and date, compute the statistic, then shift(1).

g = team_weeks.sort_values(["team", "season", "week"]).copy()
g["epa_l5"] = (g.groupby(["team"])["epa_per_play"]
                .transform(lambda s: s.shift(1).rolling(5, min_periods=3).mean()))

Forgetting shift(1) includes the game being predicted in its own feature. That is the most common reason a model beats the market in testing and fails in use.

Feature Families

1. Team efficiency (rolling). Offensive and defensive EPA per play, pass and run separately, early-down success rate. Windows of 5 and 10 games plus an expanding season mean. An NFL season has 17 games, so a 10 game window spans over half of it; shrink toward last season or league mean early (see Shrinkage).

2. Opponent adjustment. A rolling mean is biased by who the team played. A simple fix: subtract the opponent's rolling defensive EPA allowed relative to league average, or fit a ridge regression of game EPA on offense and defense dummies using only prior games. Adjustment on 5 games is noise; use 8 or more or shrink.

3. Quarterback. The starting QB is the largest single driver. get_games returns away_qb_name and home_qb_name. Build features at the QB level (rolling EPA per dropback of the starter, with a prior for rookies and a backup's prior for an unknown) rather than only team level. Flag a QB change from the prior week.

4. Situation. home_rest, away_rest, rest difference, Thursday game, bye last week, div_game, roof, surface, game temperature when present (get_game_detail for weather detail). Treat missing weather as missing, not zero.

5. Ratings. Elo from results: start every team at 1500, update with margin of victory, revert part of the way to the mean each offseason.

expected_home = 1 / (1 + 10 ** (-(elo_home - elo_away + home_adv) / 400))
elo_home += K * mov_mult * (actual_home - expected_home)

Tune K, home_adv and the offseason carryover (typically keep two thirds to three quarters, verify on your data) by walk-forward validation, not by eye.

6. Market features. The closing spread is the best single predictor of the margin in public data. Whether to include it depends on the question. A model that is allowed to see the closing line is a model of residuals; it can only tell you where the market is wrong, which is the right framing for betting but not for "predict the game". Never use a closing line as a feature for a bet placed before it exists. Use the opening line if you simulate betting earlier in the week (per-book opening is available 2020 onward).

7. Availability. Starters out (QB, left tackle, top two receivers, top pass rusher) from get_injuries. Injury reports are published during the week, so only use reports dated before your decision time.

Shrinkage and Small Samples

Early-season rolling stats are mostly noise. A standard fix is a weighted blend of prior-season rate and current rate:

rate = (n * current + k * prior) / (n + k)

with n games played and k a prior weight (start near 6 to 10 games for EPA, tune it in validation). Regress the prior toward the league mean as well; rosters change.

Targets

TargetDefinitionNote
Marginresult (home minus away)Regression, then convert to a win probability
Coverresult > spread_linePushes need handling; 3 and 7 are common margins
Totaltotal > total_lineWeather and pace features matter
Residualresult - spread_lineNeeds the line known before the bet

Keep push rows in a separate column rather than dropping or mislabeling them.

Leakage Checklist

LeakHow It Hides
Game's own stats in its rolling featureMissing shift(1)
Final season stats used for in-season rowsget_team_stats season totals include later weeks. Use weeks[] instead
Closing line as input for an earlier betClosing is the last pre-kickoff snapshot
Season-end Elo or rankings applied to earlier weeksRecompute by week
Injury status taken after the gameDate-stamp reports
Random train/test splitTime order is the point, see walk-forward-validation
Same game appearing from both team views in train and testSplit by game, not by team-week

Credit Usage

OperationCredits
One season of games and lines5
All 32 teams, one season of weekly team lines160
One season of plays for one team (about 1,100 plays, paged)10 to 20
Whole-league plays for a seasonthousands, plan before pulling

Cheapest useful set: get_games for 5 or 6 seasons (25 to 30 credits) gives results, rest, QBs and consensus lines for a first model.

Anti-patterns

RationalizationWhy It's WrongDo This Instead
"More features will help"272 regular season games a year, few hundred per many windowsStart under 15 features and add one family at a time
"Use season totals from get_team_stats"They include games after the one you predictUse weeks[] with a cutoff
"Drop pushes"Skews the cover rateKeep them as a third class
"Fill missing weather with 0"Indoor and missing are differentUse a missing flag
"Last year's EPA predicts this year"Only partially, QB and rosters changeBlend with shrinkage

Output Format

Feature table: one row per game, keys (season, week, game_id)
Columns: home/away rolling EPA (5, 10), pass/run split, QB flag,
         rest, Elo diff, line (opening only if betting early)
Cutoff rule: all inputs from games before kickoff, shift(1) applied
Rows: N games, seasons YYYY-YYYY, missing handled by [rule]

What to Do Next

What You BuiltNext ActionSkill
A feature tableEvaluate by timewalk-forward-validation
ProbabilitiesCheck calibrationprobability-calibration
A model beating the lineTest against closing oddsbacktesting

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.