## 3 ROP Prediction Based on the Random Forest Machine Learning Model
### Prediction Results and Model Performance Evaluation  
In this paper, a prediction model was constructed using the random forest regression algorithm. Logging data, including standpipe pressure, torque, drilling pressure, rotary speed, equivalent density, viscosity, inlet flow rate, outlet flow rate, total pump speed, and drilling speed, were used to train the relationship between engineering parameters and ROP.  
To visually evaluate the performance of the prediction model, a comparison was made between the predicted ROP and the actual values for the two test wells. Additionally, evaluation metrics were introduced to assess the model's performance.  
The mean squared error (MSE) is a common metric used to measure the goodness of fit of a prediction model [25]. It quantifies the average squared difference between predicted values and the actual values in the dataset. The objective of minimizing MSE is to find model parameters (e.g., in the case of a random forest, the tree structures) that make the MSE as small as possible [26]. This means that the model attempts to find the best parameter combination to minimize the total squared difference between its predicted values and the actual target values. During the training process of the random forest model, the objective function used to minimize the mean squared error (MSE) between the predicted and actual values is set to the MSE itself, resulting in the smallest MSE between the predicted and actual values.  
In this paper, the model's performance was evaluated using the R-squared (R\({}^{2}\)) value, expressed as follows:  
\[R^{2}=1-\frac{\sum_{i}^{m}(\hat{y}_{i}-y_{i})}{\sum_{i}^{m}(\overline{y}-y_{i })} \tag{7}\]  
where \(m\) represents the number of data points; \(y_{i}\) is the actual drilling rate value; \(\hat{y}_{i}\) is the predicted drilling rate value; and \(\overline{y}\) is the mean drilling rate.  
Figure 7 represents the drilling speed prediction results for well Fu39. It can be observed that the predicted ROP closely matches the actual values, and the overall trend  
Figure 6: Importance ranking of features affecting ROP in well Kangtan2.  
is consistent. The R-squared (R\({}^{2}\)) value reaches 0.94, indicating a good overall prediction performance. Moreover, for the abnormally low-speed sections at well depths of 3950-4300 m and 4700-5000 m, the random forest model is also capable of capturing the unusual ROP trends effectively. This is an achievement that traditional mechanism-driven ROP prediction models cannot accomplish.  
The well Kangtan2 is located far away from the other training wells and has a longer test interval, resulting in greater fluctuations in the mechanical drilling rate compared to Well Fu39. The mechanical drilling rate prediction results for Kangtan2 are illustrated in Figure 8. Although there is some deviation between the predicted results and the actual drilling rate in the relatively high-speed interval of 2000-3500 m, the model effectively captured the fluctuation trend of the mechanical drilling rate, yielding an R\({}^{2}\) value of 0.83 and demonstrating a good overall prediction performance. This also confirms the strong generalization capability of the data-driven mechanical drilling rate prediction model based on the random forest model.  
Figure 8: ROP prediction results of well Kangtan2 based on random forest (R\({}^{2}\) = 0.83).  
Figure 7: ROP prediction results of well Fu39 based on random forest (R\({}^{2}\) = 0.94).