This project models baseball through a game-theoretic lens using MLB data
- Create a virtual environment (myenv will be ignored by git).
- Install requirements using
pip install -r requirements.txt - In the env file in src/.env, set the folder variable to the absolute path of the BaseballGameTheory folder.
- Create a folder titled statcast inside the raw data folder.
- Fetch the raw data with
raw_data/fetch_raw_data.py - Process the data with
src/data/data_loading.py - Try out the zero-sum stochastic game model with
src/policy/optimal_policy.py(run this from inside the policy folder) - Try out batting order optimization scripts with
src/policy/batting_order_optimization.py - Feel free to load the data with
bd = BaseballData()and experiment!
model_weights/contains pre-trained models for the distributionspresentation/contains the research poster and write-upsrc/contains the made codebasesrc/data/contains the data processing scripts and Pytorch datasetssrc/distributions/contains the Pytorch models for learning the distributionssrc/model/contains the object classes for the game model, like players, zones, pitches, etc.src/policy/contains the zero-sum stochastic game model and work on batting lineup optimization
- Implented stochastic runners to accurately model speed
- Sped up ERA computation by dynamically storing inning results
- Modified batter representation to enhance swing outcome neural network calculation
- Batter/pitcher handedness
- Limit pitcher arsenals to pitches they throw
- Trade deadline targets
- Pinch hitting strategy
- Stolen bases strategy on a runner/catcher basis
- Incorporate on-field events like sacrifices, double plays, stretching, etc.
- Bullpen strategy
Old repository: https://github.com/BOBONA/ZeroSumBaseball