# Application of Machine Learning Models for Baseball Outcome Prediction
## 2 Method  
The research workflow comprised five sequential stages: data collection, preprocessing, model training, performance evaluation, and interpretation (see Figure 1). Data were collected from the official CPBL website and Baseball Rebas Data Company, yielding 1738 regular-season games from 2021 to 2023. During preprocessing, tied games were excluded to ensure binary outcomes suitable for machine learning applications. Six machine learning algorithms were implemented and trained using 5-fold cross-validation: decision tree, logistic regression, Artificial Neural Network (ANN), Random Forest, LightGBM, and XGBoost. Performance was assessed using seven metrics: accuracy, F1 score, sensitivity, specificity, positive predictive value (PPV), negative predictive value (NPV), and area under the receiver operating characteristic curve (AUC). To enhance interpretability, feature importance analysis and SHapley Additive exPlanations (SHAP) were applied to quantify individual variable contributions to model predictions. This systematic approach ensured transparent model development and comprehensive evaluation.  
This study analyzed game data collected from the official CPBL website and the Baseball Rebas Data Company, covering a total of 900 regular-season games from the 2021 to 2023 CPBL seasons. After excluding 31 games that ended in a tie, a final dataset comprising 859 games with definitive outcomes was obtained, resulting in 1738 game records. Table 1 summarizes the key variables utilized in the analysis. This study compiled a comprehensive dataset comprising both batting and pitching statistics from professional baseball games. A total of 21 offensive (batter-related) and 16 defensive (pitcher-related) performance variables were collected, as detailed in Table 1. The binary outcome variable indicating win or loss (W/L) served as the dependent variable for model prediction. All data were obtained from official game records to ensure accuracy, completeness, and consistency across observations.  
To ensure full transparency and reproducibility, the complete implementation code, including data preprocessing, model training, performance evaluation, and visualization, is publicly available as a Google Colab notebook at [[https://colab.research.google.com/drive/1](https://colab.research.google.com/drive/1) iDYo5 dIUSGOva0m1e49C1 ADef1u2 PFl?usp=sharing]([https://colab.research.google.com/drive/1](https://colab.research.google.com/drive/1) iDYo5 dIUSGOva0m1e49C1 ADef1u2 PFl?usp=sharing). (accessed on 17 June 2025).  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Number** & **Batter** & **Abbreviation** & **Number** & **Pitcher** & **Abbreviation** \\ \hline B1 & At bats & AB & P1 & Batter Faced & BF \\ B2 & Runs & R & P2 & Pitch Count & NP \\ B3 & Run batted in & RRI & P3 & Strike & Strike \\ B4 & Single & 1B & P4 & Hits & P\_H \\ B5 & Double & 2B & P5 & Home runs & P\_HR \\ B6 & Triple & 3B & P6 & Base on balls & P\_BB \\ B7 & Home runs & HR & P7 & Strikeout & P\_SO \\ B8 & Hits & H & P8 & Walks per nine innings & B/9 \\ B9 & Walks & BB & P9 & Hits per nine innings & H/9 \\ B10 & Strike out & SO & P10 & Strikeouts per nine innings & K/9 \\ B11 & Sacrifice hits & SH & P11 & Strike percentage & S\% \\ B12 & Sacrifice flies & SF & P12 & Batting average on balls in play & BABIP \\ \hline \hline \end{tabular}
\end{table}
Table 1: Collection of research variables.  
Figure 1: A block diagram of the machine learning-based research workflow.