# Research on Wellbore Trajectory Prediction Based on a Pi-GRU Model
## 2 Materials and Methods  
### Data Preprocessing  
The performance of machine learning models is largely influenced by the quality of the input data, and this influence even surpasses the importance of the model architecture itself [16]. Therefore, constructing a high-quality dataset through appropriate data processing techniques is the key to improving the performance of a model and enhancing its generalizability.  
The attitude sensor of the current mining-while-drilling measurement system adopts a combination of triaxial accelerometers and flux gates. During the movement of the drill string, the accelerometers are prone to vibration interference, and the flux gates are susceptible to instantaneous magnetic field fluctuations. A large amount of noise is contained in data collected on site. Therefore, the Kalman filtering algorithm is used to adjust the covariance matrices of the system noise and observation noise to suppress measurement noise. The Kalman filtering algorithm has been widely applied in sensor signal processing and state estimation works, and its effectiveness has been verified by the research of [PERSON] et al. [17].  
In its specific implementation, this algorithm adopts a hierarchical threshold processing strategy. When the measured values of the triaxial accelerometer or fluxgate sensor fall within the preset range, the system classifies these abnormal fluctuations in the system noise model to perform dynamic compensation. In contrast, when the sensor output values exceed the established tolerance range (such as the overlimitation of the acceleration measurement range or severe distortion of the fluxgate signal), the abnormal data elimination mechanism is triggered. This hierarchical processing method can both retain effective information and reduce the interference of transient noise in the attitude calculation system. Taking the original data AX of the accelerometer as an example, the processing results are shown in Figure 3.  
Owing to the different orders of different input data, parameters with higher orders cause the model to pay excessive attention to them, thereby affecting the accuracy of  
Figure 3: Comparison between the signals AX before and after applying Kalman filtering processing.  
the model. To eliminate the dimensional differences among different data features and ensure that each feature has the same importance in the model training process, the data are standardized.  
Standardization is a data preprocessing technique that converts trajectory parameters such as the dip angle and azimuth into standardized features with a unified scale. Its core objective is to eliminate the unit differences in the original data, scale the data to a specific range, and ensure that different parameters are comparable during model training. During the data modeling process, the use of standardized data can highlight the degree of data dispersion, facilitate the capture of dispersed characteristics by the model, and reduce the influences of individual extreme values on the model. When the data ranges of the dip angle and azimuth are large, containing many outliers or offsets, standardization can prevent these deviations from impacting the training process by removing their means and unifying their standard deviations, enabling the model to better capture data patterns. The associated formula is as follows:  
\[Z=\frac{X-u}{\sigma} \tag{1}\]  
Here, \(Z\) represents the data value after performing standardization, \(X\) represents a specific data point in the original dataset, \(u\) denotes the mean of the original dataset, and \(\sigma\) signifies the standard deviation of the original dataset.