A ship type classification prediction method and system based on K-means and XG-Boost
By combining K-means clustering and XG-Boost algorithm, the problems of multidimensional feature gap and scale effect in ship classification are solved, and accurate classification of global ships is achieved with a classification accuracy of 96.1%, avoiding overfitting and underfitting of the model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- COSCO SHIPPING TECH CO LTD
- Filing Date
- 2023-02-10
- Publication Date
- 2026-05-08
AI Technical Summary
Existing ship classification methods suffer from significant differences in multidimensional characteristics and a pronounced scaling effect, failing to accurately reflect key data such as fuel consumption during navigation.
The K-means clustering algorithm combined with the elbow method is used to select the number of categories, and the XG-Boost classification algorithm is used to build a prediction model to cluster and label ship data. The optimal classification prediction model is constructed through training set samples to achieve accurate classification of ships worldwide.
It achieves accurate classification of ships worldwide, with a classification accuracy rate of 96.1%, avoiding overfitting and underfitting of the model, and providing a scientific method for ship classification.
Smart Images

Figure CN116340797B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of ship classification technology, specifically to a ship type classification prediction method and system based on K-means and XG-Boost. Background Technology
[0002] In recent years, artificial intelligence and machine learning methods have gradually penetrated into the technological fields of various industries, greatly promoting technological iteration and innovation in traditional industries. Building algorithmic models to solve specific problems in various industries has become a hot research topic.
[0003] Ships, as an important means of maritime transportation, are diverse in type, numerous in number, and vary in size. Ship categories have different ship structures and performance characteristics according to different usage requirements.
[0004] Commonly used classification methods include classification by purpose, by power plant, by navigation status, and by hull material. However, classification methods based on single characteristics have drawbacks such as significant differences in multidimensional characteristics and a pronounced scale effect, failing to intuitively reflect key operational data of ships, such as fuel consumption during navigation. Summary of the Invention
[0005] To address the significant discrepancies in multidimensional features and the substantial scaling effect in current ship classification methods, this invention provides a ship type classification prediction method based on K-means and XG-Boost. Based on ship data, it employs a K-means clustering algorithm combined with the elbow method to select a certain number of categories and labels all clustered ships by ship type. Then, an XG-Boost classification algorithm is used to build a classification prediction model, which predicts the ship type of all ships globally. This method accurately classifies all ships worldwide while maintaining accuracy and avoiding overfitting and underfitting. This invention also relates to a ship type classification prediction system based on K-means and XG-Boost.
[0006] The technical solution of the present invention is as follows:
[0007] A ship type classification prediction method based on K-means and XG-Boost, characterized by the following steps:
[0008] Data acquisition and preprocessing steps: Acquire ship data and preprocess the ship data;
[0009] Ship type classification and labeling steps: The K-means clustering algorithm is used to cluster each type of data in the preprocessed ship data to obtain multiple clusters. The sum of squared errors of all data in each cluster is calculated. Then, the sum of squared errors of all clusters is summed to calculate the total sum of squared errors of all clusters. The number of categories for each type of data is calculated based on the total sum of squared errors. Then, the elbow method is used to select a certain number of categories. Ship type labeling is performed on all clustered ships according to the selected number of categories.
[0010] Ship type classification prediction steps: Use the labeled ships as training set samples, use the XG-Boost classification algorithm to train multiple classification prediction models on the training set samples, validate the multiple trained classification prediction models, obtain the optimal classification prediction model, predict the ship type of all ships in the world based on the optimal classification prediction model and label them.
[0011] Preferably, the verification of the classification prediction model in the ship type classification prediction step includes:
[0012] The XG-Boost classification algorithm learns multiple weak estimators sequentially, evaluates the error of each trained classification prediction model, resamples the predicted ship type data, focuses on samples with incorrect predictions, and reconstructs some new weak estimators. It then evaluates the prediction performance of the new weak estimators on the original incorrect samples, repeats the above process iteratively, and summarizes all weak estimators to obtain the optimal classification prediction model.
[0013] Preferably, in the data acquisition and preprocessing steps, the ship data includes the rated power of the main engine, operating speed, deadweight tonnage, three-class ship type, overall length, depth, draft, displacement, and rated main engine speed.
[0014] Preferably, in the data acquisition and preprocessing steps, the preprocessing includes deleting abnormal and duplicate data, filling in missing data, removing noise, and standardizing data.
[0015] Preferably, the draft and displacement data in the ship data are obtained internally using navigation mark data and externally using HIS data.
[0016] A ship type classification and prediction system based on K-means and XG-Boost is characterized by comprising a data acquisition and preprocessing module, a ship type classification and labeling module, and a ship type classification prediction module connected in sequence.
[0017] The data acquisition and preprocessing module acquires ship data and preprocesses the ship data.
[0018] The ship type classification and labeling module uses the K-means clustering algorithm to cluster each type of data in the preprocessed ship data, obtaining multiple clusters, and calculating the sum of squared errors of all data in each cluster. Then, the sum of squared errors of all clusters is summed to calculate the total sum of squared errors of all clusters. Based on the total sum of squared errors, the number of categories for each type of data is calculated. Then, the elbow method is used to select a certain number of categories, and ship type labeling is performed on all clustered ships according to the selected number of categories.
[0019] The ship type classification prediction module uses ships with labeled ship types as training set samples, and uses the XG-Boost classification algorithm to train multiple classification prediction models on the training set samples. The multiple trained classification prediction models are then validated to obtain the optimal classification prediction model. Based on the optimal classification prediction model, the ship types of all ships in the world are predicted and labeled.
[0020] Preferably, in the ship type classification prediction module, the verification of the classification prediction model includes:
[0021] The XG-Boost classification algorithm learns multiple weak estimators sequentially, evaluates the error of each trained classification prediction model, resamples the predicted ship type data, focuses on samples with incorrect predictions, and reconstructs some new weak estimators. It then evaluates the prediction performance of the new weak estimators on the original incorrect samples, repeats the above process iteratively, and summarizes all weak estimators to obtain the optimal classification prediction model.
[0022] Preferably, the ship data includes the rated power of the main engine, operating speed, deadweight tonnage, three-class ship type, overall length, depth, draft, displacement, and rated main engine speed.
[0023] Preferably, the preprocessing includes deleting abnormal and duplicate data, filling in missing data, removing noise, and standardizing data.
[0024] Preferably, the draft and displacement data in the ship data are obtained internally using navigation mark data and externally using HIS data.
[0025] The beneficial effects of this invention are as follows:
[0026] This invention provides a ship type classification and prediction method based on K-means and XG-Boost. First, based on preprocessed ship data, the K-means clustering algorithm is used to cluster each type of data in the preprocessed ship data, obtaining multiple clusters. The sum of squared errors of all data within each cluster is calculated, and then the sums of squared errors of all clusters are summed to calculate the total sum of squared errors of all clusters. Based on the total sum of squared errors, the number of classifications for each type of data is calculated. Then, the elbow method is used to select a certain number of classifications. Based on the selected number of classifications, all clustered ships are labeled with their ship types, enabling accurate classification of all ship types. Next, the labeled ships are used as training set samples. The XG-Boost classification algorithm (also known as the extreme gradient boosting algorithm, a supervised learning classification algorithm) is used to train multiple classification prediction models (a supervised learning classification model). These trained classification prediction models are validated to obtain the optimal classification prediction model. Finally, the ship types of all ships globally are predicted based on the optimal classification prediction model. This invention is essentially a ship classification technology based on machine learning algorithms to mine multidimensional features of ships. Using ship data as support, it mines multidimensional features of ships, constructs a ship feature matrix and category labels through clustering algorithms, and builds a classification prediction model using the extreme gradient boosting algorithm, achieving accurate classification of numerous ships. In the verification and evaluation of the model's effectiveness, the ship type classification accuracy reached 96.1%, ensuring accuracy while avoiding overfitting and underfitting. The construction of the ship feature matrix through clustering algorithms specifically includes: first, acquiring and preprocessing ship data, then organizing the preprocessed ship data into a structured dataset (as shown in Table 2); then applying the K-means clustering algorithm to each column (i.e., a single feature dimension) of this structured dataset, such as clustering the "main engine rated power" column separately, thereby constructing the ship feature matrix. The ship feature matrix refers to the two-dimensional data structure shown in Table 2, where: each row corresponds to a ship sample (e.g., Xinliulinhai, Yuanpinghai, etc.); each column corresponds to a feature dimension (main engine rated power, operating speed, etc.); and the matrix elements are preprocessed feature values.
[0027] This invention also relates to a ship type classification and prediction system based on K-means and XG-Boost. This system corresponds to the aforementioned ship type classification and prediction method based on K-means and XG-Boost. It can be understood as a system that implements the aforementioned ship type classification and prediction method based on K-means and XG-Boost. It includes a data acquisition and preprocessing module, a ship type classification and labeling module, and a ship type classification prediction module connected in sequence. Each module works in concert. Based on ship data, it uses the K-means clustering algorithm combined with the elbow method to select a certain number of categories and labels all clustered ships by ship type. Then, it uses the XG-Boost classification algorithm to establish a classification prediction model. Based on the classification prediction model, it predicts the ship type of all ships in the world. It can accurately classify all ships in the world and avoids overfitting and underfitting of the model while ensuring accuracy. Attached Figure Description
[0028] Figure 1 This is a flowchart of the ship type classification prediction method based on K-means and XG-Boost of the present invention. Detailed Implementation
[0029] The present invention will now be described with reference to the accompanying drawings.
[0030] This invention relates to a ship type classification prediction method based on K-means and XG-Boost, the flowchart of which is shown below. Figure 1 As shown, the steps are as follows:
[0031] Data Acquisition and Preprocessing Steps: Acquire ship data and preprocess it to remove abnormal and duplicate data, fill in missing data, remove noise, and standardize the data. Then, anonymize the preprocessed ship data. For example, the database of a company (or a group, institution) can be used as data support to acquire the company's own ship data. Preferably, the ship data includes nine ship attributes: rated main engine power, operating speed, deadweight tonnage, three-class ship type, overall length, depth, draft, displacement, and rated main engine speed. More preferably, the draft and displacement data are acquired internally using navigation mark data and externally using HIS data. The ship data is shown in Table 1.
[0032] Table 1
[0033]
[0034] Ship type classification and labeling steps: The K-means clustering algorithm is used to cluster each type of data in the preprocessed ship data to obtain multiple clusters. The sum of squared errors of all data in each cluster is calculated. Then, the sum of squared errors of all clusters is summed to calculate the total sum of squared errors of all clusters. The number of categories for each type of data is calculated based on the total sum of squared errors. Then, the elbow method is used to select a certain number of categories. Ship type labeling is performed on all clustered ships according to the selected number of categories.
[0035] Specifically, the K-means clustering algorithm is first used to cluster each type of data in the preprocessed ship data. Specifically, data samples such as main engine rated power, operating speed, deadweight tonnage, three-class ship type, overall length, depth, draft, displacement, and rated main engine speed are clustered separately. After clustering, each type of data will have multiple clusters. The sum of squared errors of all data within each cluster is then calculated. Finally, the sums of squared errors of all clusters are summed to calculate the total sum of squared errors (SSE). The total sum of squared errors (SSE) is calculated using the following formula:
[0036]
[0037] In the above formula, C i It is the i-th cluster, and p is C i The sample points in the middle, m i It is C i The center of mass (C) i SSE is the clustering error of all samples, representing the quality of the clustering.
[0038] Then, the number of categories for each data type is calculated based on the total sum of squared errors. Next, the elbow method is used to select a certain number of categories, i.e., iterating through the categories to find the number of categories calculated with the minimum sum of squared errors. Based on the selected number of categories, all ships that have been clustered are labeled by their ship type. The ship type labeling is done using tagging.
[0039] Specifically, the elbow method for selecting the number of clusters is as follows: for a cluster, the lower its sum of squared errors, the more closely the members within the cluster are. For data with a certain degree of discriminability, the sum of squared errors will be greatly improved when a certain critical point is reached, and then slowly decrease. This critical point can be considered as the point with better clustering performance, which is the most suitable number of clusters to choose.
[0040] The ship type labeling for ships using the K-means clustering algorithm is shown in Table 2.
[0041] Table 2
[0042]
[0043] Ship type classification prediction steps: Use ships with labeled ship types as training set samples, use the XG-Boost classification algorithm to train multiple classification prediction models (also known as ship type classification prediction models) on the training set samples, and verify multiple trained classification prediction models to obtain the optimal classification prediction model. Based on the optimal classification prediction model, predict the ship type of all ships in the world and label them.
[0044] Specifically, the labeled ships are first used as training set samples. The XG-Boost classification algorithm (also known as the extreme gradient boosting algorithm) is used to train multiple classification prediction models on the training set samples. These models are then validated. The XG-Boost algorithm sequentially learns multiple weak estimators while evaluating the error of each trained model. The predicted ship type data is then resampled, focusing on incorrectly predicted samples, and some new weak estimators are reconstructed. The prediction performance of the new weak estimators on the original incorrect samples is evaluated again. This process is repeated iteratively until all weak estimators are combined to obtain the optimal classification prediction model. Finally, the ship types of all ships globally are predicted and labeled based on the optimal model, resulting in category labels for all ships worldwide. The classification of global ships by ship type using XG-Boost is shown in Table 3.
[0045] Table 3
[0046]
[0047] This invention provides a ship classification technology based on K-means clustering and XG-Boost (Extreme Gradient Boosting) algorithms to mine multi-dimensional features of ships. For example, using data from COSCO Shipping Group's own ships, multi-dimensional features of ships are mined, a ship feature matrix and category labels are constructed through clustering algorithms, and a ship type classification prediction model is built using the Extreme Gradient Boosting algorithm. This achieves accurate classification of nearly 800 ships in the group. When evaluating the model's performance on the test set, the classification accuracy reached 96.1%, ensuring accuracy while avoiding overfitting and underfitting. Using key features such as the rated maximum power of the main engine and the ship's service speed as inputs, the classification prediction model is used to predict global ship category labels, so as to achieve goals such as real-time prediction of global ship fuel consumption in the future.
[0048] This invention also relates to a ship type classification and prediction system based on K-means and XG-Boost. This system corresponds to the aforementioned ship type classification and prediction method based on K-means and XG-Boost, and can be understood as a system that implements the above method. The system includes, in sequence, a data acquisition and preprocessing module, a ship type classification and labeling module, and a ship type classification prediction module. Specifically,
[0049] The data acquisition module and the data acquisition and preprocessing module acquire ship data and preprocess the ship data.
[0050] The ship type classification and labeling module uses the K-means clustering algorithm to cluster each type of data in the preprocessed ship data, obtaining multiple clusters, and calculating the sum of squared errors of all data in each cluster. Then, the sum of squared errors of all clusters is summed to calculate the total sum of squared errors of all clusters. Based on the total sum of squared errors, the number of categories for each type of data is calculated. Then, the elbow method is used to select a certain number of categories, and ship type labeling is performed on all clustered ships according to the selected number of categories.
[0051] The ship type classification prediction module uses ships with labeled ship types as training set samples, and uses the XG-Boost classification algorithm to train multiple classification prediction models on the training set samples. The multiple trained classification prediction models are then validated to obtain the optimal classification prediction model. Based on the optimal classification prediction model, the ship types of all ships in the world are predicted and labeled.
[0052] Preferably, in the ship type classification prediction module, the verification of the classification prediction model includes: the XG-Boost classification algorithm sequentially learns multiple weak estimators, evaluates the error of each trained classification prediction model, resamples the predicted ship type data, focuses on samples with prediction errors, reconstructs some new weak estimators, evaluates the prediction effect of the new weak estimators on the original incorrect samples again, repeats the above process iteratively, and summarizes all weak estimators to obtain the optimal classification prediction model.
[0053] Preferably, the ship data includes the rated power of the main engine, operating speed, deadweight tonnage, three-class ship type, overall length, depth, draft, displacement, and rated main engine speed.
[0054] Preferably, preprocessing includes removing outlier and duplicate data, filling in missing data, and removing noise and standardizing data.
[0055] Preferably, the draft and displacement data in the ship data are obtained internally using navigation mark data and externally using HIS data.
[0056] This invention provides an objective and scientific ship type classification and prediction method and system based on K-means and XG-Boost. It involves a ship classification technology that mines multi-dimensional ship features using K-means and XG-Boost. By combining these multi-dimensional features, the K-Means supervised learning classification algorithm is first used to select nine ship attributes: main engine rated power, operating speed, deadweight tonnage, three-class ship type, overall length, depth, draft, displacement, and rated main engine speed. The number of classifications is determined by calculating the sum of squared errors within each cluster after classification. This selected number of classifications is then used to label 794 ships within the COSCO Group. To address the issue of incomplete data for the nine ship attributes within and outside the group, XG-Boost is used to train the labeled ships within the group. This XG-Boost is then used to accurately classify over 50,000 ships both within and outside the group.
[0057] It should be noted that the specific embodiments described above enable those skilled in the art to more fully understand the present invention, but do not limit the present invention in any way. Therefore, although the present invention has been described in detail with reference to the accompanying drawings and embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the present invention. In short, all technical solutions and improvements that do not depart from the spirit and scope of the present invention should be covered within the protection scope of the present invention patent.
Claims
1. A ship type classification prediction method based on K-means and XG-Boost, characterized in that, Includes the following steps: Data acquisition and preprocessing steps: Acquire ship data and preprocess the ship data; Ship type classification and labeling steps: The K-means clustering algorithm is used to cluster each type of data in the preprocessed ship data to obtain multiple clusters. The sum of squared errors of all data in each cluster is calculated. Then, the sums of squared errors of all clusters are summed to calculate the total sum of squared errors of all clusters. The number of categories for each type of data is calculated based on the total sum of squared errors. Ship type labels are then applied to all clustered ships based on the number of categories for each type of data. Each type of data in the ship data includes rated main engine power, operating speed, deadweight tonnage, three ship types, overall length, depth, draft, displacement, and rated main engine speed. Ship type classification prediction steps: Use the labeled ships as training set samples, use the XG-Boost classification algorithm to train multiple classification prediction models on the training set samples, validate the multiple trained classification prediction models, obtain the optimal classification prediction model, predict the ship type of all ships in the world based on the optimal classification prediction model and label them.
2. The ship type classification prediction method based on K-means and XG-Boost according to claim 1, characterized in that, The ship type classification prediction step includes validating the classification prediction model, which includes: The XG-Boost classification algorithm learns multiple weak estimators sequentially, evaluates the error of each trained classification prediction model, resamples the predicted ship type data, focuses on samples with incorrect predictions, and reconstructs some new weak estimators. It then evaluates the prediction performance of the new weak estimators on the original incorrect samples, repeats the above process iteratively, and summarizes all weak estimators to obtain the optimal classification prediction model.
3. The ship type classification prediction method based on K-means and XG-Boost according to claim 1, characterized in that, The data acquisition and preprocessing steps include preprocessing such as deleting abnormal and duplicate data, filling in missing data, removing noise, and standardizing data.
4. The ship type classification prediction method based on K-means and XG-Boost according to claim 1, characterized in that, The draft and displacement data in the vessel data are obtained internally using navigation mark data and externally using HIS data.
5. A ship type classification and prediction system based on K-means and XG-Boost, characterized in that, It includes a data acquisition and preprocessing module, a ship type classification and labeling module, and a ship type classification prediction module, which are connected in sequence. The data acquisition and preprocessing module acquires ship data and preprocesses the ship data. The ship type classification and labeling module uses the K-means clustering algorithm to cluster each type of data in the preprocessed ship data, obtaining multiple clusters. It calculates the sum of squared errors for all data within each cluster, then sums the sums of squared errors for all clusters to calculate the total sum of squared errors for all clusters. Based on the total sum of squared errors, it calculates the number of categories for each type of data, and labels all clustered ships according to the number of categories for each type of data. Each type of data in the ship data includes rated main engine power, operating speed, deadweight tonnage, three ship types, overall length, depth, draft, displacement, and rated main engine speed. The ship type classification prediction module uses ships with labeled ship types as training set samples, and uses the XG-Boost classification algorithm to train multiple classification prediction models on the training set samples. The multiple trained classification prediction models are then validated to obtain the optimal classification prediction model. Based on the optimal classification prediction model, the ship types of all ships in the world are predicted and labeled.
6. The ship type classification and prediction system based on K-means and XG-Boost according to claim 5, characterized in that, The ship type classification prediction module includes the following verification steps for the classification prediction model: The XG-Boost classification algorithm learns multiple weak estimators sequentially, evaluates the error of each trained classification prediction model, resamples the predicted ship type data, focuses on samples with incorrect predictions, and reconstructs some new weak estimators. It then evaluates the prediction performance of the new weak estimators on the original incorrect samples, repeats the above process iteratively, and summarizes all weak estimators to obtain the optimal classification prediction model.
7. The ship type classification and prediction system based on K-means and XG-Boost according to claim 5, characterized in that, The preprocessing includes removing abnormal and duplicate data, filling in missing data, removing noise, and standardizing the data.
8. The ship type classification and prediction system based on K-means and XG-Boost according to claim 5, characterized in that, The draft and displacement data in the vessel data are obtained internally using navigation mark data and externally using HIS data.