# A Ship Trajectory Prediction Method Based on an Optuna-BILSTM Model
## 3 Visual Analysis of Trajectory Prediction  
According to the above experimental method, the AIS data LOG, LAT, SOG, and COG of the experimental vessel are used as input samples of the Optuna-BILSTM network model. The position LON and LAT of the experimental vessel are used as the output samples of the model, and the experimental results are shown in Figure 7.  
The models subjected to experimental comparison in this study encompass the Optuna-BILSTM model, the BILSTM model, the LSTM model, and the BP model proposed herein. These models were empirically fine-tuned manually, with the exception of the Optuna-BILSTM model, which underwent automatic tuning. The efficacy of the Optuna-BILSTM model was verified through the analysis of vessel trajectories derived from AIS data, evaluating, and contrasting its accuracy metrics (RMSE, MAPE, R2, and p) against those of the BP, LSTM, BILSTM, and other models. The comparative outcomes, presented in Table 1, demonstrate that the Optuna-BILSTM model consistently exhibits the lowest prediction error across six ships; it achieved an average MAPE value of 0.0043, surpassing the BP, LSTM, and BILSTM models, which recorded values of 0.031, 0.011, and 0.069, respectively. Similarly, the RMSE value for the Optuna-BILSTM model stood at 0.0044, notably lower than that of the BP (0.020), LSTM (0.096), and BILSTM (0.044) models. Moreover, the Optuna-BILSTM model attained the highest R2 score of 0.9972 compared with the BP  
Figure 6: Diagram of the parameter optimization process. Figure 7: Longitude and latitude predictions for ship 413380410. (0.8628), LSTM (0.9413), and BILSTM (0.9649) models. Consequently, the Optuna-BILSTM model demonstrated superior performance across all evaluated metrics. As shown in Table 2, \(p\)-values were utilized to ascertain the statistical significance of performance disparities between the Optuna-BILSTM model and comparative models. Specifically, \(p\)-values of 0.06 for both MAPE and RMSE in relation to the BP model underscore the superior performance of the Optuna-BILSTM model. Likewise, a \(p\)-value of 0.028 for RMSE when compared with the LSTM model further confirms the Optuna-BILSTM's enhanced predictive accuracy for this metric. In contrast, \(p\)-values exceeding 0.05 for the BILSTM model indicate no significant performance difference with the Optuna-BILSTM model, though R2 results suggest the latter's consistent superiority. Notably, for vessels 413380410, 413457220, and 414400930, R2 values for the Optuna-BILSTM model were 0.8%, 0.2%, and 6% higher, respectively, compared with the BILSTM model. The almost identical predicted and observed trajectories for vessel 413456950, with an R2 value of 0.9997 from the Optuna-BILSTM model, further attest to its predictive precision. Overall, the Optuna-BILSTM model demonstrates enhanced performance over the BP, LSTM, and BILSTM models in ship trajectory prediction, as visually summarized in the metric comparison in Figure 8.  
Figure 8 demonstrates that the Optuna-BILSTM model outshines others in this study, showcasing superior performance across both curved and straight trajectories. The BP model, a multilayer feedforward neural network trained via the error backpropagation algorithm, stands as one of the most utilized neural network models. However, its applicability to time-series data prediction is limited, resulting in suboptimal predictions with an average R2 value. In contrast, LSTM and BILSTM models, designed specifically for time-series data, address issues of gradient explosion or vanishing that may occur with the accumulation of previous data in the RNN input process. Consequently, the LSTM model surpasses the BP model in predictive outcomes, and the BILSTM model, augmenting the LSTM with a reverse time-series data-extraction layer, excels by extracting more data features, thereby enhancing the prediction performance.