# liamrogan1/mlb_monte_carlo architecture

> Architecture diagram of the GitHub repository liamrogan1/mlb_monte_carlo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/liamrogan1/mlb_monte_carlo
- Repository: https://github.com/liamrogan1/mlb_monte_carlo

## Overview

This repository is an MLB player-prop analytics and betting project. Its clearest runtime workflow is collecting and snapshotting pitcher strikeout/walk odds, using `pred_tb.py` to simulate player outcomes and evaluate bets, then reviewing backtests or outcome distributions. Separate data-preparation code pulls and blends baseball statistics, while `k_rate_regression.py` derives training targets and features. The excerpts do not establish how the saved model or prepared datasets connect to the prediction script, so those links are omitted; several capabilities are inferred only from sampled code.

Main entry points: [`import_odds.py`](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/import_odds.py) (Odds collector), [`import_data.py`](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/import_data.py) (Stats and results), [`pred_tb.py`](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/pred_tb.py) (Prop simulation), [`k_rate_regression.py`](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/k_rate_regression.py) (Statcast features)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_odds["Odds collection"]
  node_odds_import["Odds collector<br/>[import_odds.py]"]
  node_odds_snapshot[("Odds snapshots<br/>[import_odds.py]")]
end

subgraph group_data["Baseball data"]
  node_data_import["Stats and results<br/>[import_data.py]"]
  node_player_db[("Player identity<br/>[update_pdb.py]")]
end

subgraph group_analysis["Prop analysis"]
  node_prediction["Prop simulation<br/>[pred_tb.py]"]
  node_backtest["Bet backtesting<br/>[pred_tb.py]"]
  node_outcomes["Outcome distributions"]
  node_hyp_tests["Hypothesis testing<br/>[hyp_test.py]"]
end

subgraph group_modeling["Model preparation"]
  node_feature_engineering["Statcast features"]
  node_saved_model["K-rate model<br/>[k_rate_model.pkl]"]
  node_raw_example["Example data"]
end

node_bettor(("Analyst"))
node_odds_api{{"The Odds API"}}
node_pybaseball{{"Pybaseball"}}

node_bettor -->|"requests odds"| node_odds_import
node_odds_import -->|"fetches prices"| node_odds_api
node_odds_import -->|"saves snapshots"| node_odds_snapshot
node_prediction -->|"reads latest lines"| node_odds_snapshot
node_prediction -->|"loads snapshot helper"| node_odds_import
node_bettor -->|"runs simulations"| node_prediction
node_bettor -->|"runs data pulls"| node_data_import
node_data_import -->|"fetches stats"| node_pybaseball
node_data_import -.->|"uses player IDs"| node_player_db
node_bettor -->|"runs backtest"| node_backtest
node_bettor -->|"plots outcomes"| node_outcomes
node_bettor -->|"builds features"| node_feature_engineering
node_feature_engineering -->|"pulls Statcast"| node_pybaseball

click node_odds_import "https://github.com/liamrogan1/mlb_monte_carlo/blob/main/import_odds.py"
click node_odds_snapshot "https://github.com/liamrogan1/mlb_monte_carlo/blob/main/import_odds.py"
click node_data_import "https://github.com/liamrogan1/mlb_monte_carlo/blob/main/import_data.py"
click node_player_db "https://github.com/liamrogan1/mlb_monte_carlo/blob/main/update_pdb.py"
click node_prediction "https://github.com/liamrogan1/mlb_monte_carlo/blob/main/pred_tb.py"
click node_backtest "https://github.com/liamrogan1/mlb_monte_carlo/blob/main/pred_tb.py"
click node_outcomes "https://github.com/liamrogan1/mlb_monte_carlo/blob/main/display_outcomes.py"
click node_hyp_tests "https://github.com/liamrogan1/mlb_monte_carlo/blob/main/hyp_test.py"
click node_feature_engineering "https://github.com/liamrogan1/mlb_monte_carlo/blob/main/k_rate_regression.py"
click node_saved_model "https://github.com/liamrogan1/mlb_monte_carlo/blob/main/k_rate_model.pkl"
click node_raw_example "https://github.com/liamrogan1/mlb_monte_carlo/blob/main/example_pybaseball.csv"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_odds_import,node_odds_snapshot toneBlue
class node_data_import,node_player_db toneAmber
class node_prediction,node_backtest,node_outcomes,node_hyp_tests,node_odds_api toneMint
class node_feature_engineering,node_saved_model,node_raw_example toneRose
class node_bettor,node_pybaseball toneIndigo
```

## Components

### Odds collection

- [Odds collector](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/import_odds.py): `import_odds.py`
- [Odds snapshots](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/import_odds.py): `import_odds.py`

### Baseball data

- [Stats and results](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/import_data.py): `import_data.py`
- [Player identity](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/update_pdb.py): `update_pdb.py`

### Prop analysis

- [Prop simulation](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/pred_tb.py): `pred_tb.py`
- [Bet backtesting](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/pred_tb.py): `pred_tb.py`
- [Outcome distributions](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/display_outcomes.py): `display_outcomes.py`
- [Hypothesis testing](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/hyp_test.py): `hyp_test.py`

### Model preparation

- [Statcast features](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/k_rate_regression.py): `k_rate_regression.py`
- [K-rate model](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/k_rate_model.pkl): `k_rate_model.pkl`
- [Example data](https://github.com/liamrogan1/mlb_monte_carlo/blob/main/example_pybaseball.csv): `example_pybaseball.csv`

### Other components

- **Analyst**
- **The Odds API**
- **Pybaseball**

## Connections

- Analyst → Odds collector: requests odds
- Odds collector → The Odds API: fetches prices
- Odds collector → Odds snapshots: saves snapshots
- Prop simulation → Odds snapshots: reads latest lines
- Prop simulation → Odds collector: loads snapshot helper
- Analyst → Prop simulation: runs simulations
- Analyst → Stats and results: runs data pulls
- Stats and results → Pybaseball: fetches stats
- Stats and results → Player identity: uses player IDs
- Analyst → Bet backtesting: runs backtest
- Analyst → Outcome distributions: plots outcomes
- Analyst → Statcast features: builds features
- Statcast features → Pybaseball: pulls Statcast
