# Predictive Analytics for Sucker Rod Pump Failures in Kazakhstan Oil Wells Using Machine Learning
## 4 Results  
In this study, we applied a machine learning algorithm, specifically LightGBM, to build upon and expand our previous work in a related field [15, 16]. We initially show the numerical results of the LightGBM machine learning algorithm for two dataset cases. The first data were applied to the oversampling technique for Class 1 (fault event). Secondly, we applied the undersampling method for Class 0 (normal work). In the experiments, we considered the LightGBM model with default parameters, i.e., without hypertuning parameters of the model. In the first step, the LightGBM model is applied to the original dataset, and the result of the model is presented in Table 2. Using F1 metrics, we obtain a clearer picture of the model's performance and suitability for real-world applications, where correct identification of minority cases (failures) is essential to prevent equipment downtime and optimize well operations. The model performs well for Class 0 but fails to detect Class 1 completely. The overall high accuracy is misleading because of the class imbalance, and the poor recall for Class 1 indicates the model needs improvement to address this imbalance and perform better in minority classes. Figure 5 shows the effects of the oversampling technique on the dataset. The blue bar is the amount of Class 0 and the orange color is the amount of Class 1. Figure 5 shows the cases' distribution after oversampling; the class distributions are more balanced, which should help the model better learn and generalize for both classes, especially for the minority class (Class 1). We show results for LightGBM models in scenarios with the oversampling dataset. The result does not show that imbalance correction methods improved the recall metric compared to developing models on the original training data (see Figure 6). Training models on imbalance oversampling datasets resulted in severe overestimation of Class 0 (normal work) and opposite underestimation of the fault event. Figure 6 represents a confusion matrix for a classification task using a LightGBM model on an oversampled dataset. This figure indicates that oversampling helped the LightGBM model improve metrics for some classes in the imbalance problem compared with the original dataset. However, the relatively high number of false negatives (1790) for Class 1 could still require further attention to improve recall. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Class** & **Precision** & **Recall** & **F1-Score** & **Support** \\ \hline
0 & 0.96 & 1.00 & 0.98 & 2938 \\
1 & 0.00 & 0.00 & 0.00 & 129 \\ \hline
**Accuracy** & \multicolumn{4}{c}{0.96 (Support: 3067)} \\
**Macro Avg** & 0.48 & 0.50 & 0.49 & 3067 \\
**Weighted Avg** & 0.92 & 0.96 & 0.94 & 3067 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Classification report for original dataset. Figure 5: The distribution of original and oversampling datasets. (**a**) Original dataset. (**b**) Oversampling dataset. Table 3 presents the Classification Report for a LightGBM model applied to an oversampled dataset, showing the performance metrics for each class after addressing class imbalance. The table reveals that while the model performs well for Class 0 (the majority class), it struggles significantly to predict Class 1 (the minority class) even after oversampling. The precision and recall for Class 1 are notably low, which indicates that the oversampling technique may not have been fully effective in improving the model's performance for the minority class. The imbalance in performance across classes suggests that further strategies, such as using more advanced resampling techniques (e.g., SMOTE), may be needed to improve Class \(1\) prediction. Figure 7 shows the distribution of classes in the original dataset after applying an undersampling technique. It is similar to the previous figure, but this time, the focus is on undersampling instead of oversampling. In contrast to oversampling, which increases the size of the minority class, undersampling reduces the size of the majority class (Class 0).