# Use of Machine Learning and Deep Learning to Predict the Outcomes of Major League Baseball Matches
## 3 Methods
### Data Collection and Preprocessing  
In the 2019 season, 162 games took place. Because the Chicago White Sox and Detroit Tigers only played 161 games, we collected data from a total of 4858 games. All data were obtained from Baseball-Reference, a website that records data on batting, pitching, and games. For batting, the total group batting data in each game were selected (Figure 2); for the pitching category, because a game includes more than one pitcher, we refer to the first pitcher as the SP and the pitcher who plays later as the relief pitcher (RP). In this study, the starting pitcher data and the overall pitcher data were selected separately (Figure 3). Finally, we selected the variables of the home/away team from the relevant data of the game (Figure 4). The first data set contained batting variables (13 in total, denoted B1-B13), SP variables (16 in total, denoted SP1-SP16), and one variable for the home/away team (denoted X1); thus, a total of 30 variables were selected for data set 1. The second data set included batting variables (13 in total, denoted B1-B13), variables of all pitchers (18 in total, denoted P1-P18), and one variable of the home/away team (denoted X1); thus, a total of 32 variables were selected for data set 2. Y was the output value (win/loss). The selected variables are listed in Tables 1 and 2. Figure 1: The research framework. Figure 4: Related data. Figure 3: Atlanta Braves pitching statistics. Figure 2: Atlanta Braves batting statistics. _Appl. Sci._**2021**, _11_, 4499 \begin{table}
\begin{tabular}{c c c c c c} \hline \hline  & \multicolumn{2}{c}{**Dataset 1**} & \multicolumn{4}{c}{**Dataset 2**} \\ \hline  & **Number** & **Variable** & **Abbr** & **Number** & **Variable** & **Abbr** \\ \hline  & B1 & At Bats & AB & B1 & At Bats & AB \\ \cline{2-6}  & B2 & Hits & H & B2 & Hits & H \\ \cline{2-6}  & B3 & Bases on Balls & BB & B3 & Bases on Balls & BB \\ \cline{2-6}  & B4 & Strike out & SO & B4 & Strike out & SO \\ \cline{2-6}  & B5 & Plate Appearances & PA & B5 & Plate Appearances & PA \\ \cline{2-6}  & B6 & Batting average & BA & B6 & Batting average & BA \\ \cline{2-6}  & B7 & On base percentage & OBP & B7 & On base percentage & OBP \\ \cline{2-6}  & B8 & Slugging Percentage & SLG & B8 & Slugging Percentage & SLG \\ \cline{2-6}  & B9 & On-base plus slugging & OPS & B9 & On-base plus slugging & OPS \\ \cline{2-6}  & B10 & Number of pitches in the PA & Pit & B10 & Number of pitches in the PA & Pit \\ \cline{2-6}  & B11 & Strikes & Str & B11 & Strikes & Str \\ \cline{2-6}  & B12 & Putouts & PO & B12 & Putouts & PO \\ \cline{2-6}  & B13 & Assists & A & B13 & Assists & A \\ \hline  & SP1 & Innings Pitched & IP & P1 & Innings Pitched & IP \\ \cline{2-6}  & SP2 & Hits & H & P2 & Hits & H \\ \cline{2-6}  & SP3 & Bases on Balls & BB & P3 & Bases on Balls & BB \\ \cline{2-6}  & SP4 & Strikeouts & SO & P4 & Strikeouts & SO \\ \cline{2-6}  & SP5 & Home Runs Hit & HR & P5 & Home Runs Hit & HR \\ \cline{2-6}  & SP6 & Earned Run Average & ERA & P6 & Earned Run Average & ERA \\ \cline{2-6}  & SP7 & Batters Faced & BF & P7 & Batters Faced & BF \\ \cline{2-6}  & SP8 & Number of pitches in the PA & Pit & P8 & Number of pitches in the PA & Pit \\ \cline{2-6}  & SP9 & Strikes & Str & P9 & Strikes & Str \\ \cline{2-6}  & SP10 & Strikes by Contact & Cttc & P10 & Strikes by Contact & Cttc \\ \cline{2-6}  & SP11 & Strikes Swinging & StS & P11 & Strikes Swinging & StS \\ \cline{2-6}  & SP12 & Strikes Looking & StL & P12 & Strikes Looking & StL \\ \cline{2-6}  & SP13 & Ground Balls & GB & P13 & Ground Balls & GB \\ \cline{2-6}  & SP14 & Fly Balls & FB & P14 & Fly Balls & FB \\ \cline{2-6}  & SP15 & Line Drives & LD & P15 & Line Drives & LD \\ \cline{2-6}  & SP16 & Game Score & GSc & P16 & Game Score & GSc \\ \cline{2-6}  & & & P17 & Inherited Runners & IR \\ \cline{2-6}  & & & & P18 & Inherited Score & IS \\ \hline else & X1 & Home/Away Team & H/A & X1 & Home/Away Team & H/A \\ \hline \hline \end{tabular}
\end{table} 
Table 1: MLB input variable.