## 2 AIS Data Pre-Processing  
### Data Preprocessing  
Some fields in AIS messages are key information for classification. Considering that the dynamic features (from message1) should fully reflect the kinematic information of the ship at a specific moment, and the static features (from message5) should reflect the ship's dimensions, draft, and type, we filter the key fields, as listed in Table 1, from the AIS message for ship classification. MMSI is the unique identification of a ship. The Time field in message1 is the time flag that is automatically injected by the space-based AIS receiver every minute [23], and it is accurate to a minute. Time Stamp is the UTC second when the AIS message is broadcasted. The exact time when the AIS message is sent can be obtained by combining the Time and Time Stamp. A, B, C, and D reflect the overall dimensions of the ship, which, respectively, represent the distances from the reference point O to the bow, stern, port side, and starboard of the ship, as shown in Figure 3. The ship length and width are calculated by Equation (1).  
\[\left\{\begin{array}{l}length=A+B\\ width=C+D\end{array}\right. \tag{1}\]  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Data** & **Fields Used** \\ \hline \multirow{3}{*}{Dynamic (message1)} & MMIS, Time, TimeStamp, Longitude, Latitude, SOC \\  & (Speed over ground), COG (Course over ground), \\ \cline{1-1}  & ROT (Rate of turn) \\ \cline{1-1}  & MMSI, A, B, C, D, Draught, Type \\ \hline \hline \end{tabular}
\end{table}
Table 1: Fields selected from dynamic and static data.  
Figure 2: The overall process of MFELCM.  
Raw AIS data may contain bad data, duplicate data, and missing data. In addition, the data format may be not convenient to analyze [24; 25]. We perform the following data preprocessing operations on the fields in Table 1.  
* If the field does not conform to the standards in [4], the message to which the field belongs is defined as an error message and should be removed.
* If all fields of several messages are the same, remove all but one message. For dynamic messages, if the duplicate fields are only MMSI, Time, and Time Stamp, all messages should be removed because we cannot determine the authenticity of these messages.
* In creating the Type field for message1, the values of Type are obtained from message5 by matching MMSI in mesage1 and message5.
* Replace the value seconds in the Time field of message1 with TimeStamp to obtain the exact moment the messages were sent.
* If there exists empty fields in a message, the message is defined as missing data. For dynamic messages, remove the missing data. For static messages, fill the empty fields with 0.  
Equation (2) defines the preprocessed static and dynamic data. For a ship whose MMSI is \(i_{m}\), \(d_{j}^{i_{m}}\) is the \(j\)th dynamic data of this ship in time order, and \(s^{i_{m}}\) is the static data of this ship. Moreover, Equation (3) defines the trajectory of this ship as a time series \(T^{i_{m}}\).  
\[\left\{\begin{array}{c}d_{j}^{i_{m}}=\left[time_{j}^{i_{m}},ng_{j}^{i_{m}}, lat_{j}^{i_{m}},SOG_{j}^{i_{m}},COG_{j}^{i_{m}},ROT_{j}^{i_{m}},type^{i_{m}} \right]^{T}\\ s^{i_{m}}=\left[A^{i_{m}},B^{i_{m}},C^{i_{m}},D^{i_{m}},draght^{i_{m}},type^{i_ {m}}\right]^{T}\\ \\ T^{i_{m}}=\left[d_{0}^{i_{m}},d_{1}^{i_{m}},\cdots,d_{k}^{i_{m}}\right]\cdots \cdots k>=1\end{array}\right. \tag{2}\]  
\[T^{i_{m}}=\left[d_{0}^{i_{m}},d_{1}^{i_{m}},\cdots,d_{k}^{i_{m}}\right]\cdots \cdots k>=1 \tag{3}\]