Skip to content

PR #574: League constants 60/40 blend (2026/2025) — May 15 mid-season update#443

Merged
jaayslaughter-cpu merged 1 commit into
mainfrom
pr-574-league-constants-blend
May 15, 2026
Merged

PR #574: League constants 60/40 blend (2026/2025) — May 15 mid-season update#443
jaayslaughter-cpu merged 1 commit into
mainfrom
pr-574-league-constants-blend

Conversation

@jaayslaughter-cpu
Copy link
Copy Markdown
Owner

@jaayslaughter-cpu jaayslaughter-cpu commented May 15, 2026

League Constants — 60/40 Blend (2026 Actuals / 2025 Reference)

Source: Baseball Reference totals through May 14, 2026 (49,542 PA, 30 teams × ~44 games)

What changed

Constant 2026 Actual Blended (60/40) Was in code
wOBA .307 .310 .308/.320
OBP .319 .317 .315
SLG .389 .397 .410
AVG .240 .241 .245
ISO .149 .155 .156
BABIP .288 .292 .288
ERA 4.10 4.12 4.10
K% 22.2% 22.4% 22.8%
BB% 9.5% 9.1% 8.3-8.7% ABS effect
O-swing ~28.5% 28.7% 31.6% large drop — ABS robot ump
HR-FB% ~10.5% 10.9% 11.9%

Notable: BB% is up in 2026 (ABS challenge system). O-swing drops from .316 to .287 — batters disciplined vs machine-called strikes.

Files updated (7)

  1. fangraphs_layer.py — LEAGUE_DEFAULTS pitcher+batter
  2. prop_enrichment_layer.py — _get_fg_batter/pitcher defaults + chase fallbacks
  3. pa_model.py — LEAGUE_RATES K/BB/HR/2B/1B/OUT block
  4. lineup_chase_layer.py — _LEAGUE_O_SWING + _LEAGUE_K_PCT
  5. tasklets.py — league avg dict + slg/bb_pct/k_pct fallbacks
  6. streak_agent.py — woba/fip reference baselines
  7. data/calibration_params.json — league_constants section added

Summary by cubic

Updates MLB league constants to a 60/40 blend of 2026 actuals and 2025 reference (through May 14) and applies them across models and fallbacks. Centralizes the values in data/calibration_params.json for easier future updates.

  • New Features
    • Added league_constants to data/calibration_params.json (wOBA 0.310, OBP 0.317, SLG 0.397, AVG 0.241, ISO 0.155, BABIP 0.292, K% 0.224, BB% 0.091, ERA 4.12, HR/FB% 0.109, O-swing 0.287).
    • Updated defaults/baselines in fangraphs_layer, pa_model, lineup_chase_layer, prop_enrichment_layer, streak_agent, and tasklets (e.g., K 22.4%, BB 9.1%, O-swing 28.7%, SLG 0.397).
    • Refreshed PA outcome rates (HR 3.0%, 2B 4.4%, 1B 14.1%, OUT 45.5% residual) and tuned streak/chase logic to the ABS-influenced run environment.

Written for commit 6607658. Summary will update on new commits. Review in cubic

Summary by CodeRabbit

  • Chores
    • Updated 2025 MLB season baseline statistical constants across the system, including league-average rates for pitcher and batter performance metrics used in probability calculations and predictions.
    • Refreshed default fallback values for when live statistical data is unavailable, ensuring calculations remain current with latest seasonal baselines.

Review Change Stack

@ecc-tools
Copy link
Copy Markdown
Contributor

ecc-tools Bot commented May 15, 2026

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@jaayslaughter-cpu jaayslaughter-cpu merged commit b6f450e into main May 15, 2026
2 of 4 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 77578952-68a7-4bbf-aa61-388161f93314

📥 Commits

Reviewing files that changed from the base of the PR and between 52e9c24 and 6607658.

📒 Files selected for processing (7)
  • data/calibration_params.json
  • fangraphs_layer.py
  • lineup_chase_layer.py
  • pa_model.py
  • prop_enrichment_layer.py
  • streak_agent.py
  • tasklets.py

📝 Walkthrough

Walkthrough

This PR updates league-average baseline constants used as fallbacks throughout the prediction and enrichment pipeline, applying a 60/40 2026/2025 season blend calibration. Changes span seven files: a new calibration reference, base PA outcome rates, FanGraphs defaults for pitchers and batters, probability adjustment baselines, and feature normalization constants.

Changes

League Baseline Calibration Update

Layer / File(s) Summary
Calibration source and base league rates
data/calibration_params.json, pa_model.py
New league_constants reference section documents the 60/40 blend, and LEAGUE_RATES constants for strikeout/walk/home-run/double/single outcome rates are updated to match the blended model.
FanGraphs pitcher and batter fallback defaults and adjustments
fangraphs_layer.py, streak_agent.py
LEAGUE_DEFAULTS pitcher and batter fallback statistics (wOBA, K-BB%, FIP, ERA, BABIP, etc.) are updated; pitcher and batter probability delta baselines in streak_agent.py shift to use new FIP (4.12) and wOBA (0.310) targets.
Enrichment and feature vector baseline constants
lineup_chase_layer.py, prop_enrichment_layer.py, tasklets.py
Chase score league baselines (O-swing, K%) and pitcher/batter enrichment fallback stats are updated; platoon priors and XGBoost feature vector normalization constants (SLG, BB%, K%) are adjusted.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • jaayslaughter-cpu/mework#290: Prior update to the same league-average fallback constants in fangraphs_layer.py, lineup_chase_layer.py, and related prediction layers.
  • jaayslaughter-cpu/mework#318: Earlier calibration update affecting the same fallback constants and feature baselines across fangraphs_layer.py, prop_enrichment_layer.py, and tasklets.py.
  • jaayslaughter-cpu/mework#408: Concurrent updates to prop_enrichment_layer.py's missing-stats enrichment fallback behavior and chase-score fallback logic.

Poem

🐰 Constants shift as seasons blend,
Sixty-forty split to mend,
From May's snapshot, baselines fly,
New odds and deltas multiply! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pr-574-league-constants-blend

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@deepsource-io
Copy link
Copy Markdown

deepsource-io Bot commented May 15, 2026

DeepSource Code Review

We reviewed changes in 52e9c24...6607658 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Docker May 15, 2026 5:04p.m. Review ↗
JavaScript May 15, 2026 5:04p.m. Review ↗
Python May 15, 2026 5:04p.m. Review ↗
SQL May 15, 2026 5:04p.m. Review ↗
Secrets May 15, 2026 5:04p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates league-average baseline constants across the codebase—including fangraphs_layer.py, pa_model.py, and tasklets.py—to reflect a 60/40 blend of 2026 and 2025 data. Review feedback identifies several locations where fallback values for metrics like era, xfip, and babip remain inconsistent with the new standards. Additionally, the reviewer noted that normalization logic in tasklets.py needs adjustment to align with the updated averages and suggested formatting woba to three decimal places for consistency.

Comment thread prop_enrichment_layer.py
"xfip": stats.get("xfip", 4.06),
"siera": stats.get("siera", 4.06),
"k_bb_pct": stats.get("k_bb_pct", 0.139),
"k_bb_pct": stats.get("k_bb_pct", 0.133),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While k_bb_pct has been updated to 0.133, several other league fallbacks in this block (and throughout the file) remain inconsistent with the new blended constants. Specifically, era, xfip, and siera (lines 212, 216, 217) are still using 4.06 instead of the new 4.12 standard defined in fangraphs_layer.py and streak_agent.py. Additionally, babip (line 241) and z_contact (line 243) fallbacks in the batter block are also inconsistent with the updated defaults.

Comment thread tasklets.py
# slot 2: SLG for TB/power props (16% feature importance)
if _is_tb_prop:
_slg = float(prop.get("slg", 0.410) or 0.410)
_slg = float(prop.get("slg", 0.397) or 0.397)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The update of the slg fallback to 0.397 creates an inconsistency with the normalization logic in the following line (3150). The calculation (_slg - 0.250) / 0.400 and the associated comment 0.410=avg(0.40) are based on the previous league average. To maintain the same feature scaling for an "average" player, the normalization constants should be adjusted. Similarly, the babip fallback in line 3152 remains at 0.288 instead of the new 0.292 standard.

"notes": "prop_min_prob_overrides: per-prop MIN_PROB gates stricter than global 0.57. fantasy_score set to 0.99 (effectively excluded). hits_allowed excluded pending more data (Brier 0.4531).",
"league_constants": {
"_comment": "60/40 blend 2026/2025 \u2014 May 15 2026. Source: BBRef totals through May 14.",
"woba": 0.31,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the other league constants in this file (which use three decimal places), woba should be explicitly set to 0.310.

Suggested change
"woba": 0.31,
"woba": 0.310,

Comment thread pa_model.py
"1B": 0.141, # single — blended (2026: 14.0%, 2025: 14.3%)
"OUT": 0.455, # field out — residual to sum=1.000
}
assert abs(sum(LEAGUE_RATES.values()) - 1.0) < 0.01, "LEAGUE_RATES must sum to 1"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.


Usage of assert statement in application logic is discouraged. assert is removed with compiling to optimized byte code. Consider raising an exception instead. Ideally, assert statement should be used only in tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant