Automatic Identiﬁcation System (AIS) Data Supported Ship Trajectory Prediction and Analysis via a Deep Learning Model

: Automatic Identiﬁcation System (AIS) data-supported ship trajectory analysis consistently helps maritime regulations and practitioners make reasonable trafﬁc controlling and management decisions. Signiﬁcant attentions are paid to obtain an accurate ship trajectory by learning data feature patterns in a feedforward manner. A ship may change her moving status to avoid potential trafﬁc accident in inland waterways, and thus, the ship trajectory variation pattern may differ from previous data samples. The study proposes a novel ship trajectory exploitation and prediction framework with the help of the bidirectional long short-term memory (LSTM) (Bi-LSTM) model, which extracts intrinsic ship trajectory features with feedforward and backward manners. We have evaluated the proposed ship trajectory performance with single and multiple ship scenarios. The indicators of mean absolute error (MAE), mean absolute percentage error (MAPE) and mean square error (MSE) suggest that the proposed Bi-LSTM model can obtained satisﬁed ship trajectory prediction performance.


Introduction
The development of global economic promotes goods transmission among different countries and cities via varied traffic modes, while the majority of freight volumes are transmitted by ships [1][2][3]. It can be observed that inland waterways become increasingly more congested due to the heavy raise of maritime traffic volumes, and thus, maritime traffic accidents may occur with a higher possibility. Therefore, it is of great importance to manage and monitor maritime traffic in the inland waterways via the support of varied maritime traffic data sources. The automatic identification system (AIS) is a common type of traffic data source used for maritime traffic management in the real world [4,5]. The AIS system mainly involves of ship-borne and shore-based facilities, which are used for AIS data transmission and reception, and the regular data transmission frequency ranges from 2 s to 10 min based on the ship moving speed [6,7].
The AIS system broadcasts both static and kinematic ship data to the neighboring ships and base stations, which include the ship type, Maritime Mobile Service Identity (MMSI), speed, real-time location (i.e., latitude and longitude), etc. [8]. It is noted that neighboring ships receive the AIS data with a given time interval, which is further used to explore the on-spot traffic situation [9]. Moreover, numerous AIS stations deployed at coastal areas store AIS data transmitted by ships travelling in the area, which can be used to support maritime traffic 2 of 12 management and controlling by maritime officials and ship company as well. Many focuses are paid to control maritime traffic by predicting ship moving trajectories via the support of historical AIS data [10,11]. In that way, accurate ship trajectory plays an important role in the reasonable decision-making operation for maritime traffic management. It is observed that many studies are conduced to predict ship trajectories with conventional machine learning models, which forecast potential ship routes by exploring shallow data features from the input AIS samples [12,13].
Traditional framework may perform well when the ship moving pattern does not significantly change for a given time period (e.g., sudden acceleration/deceleration). For instance, Zhang et al. predicted traffic flow with an enhanced particle swarm optimization model supported by the back propagation mechanism [14]. Yu et al. evaluated the offshore wind farm impact on maritime traffic flow variation with steps of raw AIS data collection, data cleansing and the farm influence analysis [15]. Similar studies can be found in [16][17][18][19]. However, ship traveling in the inland waterways may maneuver its moving direction and speed to avoid potential traffic accidents due to maritime traffic jam [20,21]. In that manner, there is an urgent need to predict ship trajectories by exploring intrinsic spatial-temporal features from historical AIS data.
Deep learning models have shown its successes in the traffic flow prediction task, and the long sort term memory (LSTM) model is a common yet popular model used for traffic flow prediction [22,23]. Zhou et al. clustered ship behaviors from inland massive AIS data series, and thus, further recognized ship behavior patterns with the support of behavior clustering results [24]. Bai et al. also investigated financial operation risk for global tramp shipping industry via AIS data support [25]. Duan et al. proposed a semi-supervised deep learning method to classify ship trajectory type via the help of both of kinematic and static information from AIS data [26]. More specifically, Duan et al. aimed to classify ship trajectory category via the support of limited yet labeled AIS data. In contrast, our study intends to predict ship trajectory with the support of historical AIS data. It is found that the deep learning model maybe overfitting due to the lack of backward context training procedure. It is found that several measurements can be taken to avoid the overfitting phenomenon, which consists of data augmentation, ensemble learning technique, abnormal data removal, etc. We try to alleviate the overfitting weakness with the abnormal data removal-based logic.
The aim of the study is to predict ship trajectory with a bidirectional LSTM (Bi-LSTM) model, and thus, further analyze trajectory variation tendency with the data prediction results. Moreover, we can also predict potential berth port by accurately forecasting ship trajectory data, especially with the support of speed-related kinematic information contained in the AIS data [27,28]. The study helps maritime traffic practitioners (e.g., maritime traffic officials, ship crew, etc.) make management and ship maneuvering operation in a more reasonable manner. The remainder of the paper is organized as follows. Section 2 describes the methodology used in the study, while Section 2.3 illustrates the experiment of the study. The final section briefly concludes the study and describes potential future research.

AIS Data Normalization
We have downloaded the raw AIS data from the publicly accessible website https: //marinecadastre.gov/ais/ [29]. Note that the website maintenance department has already conducted data outlier correction procedure to suppress obvious data outliers. The step aims to suppress potential AIS data outliers from raw AIS dataset regardless of interferences of ship type, buoy AIS, etc. More specifically, the preprocessing step in the study mainly focus on data outliers, and thus, factors triggering the data outliers are beyond the research scope. The ship position may range from varied latitude and longitude area, which may impose additional interference for maritime traffic situation analysis via the support of AIS data. We have normalized the time span between neighboring AIS data samples into 10 second in the study. Besides, both of the latitude and longitude data are mapped into interval from 0 to 1 via the help of min-max normalization method (see Equation (1)). More specifically, the raw latitude (and longitude) is mapped onto a new latitude (and longitude) value by subtracting the minimum latitude and dividing the difference between maximum and minimum latitudes. Note that the symbol lat raw denotes the raw latitude for a given AIS data sample, while the lat max and lat min are the maximum and minimum latitudes, respectively. The lat n represents the normalized latitude sample. We can obtain the normalized longitude data by following the same rule for calculating the normalization latitude data (see Equation (2)). The parameters lon raw , lon min , lon max and lon n demonstrate raw, minimum, maximum and normalized longitude AIS data sample: lon n = lon raw − lon min lon max − lon min (2)

Basic LSTM Model
The basic LSTM model is a type of efficient sequential data prediction model, which originated from a recurrent neural network. It is found that the prediction error will significantly increase due to iterative weight matrix multiplication. The LSTM model mitigates such a disadvantage by introducing a gate controlling mechanism for the purpose of suppressing data feature loss and non-trivial data transmission. More specifically, the LSTM learns data features by integrating the input gate, output gate and forget gate during the training and prediction procedure. We employ the symbol L to denote the input AIS data series, and L p demonstrates the prediction result. We can obtain the formulas for the input gate (denoted as G in ), forget gate (labeled as G fgt ) and output gate (labeled as G out ) with Equations (3)-(5): where β j , γ j and µ j (j = 1, 2, 3) are the weight matrices for the input gate, forget gate and output gate, respectively. Moreover, the parameters V, C and C are activation vectors in the deep neural network.

Ship Trajectory Prediction with the Bi-LSTM Model
The conventional LSTM model outputs the maritime traffic data by only considering the historical data pattern. The model may obtain obvious biased results when the ship significantly changes movement state (e.g., a ship sharply varying her maneuvering direction and speed). The Bi-LSTM model can mitigate the LSTM model disadvantage since the Bi-LSTM model assumes that both the historical and future variation pattern may affect the ship data prediction performance [30]. More specifically, the Bi-LSTM model employs the prediction output to feed back into the model training procedure for the purpose of enhancing model performance. The Bi-LSTM model consists of forward layer and feedback layer (with basic LSTM units), and the overview for the Bi-LSTM network can be found in Figure 1. The Bi-LSTM model obtains final training and prediction results by learning intrinsic features from both of forward layer outputs and feedback layer. Note that the forward (feedback) layer in the Bi-LSTM model plays the role of AIS data pattern transmission in a forward (backward) manner. The information obtained by both of the forward and feedback layers generate final output of the AIS data prediction results. found in Figure 1. The Bi-LSTM model obtains final training and prediction results by learning intrinsic features from both of forward layer outputs and feedback layer. Note that the forward (feedback) layer in the Bi-LSTM model plays the role of AIS data pattern transmission in a forward (backward) manner. The information obtained by both of the forward and feedback layers generate final output of the AIS data prediction results.

Evaluation Metrics
We introduce three popular yet efficient indicators to analyze maritime traffic flow data prediction accuracy. More specifically, the indicators of mean absolute error (MAE), mean absolute percentage error (MAPE) and mean square error (MSE) are introduced to evaluate model performance by following the rules in previous studies [31,32]. The MAE indicator measures the absolute error between the ground-truth and prediction AIS data series, which are further implemented in terms of latitude and longitude (see Equation (6)). The MAPE quantifies model performance in the manner of percentage (see Equation (7)). The rule of thumb suggests that the prediction model obtains satisfied performance when the MAPE is smaller than 10. The MSE indicator represents mean value for the square error between the predicted and ground-truth AIS data samples (see Equation (8)). It is noticed that lower MAE, MSE and MAPE indicate better traffic data prediction performance.

Evaluation Metrics
We introduce three popular yet efficient indicators to analyze maritime traffic flow data prediction accuracy. More specifically, the indicators of mean absolute error (MAE), mean absolute percentage error (MAPE) and mean square error (MSE) are introduced to evaluate model performance by following the rules in previous studies [31,32]. The MAE indicator measures the absolute error between the ground-truth and prediction AIS data series, which are further implemented in terms of latitude and longitude (see Equation (6)). The MAPE quantifies model performance in the manner of percentage (see Equation (7)). The rule of thumb suggests that the prediction model obtains satisfied performance when the MAPE is smaller than 10. The MSE indicator represents mean value for the square error between the predicted and ground-truth AIS data samples (see Equation (8)). It is noticed that lower MAE, MSE and MAPE indicate better traffic data prediction performance.
where R(i) demonstrates the predicted ith AIS data sample and the GT(i) is the counterpart of the ground-truth sample. The number n indicates overall data samples for a given AIS segment.

Experimental Setups
The platform used for AIS data prediction performance analysis consists of hardware and software setups. From the perspective of hardware settings, we employ the Intel(R) Core (TM) i7-8750H with CPU frequency of 2.2 GHz. The RAM size is 16 G, and the GPU used in the study is NVIDIA GeForce GTX 1050 Ti. The software setups in the study include the win10 operation system. The coding language for implementing traffic flow prediction task is python via the support of tensorflow and the Keras deep network structure. More details for the experimental setups can be found in Table 1. We have employed the Pandas and Numpy packages to preprocess and visualize the AIS data. For the purpose of model performance comparison, we have implemented the LSTM [33], social LSTM (SOC-LSTM) [34] and social generative adversarial network (SOC-GAN) [35] to achieve ship trajectory prediction task. Note that our proposed ship trajectory prediction model was labeled as Bi-LSTM model for the purpose of readability. It is noted that accurate ship trajectory benefits varied maritime traffic participants (e.g., maritime traffic regulation department, ship crew). More specifically, a traffic variation trend can be predicted with support of accurate ship trajectory data. In that manner, model performance is evaluated in terms of ship trajectory prediction accuracy. Moreover, we collect the ship trajectory data, while the ships are involved with typical maritime traffic scenario (i.e., head-on situation). Moreover, we have collected the AIS data from three merchant ships since that the majority of maritime goods carriages are transported by merchant ships. In that way, we can verify the model performance for the ship trajectory prediction task, which can be further used to analyze the ship maneuvering and controlling strategy. We collected the AIS data of ships with MMSI code number 413842854, 413694210 and 412592160, which were indeed merchant ships. For the purpose of readability, we labeled the ship with MMSI 413842854 as ship #1, and the latter two ships as ship #2 and #3, respectively.
It is noted that ship trajectory can be easily identified from the longitude and latitude variation from the AIS data series. In that manner, we predict ship trajectory by focusing on the longitude and latitude data. The primary parameter settings in the study are shown in Table 2. The training epoch number is set to 2000, and default learning rate is set to 1.00 × 10 −4 . We set the batch size into 64, and the MSE function is introduced as the loss function in the proposed deep learning framework. It is observed that model performance is also affected by network parameter settings, while input feature number and hidden layer node number play a more important role. The optimal settings for the input feature number and hidden layer node number for different models (i.e., Bi-LSTM, LSTM, SOC-LSTM and SOC-GAN) are shown as Table 3. Note that we did not provide the normalized AIS data in the following sections for the purpose of better readability.

Single-Ship Trajectory Prediction and Analysis
We obtained the single-ship (with MMSI 413842854) trajectory prediction performance for different models, which can be found in Figure 2. It was observed that the conventional LSTM and Bi-LSTM models obtained better performance compared to those of the socialbased deep learning models (i.e., SOC-LSTM and SOC-GAN). Indeed, the ship trajectory prediction accuracy for the SOC-LSTM model was worse than the other three models. The SOC-GAN showed an obvious bias results compared to those of the ground truth AIS data samples. One possible reason may be that the model introduced some negative AIS variation tendency during the training procedure.   We have provided the ship trajectory segment prediction performance for the ship (with MMSI code 413842854) in terms of latitude and longitude data samples. Note that the unit for the latitude and longitude data was degree, without further specifications in the study. Table 4 suggested that the latitude prediction accuracy obtained by the Bi-LSTM model was higher than the counterparts of LSTM, SOC-LSTM and SOC-GAN. More specifically, we found that the latitude prediction error for the Bi-LSTM model was smaller than 1%, and the LSTM counterpart was similar yet larger than that of the Bi-LSTM model. The latitude data prediction errors for both of SOC-LSTM and SOC-GAN models were slightly larger than the Bi-LSTM and LSTM models. Table 5 demonstrated trajectory segment prediction performance on the longitude data samples for the ship with MMSI code 413842854. It was observed that the ship longitude prediction accuracy showed similar performance compared those of the latitude data prediction performance. More specifically, the Bi-LSTM model outperformed the LSTM, SOC-LSTM and SOC-GAN models in terms of the longitude data prediction task.  to that of the Bi-LSTM model. The MAE indictor for the SOC-GAN model was 1.64 × 10 −1 , which was obviously larger than the counterparts of Bi-LSTM, LSTM and SOC-LSTM. The MAPE indicator variation tendency showed similar performance compared to those of the MAE indicator. More specifically, the MAPE for the Bi-LSTM was 6.74 × 10 −5 , which was about half to that of the LSTM model (i.e., 1.15 × 10 −4 ). The MAPE indicators for the SOC-LSTM and SOC-GAN models were 8.66 × 10 −4 and 4.13 × 10 −4 , respectively. We found that the MSE values were smaller than those of the MAE and MAPE. It was observed that MSE for the Bi-LSTM model was 1.43 × 10 −9 , which was significantly lower than the counterparts of the MAE and MAPE. The MSE values for the LSTM, SOC-LSTM and SOC-GAN were 1.94 × 10 −9 , 4.63 × 10 −7 and 7.79 × 10 −2 , which were at least 30% larger than that of the Bi-LSTM model. In sum, the Bi-LSTM model can accurately predict ship trajectory in terms of the MAE, MSE and MAPE indicators compare to those of the LSTM, SOC-LSTM and SOC-GAN models.

Trajectory Prediction for Multiple Ships
We simultaneously analyzed trajectory prediction performance for multiple ships (i.e., three ships in our study) for the purpose of model performance comparison. Note that the ships with MMSI codes 412592160, 413694210 and 413842854 were labeled as ship A, ship B and ship C, respectively, in our study. It can be observed that the Bi-LSTM model can accurately predict ship trajectory, since the predicted ship trajectory samples matched the ground truth data well (see the Figure 3). The LSTM model prediction performance was similar to that of the Bi-LSTM models considering that the predicted and ground truth ship trajectory samples were quite close to each other, as shown in Figure 4. Note that our study mainly focused on ship trajectory prediction with the latitude and longitude information, regardless of ship speed and heading data. The main reason was that the above-mentioned ship kinematic data variation (i.e., speed and heading data) can be inferred from ship trajectory data. More specifically, maritime traffic safety-related analysis can be fulfilled by exploring ship position data variations. Moreover, the distance was measured while the ship was considered as a particle. In that way, the distance between neighboring AIS data samples was acceptable (i.e., did not threaten maritime traffic).
LSTM model can accurately predict ship trajectory in terms of the MAE, MSE and MAPE indicators compare to those of the LSTM, SOC-LSTM and SOC-GAN models.

Trajectory Prediction for Multiple Ships
We simultaneously analyzed trajectory prediction performance for multiple ships (i.e., three ships in our study) for the purpose of model performance comparison. Note that the ships with MMSI codes 412592160, 413694210 and 413842854 were labeled as ship A, ship B and ship C, respectively, in our study. It can be observed that the Bi-LSTM model can accurately predict ship trajectory, since the predicted ship trajectory samples matched the ground truth data well (see the Figure 3). The LSTM model prediction performance was similar to that of the Bi-LSTM models considering that the predicted and ground truth ship trajectory samples were quite close to each other, as shown in Figure 4. Note that our study mainly focused on ship trajectory prediction with the latitude and longitude information, regardless of ship speed and heading data. The main reason was that the abovementioned ship kinematic data variation (i.e., speed and heading data) can be inferred from ship trajectory data. More specifically, maritime traffic safety-related analysis can be fulfilled by exploring ship position data variations. Moreover, the distance was measured while the ship was considered as a particle. In that way, the distance between neighboring AIS data samples was acceptable (i.e., did not threaten maritime traffic).   The ship trajectory segment prediction performance shown in Figures 5 and 6 indicated that both of the SOC-LSTM and SOC-GAN models failed to obtain satisfied performance. It was found that the predicted trajectory for ship A for the SOC-LSTM model was obviously different from that of the ground truth data (see Figure 5). The prediction per- The ship trajectory segment prediction performance shown in Figures 5 and 6 indicated that both of the SOC-LSTM and SOC-GAN models failed to obtain satisfied performance. It was found that the predicted trajectory for ship A for the SOC-LSTM model was obviously different from that of the ground truth data (see Figure 5). The prediction performance for ship B and ship C for the SOC-LSTM were similar to that of the ship A. It can be inferred that SOC-LSTM model output ship trajectory with similar variation tendency compared to those of the ground truth ship trajectories with a larger span. The ship trajectory prediction results for the SOC-GAN model shown in the Figure 6 suggested that the predicted ship trajectory variation tendency was different from that of the ground truth data. The ship trajectory segment prediction performance shown in Figures 5 and 6 indicated that both of the SOC-LSTM and SOC-GAN models failed to obtain satisfied performance. It was found that the predicted trajectory for ship A for the SOC-LSTM model was obviously different from that of the ground truth data (see Figure 5). The prediction performance for ship B and ship C for the SOC-LSTM were similar to that of the ship A. It can be inferred that SOC-LSTM model output ship trajectory with similar variation tendency compared to those of the ground truth ship trajectories with a larger span. The ship trajectory prediction results for the SOC-GAN model shown in the Figure 6 suggested that the predicted ship trajectory variation tendency was different from that of the ground truth data.  More specifically, we may infer that the model may have extracted biased ship trajectory features from the training data samples. In sum, ship trajectory prediction results shown from Figures 4-6 indicated that the Bi-LSTM and conventional LSTM model successfully exploited ship features from historical trajectory data samples. Meanwhile, the social based deep learning models failed to identify ship trajectory variation tendency. The ship crew can identify on-site traffic situation via the support of AIS data, which can be further determined with other common maritime data sources (such as very high frequency radio, radar, etc.). More specifically, the AIS data can help on-board ship staff identify on-site traffic situations, while emergency traffic scenarios will be further confirmed with other maritime data sources. In that manner, maritime traffic safety can be ensured by implementing efficient yet proper ship maneuvering operations.
We obtained the aggregated ship trajectory prediction performance in terms of MAE, MAPE and MSE, which can be found in Table 7. Distributions for the three indicators suggested that the Bi-LSTM model obtained better performance compared with the LSTM, SOC-LSTM and SOC-GAN models. The values for the MAE, MAPE and MSE were 6.46 × 10 , 9.07 × 10 and 3.98 × 10 , which were smaller than the counterparts of other three models. It was noted that the MAE indicator for the LSTM model was approximately three-fold larger than that of the Bi-LSTM model. The MAPE and MSE indicators of the LSTM model, which were 1.31 × 10 and 1.02 × 10 , respectively, showed similar performance compared to that of the MAE indicator. The aggregated MAE, MAPE and MSE for the SOC-LSTM were at least two-fold larger than those of the LSTM model, which were 3.57 × 10 , 7.98 × 10 and 3.31 × 10 . The three indicators (i.e., MAE, MAPE and MSE) for the SOC-GAN, shown in the Table 7, were smaller than those of the SOC-LSTM.   More specifically, we may infer that the model may have extracted biased ship trajectory features from the training data samples. In sum, ship trajectory prediction results shown from Figures 4-6 indicated that the Bi-LSTM and conventional LSTM model successfully exploited ship features from historical trajectory data samples. Meanwhile, the social based deep learning models failed to identify ship trajectory variation tendency. The ship crew can identify on-site traffic situation via the support of AIS data, which can be further determined with other common maritime data sources (such as very high frequency radio, radar, etc.). More specifically, the AIS data can help on-board ship staff identify on-site traffic situations, while emergency traffic scenarios will be further confirmed with other maritime data sources. In that manner, maritime traffic safety can be ensured by implementing efficient yet proper ship maneuvering operations.
We obtained the aggregated ship trajectory prediction performance in terms of MAE, MAPE and MSE, which can be found in Table 7. Distributions for the three indicators suggested that the Bi-LSTM model obtained better performance compared with the LSTM, SOC-LSTM and SOC-GAN models. The values for the MAE, MAPE and MSE were 6.46 × 10 −5 , 9.07 × 10 −5 and 3.98 × 10 −9 , which were smaller than the counterparts of other three models. It was noted that the MAE indicator for the LSTM model was approximately three-fold larger than that of the Bi-LSTM model. The MAPE and MSE indicators of the LSTM model, which were 1.31 × 10 −4 and 1.02 × 10 −8 , respectively, showed similar performance compared to that of the MAE indicator. The aggregated MAE, MAPE and MSE for the SOC-LSTM were at least two-fold larger than those of the LSTM model, which were 3.57 × 10 −4 , 7.98 × 10 −4 and 3.31 × 10 −7 . The three indicators (i.e., MAE, MAPE and MSE) for the SOC-GAN, shown in the Table 7, were smaller than those of the SOC-LSTM.

Conclusions
Ship trajectory prediction and identification provides crucial traffic information to varied maritime activity practitioners, such as on-duty ship crew, maritime traffic officials, etc. The study aimed to accurately predict ship trajectory by introducing a deep learningbased framework. More specifically, we predicted trajectory variation in terms of a single ship and multiple ships with AIS data samples. Moreover, we have further evaluated our model performance against additional popular ship trajectory prediction models (i.e., LSTM, SOC-LSTM and SOC-GAN). Experimental results suggested that the proposed Bi-LSTM based framework can obtain better accuracy considering that prediction errors (quantified by the MAE, MAPE and MSE indicators) for the proposed model were smaller than the counterparts obtained by the other three models (i.e., LSTM, SOC-LSTM and SOC-GAN). Moreover, the LSTM model outperformed the SOC-LSTM and SOC-GAN models in terms of the MAE, MAPE and MSE indicators. The research findings can help maritime authorities, and ship owners make more reasonable maneuver operations in advance with the help of ship trajectory information.
We can further improve our study by exploring the following potential directions. First, ship navigation surroundings (e.g., wave, wind, buoys) may impose additional interference to ship maneuvering operations, and thus leading to different ship trajectories. We can further quantify the ship navigation interference factors by implementing the ship trajectory prediction task in future. Second, the time cost for training a deep learning model may significantly increase with an increased number of neurons. We can introduce other training mechanisms to reduce time cost without suppressing model prediction performance. Third, the model performance was verified under typical maritime traffic situation regardless of waterway conditions. The proposed framework was supposed to obtain satisfied performance in narrow channels due to that ship smoothly moves in the narrow waterways (i.e., ship movement pattern was straightforward). We can further explore traffic impact on the trajectory extraction task in future. Last but not least, we may further integrate the attention mechanism into the Bi-LSTM model by focusing on intrinsic data feature exploitation.