# A ResNet1D-AttLSTM-Based Approach for Ship Trajectory Classification
## 2 Methods
### Data Preprocessing
This paper focuses on the research of classification algorithms for short-term trajectories, and the method for extracting trajectory sequences is as follows:  
* **Fixed time window-based segmentation:** For the navigation records of each ship in the AIS dataset, an initial trajectory segmentation is performed using a sliding window approach. Specifically, a fixed time window of 60 min is employed to traverse the entire navigation record in chronological order. Each window's trajectory points are aggregated into an independent trajectory sequence. * **Removal of anchoring points:** A speed threshold, \(V_{T}\), is set; if the speed of a trajectory point is less than \(V_{T}\), it is considered an anchoring point and removed from the trajectory sequence. Anchoring points are removed because they contain static data that contribute little to the analysis of vessel navigation behavior and may even introduce noise. * **Outlier removal:** An heuristic outlier detection method [34] is employed. Using the current trajectory point as the center and \(V_{max}\times\Delta_{t}\) as the radius (where \(V_{max}\) is the upper limit of the reasonable speed range and \(\Delta_{t}\) is the time interval between the current and next trajectory points), a circular region is defined. If the next trajectory point falls outside this circular region, it is identified as an outlier. Outliers are typically caused by sensor malfunctions, signal interference, or other external factors leading to data anomalies, which can interfere with the analysis of true vessel navigation behavior. * **Trajectory segmentation:** A time interval threshold, \(T_{seg}\), is set. In the trajectory sequence, the time interval between each trajectory point and the previous one is calculated. If the time interval exceeds \(T_{seg}\), it is marked as a segmentation point, dividing the trajectory sequence into multiple subsequences. The primary purpose of trajectory segmentation is to ensure that the trajectory points within each segment are more closely related in space and time, avoiding data dispersion caused by long time intervals. This helps the model learn more accurate behavioral patterns. * **Sequence length filtering:** A trajectory point count threshold, \(P_{num}\), is established. The number of trajectory points in each sequence is calculated, and sequences with fewer points than \(P_{num}\) are discarded. Removing overly short sequences reduces the impact of noise and allows the model to focus on high-quality data. After extracting the trajectory sequences, the dataset may still suffer from class imbalance. To address this issue, we performed undersampling on the majority classes in the trajectory sequence dataset by randomly removing a portion of the trajectory sequences from these classes to achieve a more balanced distribution across all categories. Furthermore, because certain features within the trajectory data have different scales and units, to prevent the model from becoming overly sensitive to some features--which could lead to a decrease in robustness--we applied min-max normalization. This method standardizes all features to a uniform range, ensuring that no single feature disproportionately influences the model due to its scale.