# Integrating k-means Clustering and LSTM for Enhanced Ship Heading Prediction in Oblique Stern Wave

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Principles and Methods

#### 2.1. k-means Clustering

#### 2.2. RNN and the LSTM Model

#### 2.3. Data Normalization

#### 2.4. LSTM Input and Output Data Mapping

## 3. Data from the Autopilot of Ship in Waves

#### 3.1. The Autopilot of Ship in Waves

#### 3.2. Wave and Ship Motion Data

## 4. Model Construction and Evaluation

#### 4.1. Model Structure and Initial Features

#### 4.2. Performance Evaluation and Optimization

## 5. Prediction Based on the LSTM

#### 5.1. Selection Process for Input Length

#### 5.2. Prediction Based on the Data after k-means Clustering

#### 5.3. The Effect of Input Features

#### 5.4. Comparisons of Multi-Task Learning

#### 5.5. Optimization Method Prediction

## 6. Conclusions

- (1)
- In this paper, K-means clustering is applied to the classification of trimaran sailing data. It is found from the comparison that the model trained by the datasets with similar trends could be of relatively better prediction accuracy. Evaluation metrics like MSE, RMSE, and MAE compared predictions of different data subsets. Clustered datasets showed similarities, with better predictions within the same group.
- (2)
- Our analysis evaluated the impact of various feature combinations on predictive performance. Removing the force feature significantly improved accuracy, reducing MSE, RMSE, and MAE values. Excluding the features of speed and trajectory led to accuracy deterioration. Feature selection is crucial for precise predictions and advancing predictive modeling.
- (3)
- Using multi-task learning, the predictive ability is enhanced. Training multiple datasets with different initial conditions enhanced predictive capability. Including more datasets improved accuracy by capturing complex relationships. Better utilizing available data is crucial for constructing predictive models.

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Acknowledgments

## Conflicts of Interest

## References

- Triantafyllou, M.; Bodson, M.; Athans, M. Real time estimation of ship motions using Kalman filtering techniques. IEEE J. Ocean. Eng.
**1983**, 8, 9–20. [Google Scholar] [CrossRef] - Sutulo, S.; Moreira, L.; Soares, C.G. Mathematical models for ship path prediction in manoeuvring simulation systems. Ocean. Eng.
**2002**, 29, 1–19. [Google Scholar] [CrossRef] - Rigatos, G.G. Sensor fusion-based dynamic positioning of ships using Extended Kalman and Particle Filtering. Robotica
**2013**, 31, 389–403. [Google Scholar] [CrossRef] - Perera, L.P. Navigation vector based ship maneuvering prediction. Ocean. Eng.
**2017**, 138, 151–160. [Google Scholar] [CrossRef] - Fossen, S.; Fossen, T.I. Exogenous Kalman Filter (xkf) for Visualization and Motion Prediction of Ships Using Live Automatic Identification Systems (ais) Data. 2018. Available online: http://hdl.handle.net/11250/2584706 (accessed on 1 April 2018).
- Jiang, H.; Duan, S.; Huang, L.; Han, Y.; Yang, H.; Ma, Q. Scale effects in AR model real-time ship motion prediction. Ocean. Eng.
**2020**, 203, 107202. [Google Scholar] [CrossRef] - Luo, W.; Zhang, G. Ship motion trajectory and prediction based on vector analysis. J. Coast. Res.
**2020**, 95, 1183–1188. [Google Scholar] [CrossRef] - Shen, Y. On the Neural Network Theory and Its Application in Ship Motion Prediction. Ph.D. Thesis, Harbin Engineering University, Harbin, China, 2005; pp. 5–83. [Google Scholar]
- Khan, A.; Marion, K.; Bil, C. The prediction of ship motions and attitudes using artificial neural networks. Asor Bull.
**2007**, 26, 2. [Google Scholar] - Yang, G.; Jie, Q.M.; Tao, N.Q. Prediction of ship motion attitude based on BP network. In Proceedings of the 2017 29th Chinese Control And Decision Conference (CCDC), Chongqing, China, 28–30 May 2017; IEEE: Piscataway, NJ, USA, 2017; pp. 1596–1600. [Google Scholar]
- Chen, X.; Liu, Y.; Achuthan, K.; Zhang, X. A ship movement classification based on Automatic Identification System (AIS) data using Convolutional Neural Network. Ocean. Eng.
**2020**, 218, 108182. [Google Scholar] [CrossRef] - Zhang, T.; Zheng, X.Q.; Liu, M.X. Multiscale attention-based LSTM for ship motion prediction. Ocean. Eng.
**2021**, 230, 109066. [Google Scholar] [CrossRef] - Bassam, A.M.; Phillips, A.B.; Turnock, S.R.; Wilson, P.A. Ship speed prediction based on machine learning for efficient shipping operation. Ocean. Eng.
**2022**, 245, 110449. [Google Scholar] [CrossRef] - Kong, Z.; Cui, Y.; Xiong, W.; Xiong, Z.; Xu, P. Ship Target Recognition Based on Context-Enhanced Trajectory. ISPRS Int. J. Geo-Inf.
**2022**, 11, 584. [Google Scholar] [CrossRef] - Abebe, M.; Noh, Y.; Kang, Y.-J.; Seo, C.; Kim, D.; Seo, J. Ship trajectory planning for collision avoidance using hybrid ARIMA-LSTM models. Ocean. Eng.
**2022**, 256, 111527. [Google Scholar] [CrossRef] - Kim, D.; Song, S.; Jeong, B.; Tezdogan, T. Numerical evaluation of a ship’s manoeuvrability and course keeping control under various wave conditions using CFD. Ocean. Eng.
**2021**, 237, 109615. [Google Scholar] [CrossRef] - Gong, J.; Li, Y.; Cui, M.; Yan, S.; Ma, Q. Study on the surf-riding and broaching of trimaran in quartering seas. Ocean. Eng.
**2022**, 266, 112995. [Google Scholar] [CrossRef] - Tang, X.; Gu, J.; Shen, Z.; Chen, P. A flight profile clustering method combining twed with K-means algorithm for 4D trajectory prediction. In Proceedings of the 2015 Integrated Communication, Navigation and Surveillance Conference (ICNS), Herdon, VA, USA, 21–23 April 2015; IEEE: Piscataway, NJ, USA, 2015; pp. S3-1–S3-9. [Google Scholar]
- Anderson, J.A. An Introduction to Neural Networks; MIT Press: Cambridge, MA, USA, 1995. [Google Scholar]
- Barnard, E. Optimization for training neural nets. IEEE Trans. Neural Netw.
**1992**, 3, 232–240. [Google Scholar] [CrossRef] - Hochreiter, S.; Schmidhuber, J. Long short-term memory. Neural Comput.
**1997**, 9, 1735–1780. [Google Scholar] [CrossRef] - Liu, J.; Gong, X. Attention mechanism enhanced LSTM with residual architecture and its application for protein-protein interaction residue pairs prediction. BMC Bioinform.
**2019**, 20, 609. [Google Scholar] [CrossRef] - Kramer, O. Machine Learning for Evolution Strategies; Springer: Berlin/Heidelberg, Germany, 2016. [Google Scholar]
- Rusche, H. Computational Fluid Dynamics of Dispersed Two-Phase Flows at High Phase Fractions. Ph.D. Thesis, Imperial College London (University of London), London, UK, 2003. [Google Scholar]
- Weller, H.G. Derivation, Modelling and Solution of the Conditionally Averaged Two-Phase Flow Equations; Technical Report TR/HGW/02; Nabla Ltd.: Sofia, Bulgaria, 2002; Volume 2, p. 9. [Google Scholar]
- Ma, Q.W.; Yan, S. QALE-FEM for numerical modelling of nonlinear interaction between 3D moored floating bodies and steep waves. Int. J. Numer. Methods Eng.
**2009**, 78, 713–756. [Google Scholar] [CrossRef] - Yan, S.; Ma, Q.W. QALE-FEM for modelling 3D overturning waves. Int. J. Numer. Methods Fluids
**2010**, 63, 743–768. [Google Scholar] [CrossRef] - Hu, Z.Z.; Yan, S.; Greaves, D.; Mai, T.; Raby, A.; Ma, Q. Investigation of interaction between extreme waves and a moored FPSO using FNPT and CFD solvers. Ocean. Eng.
**2020**, 206, 107353. [Google Scholar] [CrossRef] - Gong, J.; Li, Y.; Cui, M.; Fu, Z.; Hong, Z. The effect of side-hull position on the seakeeping performance of a trimaran at various headings. Ocean. Eng.
**2021**, 239, 109897. [Google Scholar] [CrossRef] - Xing, T.; Carrica, P.; Stern, F. Computational towing tank procedures for single run curves of resistance and propulsion. J. Fluids Eng.
**2008**, 130, 101102. [Google Scholar] [CrossRef] - Renilson, M.R.; Tuite, A. Broaching-To: A Proposed Definition and Analysis Method. In Proceedings of the SNAME American Towing Tank Conference, Iowa City, Iowa, USA, October 1998; SNAME: Alexandria, VA, USA, 1998; p. D021S005R001. [Google Scholar]
- De Jong, P.; Van Walree, F.; Renilson, M. The broaching of a fast rescue craft in following seas. In Proceedings of the 12th International Conference on Fast Sea Transportation, Amsterdam, The Netherlands, 2–5 December 2013. [Google Scholar]
- Ivan, A.; Gasparotti, C.; Rusu, E. Influence of the interactions between waves and currents on the navigation at the entrance of the Danube Delta. J. Environ. Prot. Ecol.
**2012**, 13, 1673–1682. [Google Scholar]

Classification | Initial Conditions | Heading | Wave | Trajectory | Speed | Motion | Force | Torque |
---|---|---|---|---|---|---|---|---|

Features | $\mathit{Fr}$ | $\Psi $ | $\lambda $ | $x$ | ${V}_{\mathit{sw}}$ | ${\xi}_{3}$ | ${F}_{\mathit{Hx}{\u200a}^{\prime}}$ | ${M}_{\mathit{Hx}{\u200a}^{\prime}}$ |

${V}_{s0}$ | $\delta $ | $H$ | $y$ | ${V}_{w}$ | ${\xi}_{4}$ | ${F}_{\mathit{Hy}{\u200a}^{\prime}}$ | ${M}_{\mathit{Hy}{\u200a}^{\prime}}$ | |

${\xi}_{5}$ | ${F}_{\mathit{Hz}{\u200a}^{\prime}}$ | ${M}_{\mathit{Hz}{\u200a}^{\prime}}$ |

Layers | Initial Values of Related Parameters |
---|---|

LSTM_1 | units: 50, return_ sequences: True predict_ step: 50 |

Dropout_1 | rate: DROPOUT_RATE |

LSTM_2 | units: 50 |

Dense | units: TO BE DETERMINED |

Activation | Relu |

MinMaxScaler | feature_ range: (0, 1) |

Train–Test Split | train_ ratio: 80%, test_ ratio: 20% |

Time Step | time_ step: TO BE DETERMINED |

Input Length | MSE | RMSE | MAE |
---|---|---|---|

250 | 101.13 | 10.05 | 3.30 |

500 | 76.93 | 8.77 | 3.00 |

750 | 96.77 | 9.83 | 3.35 |

1000 | 75.78 | 8.70 | 2.94 |

1500 | 84.44 | 9.18 | 3.26 |

Dataset | ${\mathit{V}}_{\mathit{s}}$$/{\mathit{V}}_{\mathit{w}}$ | ${\mathit{F}}_{\mathit{n}}$ | $\mathit{\lambda}/\text{}\mathit{H}$ |
---|---|---|---|

Data1 | 0.91 | 0.38 | 5.45 |

Data2 | 0.96 | 0.40 | 2.34 |

Data3 | 1.08 | 0.45 | 2.24 |

Data4 | 0.92 | 0.45 | 2.33 |

Data5 | 1.08 | 0.45 | 3.27 |

Data6 | 0.91 | 0.38 | 3.27 |

Data7 | 1.32 | 0.55 | 5.45 |

Data8 | 1.44 | 0.60 | 2.34 |

Data9 | 1.13 | 0.35 | 2.34 |

Dataset Used for Training | MSE | RMSE | MAE |
---|---|---|---|

Data1 | 390.67 | 19.76 | 8.71 |

Data2 | 301.30 | 17.35 | 8.39 |

Data4 | 582.49 | 24.13 | 9.15 |

Data7 | 1390.53 | 37.28 | 13.36 |

Dataset Used for Training | MSE | RMSE | MAE |
---|---|---|---|

Data5 | 28.77 | 5.36 | 2.31 |

Data8 | 505.40 | 22.48 | 8.39 |

Dataset | ${\mathit{V}}_{\mathit{s}}$$/{\mathit{V}}_{\mathit{w}}$ | ${\mathit{F}}_{\mathit{n}}$ | $\mathit{\lambda}/\mathit{H}$ |
---|---|---|---|

Training Data | 0.84 | 0.35 | 5.45 |

Prediction Data | 1.08 | 0.45 | 2.24 |

Removed Parameter | MSE | RMSE | MAE |
---|---|---|---|

- | 430.65 | 20.75 | 9.26 |

Torque | 259.30 | 16.10 | 6.83 |

Force | 235.77 | 15.35 | 5.60 |

Motion | 465.37 | 21.57 | 9.56 |

Speed | 483.63 | 21.99 | 9.89 |

Trajectory | 474.67 | 21.78 | 10.13 |

$\mathsf{\delta}$ | 422.28 | 20.54 | 8.69 |

Dataset | ${\mathit{V}}_{\mathit{s}}$$/{\mathit{V}}_{\mathit{w}}$ | ${\mathit{F}}_{\mathit{n}}$ | $\mathit{\lambda}/\mathit{H}$ |
---|---|---|---|

TrainingD1 | 1.24 | 0.35 | 2.34 |

TrainingD2 | 0.84 | 0.35 | 5.45 |

TrainingD3 | 0.84 | 0.35 | 3.27 |

TrainingD4 | 0.84 | 0.35 | 2.34 |

TrainingD5 | 0.91 | 0.38 | 5.45 |

TrainingD6 | 1.18 | 0.45 | 2.33 |

Number of Training Sets | MSE | RMSE | MAE |
---|---|---|---|

1 | 2963.41 | 54.43 | 20.75 |

2 | 431.23 | 20.76 | 8.36 |

3 | 257.38 | 16.04 | 6.12 |

4 | 115.04 | 10.72 | 4.38 |

5 | 100.30 | 10.01 | 4.28 |

6 | 88.25 | 9.39 | 3.76 |

Dataset | ${\mathit{V}}_{\mathit{s}}$$/{\mathit{V}}_{\mathit{w}}$ | ${\mathit{F}}_{\mathit{n}}$ | $\mathit{\lambda}/\mathit{H}$ |
---|---|---|---|

TrainingD1 | 0.91 | 0.38 | 3.27 |

TrainingD2 | 1.08 | 0.45 | 3.27 |

TrainingD3 | 0.92 | 0.45 | 2.33 |

TrainingD4 | 0.87 | 0.45 | 2.34 |

TrainingD5 | 1.32 | 0.55 | 2.33 |

TrainingD6 | 1.20 | 0.50 | 3.27 |

Policy | MSE | RMSE | MAE |
---|---|---|---|

Traditional policy | 38.06 | 6.17 | 2.64 |

Optimized policy | 31.76 | 4.94 | 2.30 |

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |

© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Xu, J.; Gong, J.; Wang, L.; Li, Y.
Integrating k-means Clustering and LSTM for Enhanced Ship Heading Prediction in Oblique Stern Wave. *J. Mar. Sci. Eng.* **2023**, *11*, 2185.
https://doi.org/10.3390/jmse11112185

**AMA Style**

Xu J, Gong J, Wang L, Li Y.
Integrating k-means Clustering and LSTM for Enhanced Ship Heading Prediction in Oblique Stern Wave. *Journal of Marine Science and Engineering*. 2023; 11(11):2185.
https://doi.org/10.3390/jmse11112185

**Chicago/Turabian Style**

Xu, Jinya, Jiaye Gong, Luyao Wang, and Yunbo Li.
2023. "Integrating k-means Clustering and LSTM for Enhanced Ship Heading Prediction in Oblique Stern Wave" *Journal of Marine Science and Engineering* 11, no. 11: 2185.
https://doi.org/10.3390/jmse11112185