In order to prevent safety risks, control marine accidents and improve the overall safety of marine navigation, this study established a marine accident prediction model. The influences of management characteristics, environmental characteristics, personnel characteristics, ship characteristics, pilotage characteristics, wharf characteristics and other factors on the safety risk of maritime navigation are discussed. Based on the official data of Zhejiang Maritime Bureau, the extreme gradient boosting (XGBoost) algorithm was used to construct a maritime accident classification prediction model, and the explainable machine learning framework SHAP was used to analyze the causal factors of accident risk and the contribution of each feature to the occurrence of maritime accidents. The results show that the XGBoost algorithm can accurately predict the accident types of maritime accidents with an accuracy, precision and recall rate of 97.14%. The crew factor is an important factor affecting the safety risk of maritime navigation, whereas maintaining the equipment and facilities in good condition and improving the management level of shipping companies have positive effects on improving maritime safety. By explaining the correlation between maritime accident characteristics and maritime accidents, this study can provide scientific guidance for maritime management departments and ship companies regarding the control or management of maritime accident prevention.