This project selects the lineup that maximizes expected wins above average.
This script is intended to data in the format shown below, where each row is a unique player-position.
head(padres, 10)
# A tibble: 10 × 6
MLBAMID Name Pos dWAA rWAA lWAA
<dbl> <chr> <chr> <dbl> <dbl> <dbl>
1 592518 Manny Machado DH 0 1.4 1.9
2 592518 Manny Machado 3B -0.47 1.4 1.9
3 593428 Xander Bogaerts DH 0 -0.37 0.85
4 593428 Xander Bogaerts SS 0.94 -0.37 0.85
5 630105 Jake Cronenworth DH 0 1.15 0.98
6 630105 Jake Cronenworth 2B -0.3 1.15 0.98
7 630105 Jake Cronenworth SS 3.69 1.15 0.98
8 630105 Jake Cronenworth 1B -1.68 1.15 0.98
9 657656 Ramón Laureano DH 0 2.74 2.96
10 657656 Ramón Laureano RF -1.2 2.74 2.96The first three columns are self explanatory. The other columns, dWAA, rWAA, and lWAA, are defensive wins above average, offensive wins above average against RHPs, and offensive wins above average against LHPs, respectively.
The script to create the optimal lineup is run on data in this format and produces an optimal solution to the Kuhn-Munkres Algorithm.
Note
I exclude the 02Data folder as this contains Fangraphs data only used to illustrate the algorithm. It is not intended to serve as an actual projection, just as a placeholder to show how the algorithm works.
- 01Code contains the R script to run the Kuhn-Munkres optimization algorithm.
- 03Tables contains the formatted html tables which are the solution to the optimization algorithm.
A detailed write-up of this project can be found here: https://ryanpapale.github.io/roster.