# Intelligent Prediction of Stuck Pipe Using Combined Data-Driven and Knowledge-Driven Model
## 3 Proposed Methodology
### Real-Time Analysis of Stuck Pipe Trend Based on Inversion of Friction Coefficient
#### 3.1.1 Real-Time Intelligent Calculation of WOB and TOB  
Mudlog Data Preprocessing  
1. Feature selection  
The WOB and TOB are related to many factors during drilling. Through the analysis of physical problems, the following parameters are selected as input parameters. Among them, the time sequence parameters are: WOB, TOB, depth, inclination, azimuth, torque, rpm, stand pipe pressure, outlet flow, inlet density, outlet density, total pool volume, hook tension, mud density, mud viscosity, mud plastic viscosity. Non-sequential parameters include: mud system, BHA (bottom hole assembly) and bit type.  
2. Normalization  
For sequential parameters, considering that mudlog parameters rarely have extreme maximum and minimum values and are restricted by drilling equipment capabilities, the maximum and minimum parameters can be set in advance or obtained by statistical analysis, so the minimax normalization method is used to normalize the time series data.  
For non-sequential parameters, the mud system is divided into water-based, oil-based and gas-based; Bit types are divided into PDC and cone; BHA is divided into pendulum, eyeful and tower. The above parameters are digitized by one hot method.  
Neural Network Optimization and Structure Design  
According to the characteristics of mudlog data in sequence and non-sequence, the adaptive neural networks, namely BP [24] and LSTM [25] networks, are selected.  
The formula of BP neural network is as follows,  
\[h_{\text{t}}=f(w_{\text{h}}x_{\text{t}}+b_{\text{h}}) \tag{1}\]  
\(x_{\text{t}}\) is the current input; \(w_{\text{h}}\) is the weight matrix of hidden layer; \(b_{\text{h}}\) is the  
The BP neural network in Figure 1 is used to input non-sequential data which are digitized by one-hot and have a dimension of 8. An input sample of the BP network is a one-dimensional vector.  
The LSTM network in Figure 1 is used to input sequential data. The historical time step is selected as 5, and a data sample input to the LSTM network is a 5 \(\times\) 16 matrix.  
Training, Testing and Optimization of BP-LSTM  
The data from 74 wells in the same block of Tarim Oilfield is used to test and optimize the BP-LSTM model. The data of 52 wells are used for training and the rest for testing.  
The number of network layers, the number of neurons, dropout and activation function are optimized and each model is trained 120 epochs. The three indexes of MAPE (mean absolute percentage error), RMSE (root mean square error) and model complexity which is the number of parameters to be trained are combined to optimize the model. The experimental scheme of the BP-LSTM model is shown in Table 1.  
\[\text{RMSE}=\sqrt{\frac{1}{N}{\sum}_{i=1}^{N}{\big{(}y_{\text{pre}}-y_{\text{ true}}\big{)}}^{2}} \tag{5}\]  
\[\text{MAPE}=\frac{{\sum}_{i=1}^{N}{\big{|}\frac{y_{\text{pre}}-y_{\text{true}} \big{|}}{y_{\text{true}}}\big{|}}}{N} \tag{6}\]  
\(y_{\text{true}}\) is the measured value; \(y_{\text{pre}}\) is the predicted value; \(N\) is the number of samples.  
\begin{table}
\begin{tabular}{c c c c c c c c c c} \hline \hline  & **Layers** & **Neurons** & **Layers** & **Neurons** & **LSTM** & **Dropout** & **Activation** & \multicolumn{2}{c}{**WOB (kN)**} & \multicolumn{2}{c}{**TOB (kN\(\cdot\)m)**} \\ \cline{5-10}  & **(BP)** & **(BP)** & **(LSTM)** & **(LSTM)** & **Dropout** & **Function** & **RMSE** & **MAPE** & **RMSE** & **MAPE** \\ \cline{5-10}  & 1 & 32 & 1 & 16 & 0.1 & sigmoid & 77.3 & 39.5 & 6.2  
Calculation Results of WOB and TOB  
The results of WOB and TOB are shown in Figures 2 and 3, respectively. The RMSE and MAPE of WOB is 23.8 kN and 13.0%, respectively. The RMSE and MAPE of TOB is 2.8 kN\(\cdot\)m and 12.8%, respectively.  
The BP-LSTM neural network is used to realize the real-time prediction of WOB and TOB, which lays a foundation for the real-time inversion of friction coefficient.