# Stream: Spatial Trajectory Enhanced Attention Mechanism for Abnormal UAV Trajectory Detection
## 3 System Design
### Deep Interpolation Model  
This section delves into the process of enhancing the DNN model's accuracy by refining the quality of the input dataset. This work includes the process of gathering UWB sensor data collected from edge devices to a central server, calculating the location data for each UAV from the central server, and visualizing the movement flight path. However, this process makes it difficult to collect data reliably for environmental reasons, and, in some cases, it can cause a large amount of missing values. This can ultimately lead to a decrease in the performance of the classification model. To solve this, we propose an advanced technique to interpolate these missing values. The Kalman filter stands out as a prominent interpolation technique, but its restoration capabilities are constrained by the extent of missing location data. Figure 3 shows the performance of the Kalman filter that varies depending on the missing rate of the location data that make up the trajectory. The trajectory depicted in Figure 3 is derived using the method outlined in Section 3.1. For this purpose, a Raspberry Pi equipped with a UWB sensor was utilized to simulate a UAV flying with the same sensor. When the distribution density of the original location data is high or the missing data are more than 50% of the original datasets, the restored trajectory gradually loses the original meaning. These distorted datasets can result in completely different predicted values from the classification model, which can have a negative impact on our research to precisely monitor flight patterns and detect anomalies. We propose a new interpolation methodology that can respond to complex and diverse interpolation problems with consistent performance and without distortion of the original data. Our proposal enables complex and sophisticated calculations through DNN, and operates so that the restored data are very similar to the original data even if serious data loss occurs. Figure 1 emphasizes the architecture of the proposed interpolation methodology with a red square. First, our suggestion performs interpolation for missing values based on images rather than numerical data. This image refers to data expressed in the form of an image by visualizing the trajectory composed of the location data of the UAVs calculated from the UWB sensor data covered in Section 3.1. Interpolation is not performed for all images, and the first criterion for judging interpolation for a single image is expressed as follows:  
\[N=\frac{n_{total}-n}{n_{total}}, \tag{6}\]  
where \(n_{total}\) denotes the total number of location data before data are lost, and \(n\) denotes the total number of location data after data are lost. The missing rate \(N\) is expressed as the number of missing coordinates divided by the total number of location data. For more precise control, we calculate the scaling constant \(M\) and it is expressed as  
\[n_{total}=\mu t, \tag{7}\]  
\[M=\log(\mu), \tag{8}\]  
where \(\mu\) denotes the number of UWB sensor data transmitted per second from the anchor to the server and \(M\) refers to the value expressed in the logarithmic scale of lambda. Even if the \(N\) is the same, when the location coordinate generation rate is high, the degree of loss can be considered more serious because the amount of lost data is greater. For this reason, we define the interpolation value \(K\) as follows:  
\[K=N*M. \tag{9}\]  
Our proposal is designed to perform interpolation only if the value of \(K\) is greater than the specified interpolation threshold \(K_{th}\). This is to reduce resource allocation and computing load resulting from unnecessary interpolation because deep neural networks for image processing require computationally intensive operations. In summary, we determine the necessity for interpolation through Equation (9) for each of the visualized trajectories and apply the DNN model described next only to cases where interpolation is necessary. Figure 3: This is the Kalman filter’s prediction for more than 30% missing trajectory.