## 3 Methodology
### AIS Data Pre-Processing
Currently, the maximum speed of ultra-large container vessels can reach 25-32 knots, bulk carriers typically operate at 12-17 knots, and general cargo ships usually maintain speeds between 15-17 knots. As show in Figure 5, a speed distribution analysis of 2,884,799 trajectory points collected within one hour along the Chinese coast shows a high concentration of points in the 0-2 knot range, with almost no points exceeding 20 knots. Since this study focuses on vessel behavior within navigational channels, where speed limits are enforced  
Figure 4: MID Distribution. by authorities to ensure safe navigation, a speed threshold of 20 knots is established based on the statistical analysis and port safety regulations. Thus, any data with a speed field value or calculated speed exceeding 20 knots, based on the distance between consecutive trajectory points and the time interval, is considered an anomaly and is removed. The movement of vessels within port waters can generally be divided into three distinct phases: the incoming phase, where a vessel enters the channel and proceeds to a berth; the berthing phase, where the vessel is moored at the berth for cargo loading or unloading; and the outcoming phase, where the vessel departs from the berth and exits the channel. Based on this analysis, the speed of an individual vessel within the study area, when plotted over time, typically exhibits a pattern of high-to-low (incoming phase), a period of near-zero speed (berthing phase), and low-to-high (outcoming phase). Our research focuses primarily on the incoming and outcoming phases. Therefore, the vessel trajectory can be segmented based on speed variations to extract the trajectory data of individual voyages. Considering minor speed fluctuations, a threshold of 0.5 knots is selected to segment the trajectory. A complete trajectory used for training is defined as follows: For incoming vessels, the trajectory starts at the channel boundary and ends at the berth. For outgoing vessels, the trajectory starts at the berth and ends at the channel boundary. Due to the varying positions of the entrance and exit of the channel and the berth, the number of trajectory points in a single trajectory can vary significantly. Therefore, when organizing the training data, there is no restriction on the number of points in a single trajectory. However, the position of the trajectory's starting and ending position is very important. For a single trajectory, the vessel's length, width, and type can be retrieved from the static data using the MMSI, while the draft information can be obtained from the voyage information database based on the time range of the trajectory. The last point of an entry port trajectory and the first point of an exit port trajectory can be used to determine the berth location. By iterating through each trajectory point, the latitude and longitude of each point, along with the time difference between the point and the starting time, can be obtained. With this data, labeled training data can be generated as Equations (2) and (3). \(X\) and \(y\) form the labeled sample, the solid lines in the matrix separate multiple complete trajectories. The meaning of each feature is described in detail in Section 3.1. Figure 5: Ship speed Distribution. \[X=\begin{pmatrix}