# Energy Consumption Prediction for Drilling Pumps Based on a Long Short-Term Memory Attention Method
## 3 Results and Discussion
### Model Performance Comparison  
Based on the above experiments, we conducted a comparative analysis of the performance of different models in predicting drilling pump energy consumption. We employed independent testing datasets collected from pumps operating in different oilfields, with no overlap with the training data. These datasets were gathered from diverse geographic locations and under varying operational conditions. Consequently, the model's performance on the test data reflects not only its ability to fit the training data but also its predictive robustness across different data sources and changing conditions. To evaluate the models, we introduced four evaluation metrics: Mean Absolute Error (MAE), Mean Squared Error (MSE), Root Mean Square Error (RMSE), and the Coefficient of Determination (R\({}^{2}\)). The formulas for these metrics are as follows:  
\[\text{MAE }=\frac{1}{n}\sum_{i=1}^{n}|y_{i}-\overset{\wedge}{y}_{i}| \tag{10}\]  
MAE measures the average absolute difference between predicted and actual values, reflecting the overall prediction error of the model.  
\[\text{MSE }=\frac{1}{n}\sum_{i=1}^{n}(y_{i}-\overset{\wedge}{y}_{i})^{2} \tag{11}\]  
MSE represents the average squared difference between predicted and actual values and is sensitive to large errors. A lower MSE indicates better control over the overall prediction error.  
\[\text{RMSE }=\sqrt{\frac{1}{n}\sum_{i=1}^{n}(y_{i}-\overset{\wedge}{y}_{i})^{2}} \tag{12}\]  
RMSE is the square root of MSE, providing a measure of the average deviation between predicted and actual values. RMSE is also sensitive to large errors and offers a comprehensive evaluation of model performance.  
\[R^{2}=1-\frac{\sum_{i=1}^{n}\left(y_{i}-\overset{\wedge}{y}_{i}\right)^{2}}{ \sum_{i=1}^{n}(y_{i}-\overline{y})^{2}} \tag{13}\]  
R\({}^{2}\) reflects the proportion of variance in the dependent variable that is predictable from the independent variables. An R\({}^{2}\) value closer to one indicates a better fit of the model to the data.  
These four metrics provide a comprehensive assessment of the model's performance in predicting drilling pump energy consumption. MAE and MSE primarily evaluate the magnitude of prediction errors, while RMSE offers an overall evaluation by accounting for both small and large errors. R\({}^{2}\) measures how well the model captures the overall trend in the data. By comparing these metrics, we can better understand the strengths and weaknesses of different models, providing valuable insights for further optimization and improvement of energy consumption prediction models. The performance comparison is shown in Figure 11.  
As illustrated in the figures, the LSTM-Attention model outperforms the traditional LSTM and CNN models across all evaluation metrics (MAE, MSE, RMSE, and R\({}^{2}\)), demonstrating superior predictive capabilities and robustness. The MAE and MSE values indicate that this model effectively reduces prediction errors, especially when handling complex nonlinear relationships and long-term dependencies, with significantly lower error rates than other models, showcasing its high accuracy and reliability. The RMSE metric further validates its excellent performance in controlling overall errors and mitigating large discrepancies. In contrast, the LSTM and CNN models show higher error values and lower goodness of fit when dealing with extreme conditions and high-frequency fluctuations, making them less effective in accurately predicting fluctuations in drilling pump energy consumption. Moreover, the LSTM-Attention model achieves an R\({}^{2}\) value close to 1, indicating its strong capability to capture the fluctuation patterns in actual data and providing a much better explanation of energy consumption variations than traditional models. Overall, the LSTM-Attention model not only excels in prediction accuracy but also exhibits high robustness and adaptability, offering effective technical support for energy management and optimization in drilling operations.