Ship anomaly detection method and device based on TCN trajectory prediction

The TCN-based ship anomaly detection method addresses regional adaptability and accuracy issues by predicting ship positions and scoring anomalies, enhancing detection precision and providing detailed reports for improved maritime safety.

CN120316696AInactive Publication Date: 2025-07-15THE 54TH RESEARCH INSTITUTE OF CHINA ELECTRONICS TECHNOLOGY GROUP CORPORATION

Patent Information

Application Number
CN202510811590.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-18
Publication Date
2025-07-15
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art has problems in the detection area of ship voyage abnormality detection, the inability to detect the real abnormal behavior of the ship, and the incomplete detection information, which is difficult to apply in different areas and cannot provide detailed abnormal information.

Method used

The method based on TCN trajectory prediction is adopted to predict the ship's position through a time convolution network, calculate the position error, identify the abnormal points, and generate detailed abnormality detection reports based on the abnormal points, including the abnormality score and level of the abnormal track segment.

Benefits of technology

It improves the accuracy and information integrity of ship abnormal behavior detection, can be applied in different areas, and provides detailed abnormal information such as time, place and event key data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120316696A_ABST
    Figure CN120316696A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of behavior prediction, and particularly relates to a ship anomaly detection method and device based on TCN trajectory prediction. The method comprises the following steps: S1, acquiring AIS data given by a ship automatic identification system in a set time period before the current moment; s2, predicting the position of the ship at the next moment based on a pre-trained time convolutional network; s3, determining an error between the actual position and the predicted position of the ship at the next moment; s4, when the error exceeds a threshold value, determining that the position is an abnormal point; s5, continuously appearing abnormal points serve as abnormal track segments, the time length of the abnormal track segments serves as a weight calculation factor, and the abnormal scores of the abnormal track segments are calculated; and S6, determining the abnormal level of the abnormal track segment according to the abnormal score and the plurality of abnormal degree intervals. According to the invention, the detection precision of ship abnormal behaviors is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of behavior prediction, and particularly relates to a method and device for ship anomaly detection based on TCN trajectory prediction. Background Art

[0002] The anomaly detection of ship voyages is a core element of the marine safety strategy. Timely detection of whether a ship has abnormal behavior can avoid many risks and provide guarantee for maritime traffic safety. A voyage refers to the complete navigation process of a ship from a specific port to another port. The scope of voyage anomaly detection includes all navigation trajectories of a ship or a maritime target from the departure port to the destination port. By using the trajectory information in AIS (Automatic Identification System) data, significant behavioral characteristic rules such as the ship's sailing route, speed, and port call situation can be analyzed, and potential factors such as deviation from the route and anchoring that affect other ships can be judged.

[0003] The core idea of anomaly category detection is to use machine learning algorithms for classification, such as the K-Nearest Neighbor (KNN) algorithm, the Support Vector Machines (SVM) algorithm, etc. The existing anomaly category detection methods used are restricted by samples. Since there are many types of anomalies in ship navigation trajectories, it is difficult to traverse all types and extract anomaly samples. If the anomaly tracks covered by the anomaly samples are not comprehensive, it will lead to deviation in the detection results.

[0004] Existing studies mainly face the following difficulties when detecting voyage anomalies of maritime targets: (1) Limitation of the detection area: Most existing methods are for anomaly detection of ships within a selected area. Due to the differences in hydrological conditions and ship route habits in different areas, the detection and training models in one area are not applicable to other areas. Therefore, it is impossible to perform anomaly detection at any time and place, and it does not support long-distance ocean detection for ships with long routes.

[0005] (2) Failure to detect the true anomalies of ships: Existing methods mainly find similarities from the navigation rules of most ships and pick out a few ships that do not conform to this overall rule, and judge these few ungrouped ships as anomalies. However, the navigation anomaly of a ship should be that the ship deviates from its own navigation rule. Therefore, existing methods do not strictly detect the abnormal behavior of ships.

[0006] (3) Incomplete abnormal information detected: The purpose of anomaly detection is to monitor and report abnormal behavior, detect anomalies in a timely manner and solve problems according to specific circumstances, so as to avoid potential risks for subsequent navigation. However, existing methods can only detect whether a ship has abnormal behavior, without further providing detailed abnormal information, such as the time, location and event of the anomaly. Summary of the invention

[0007] In order to solve one of the above problems, the present invention provides a ship anomaly detection method and device based on TCN trajectory prediction, which captures the long-term dependencies and short-term changes in the time series through the TCN prediction algorithm, and finds the abnormal behavior pattern and position change of the ship, thereby detecting the abnormal behavior of the ship.

[0008] The technical solution adopted by the present invention is: The first aspect of the present invention provides a ship anomaly detection method based on TCN trajectory prediction, which mainly includes: S1, obtaining the AIS data given by the ship automatic identification system for a set time period before the current time; S2, based on the AIS data obtained in S1, uses the pre-trained temporal convolutional network to predict the position of the ship at the next moment; S3, determining the error between the actual position of the ship at the next moment and the predicted position; S4. When the error exceeds a threshold, the position is determined to be an abnormal point; S5, taking the continuously occurring abnormal points as abnormal trajectory segments, taking the time length of the abnormal trajectory segments as a weight calculation factor, and calculating the abnormal score of the abnormal trajectory segments; S6. Determine the abnormality level of the abnormal trajectory segment according to the abnormality score and multiple abnormality degree intervals.

[0009] Preferably, S1 further comprises: S11, mapping the AIS data given by the ship automatic identification system within a set time period to uniform time points; S12, eliminating abnormal AIS data values; S13, using local time series information to fill missing values in the AIS data after outliers are removed; S14. Perform feature normalization on the AIS data after missing value filling.

[0010] Preferably, S13 further comprises: For the data to be filled whose missing time is less than the first preset ratio of the set time period length, linear interpolation is used for filling; For the data to be filled with the missing time ranging from the first preset ratio to the second preset ratio of the set time period length, use the kinetic prediction model established from historical data for filling; For the data to be filled with the missing time greater than the second preset ratio of the set time period length, mark the set time period as an invalid time period.

[0011] Preferably, in S5, further including the continuously occurring abnormal points as an abnormal trajectory segment: Set the time threshold for the abnormal trajectory segment. When the span of the continuously occurring abnormal points exceeds the time threshold, truncate the abnormal trajectory segment and restart the timing.

[0012] Preferably, in S5, calculate the abnormal score of the abnormal trajectory segment through the following formula: ; where Score segment is the abnormal score, MSE i is the error at the i-th time point, t start and t end are the start and end time points of the abnormal trajectory segment, n is the number of time points of the abnormal trajectory segment, W duration is the time weight, and τ is the time threshold.

[0013] The second aspect of the present invention provides a ship anomaly detection device based on TCN trajectory prediction, mainly including: An AIS data acquisition module for acquiring AIS data given by the Automatic Identification System of ships for a set time period before the current moment; A position prediction module for predicting the position of the ship at the next moment based on a pre-trained temporal convolutional network; An error calculation module for determining the error between the actual position and the predicted position of the ship at the next moment; An abnormal point determination module for determining the position as an abnormal point when the error exceeds the threshold; An abnormal score calculation module for the abnormal trajectory segment, which takes the continuously occurring abnormal points as an abnormal trajectory segment and calculates the abnormal score of the abnormal trajectory segment with the time length of the abnormal trajectory segment as the weight calculation factor; An abnormal level determination module for determining the abnormal level of the abnormal trajectory segment according to the abnormal score and multiple abnormal degree intervals.

[0014] Preferably, the AIS data acquisition module includes: A uniform sampling unit for mapping the AIS data given by the Automatic Identification System of ships for the set time period to uniform time points; An abnormal value rejection unit for rejecting abnormal AIS data values; A missing value filling unit for filling missing values in the AIS data with outliers removed by using local temporal information; A normalization unit for performing feature normalization on the AIS data after missing value filling.

[0015] Preferably, the missing value filling unit includes: A linear interpolation filling subunit for filling the data to be filled with a missing time less than 10% of the set time period length by using linear interpolation; A kinetic prediction model filling subunit for filling the data to be filled with a missing time between 10% and 30% of the set time period length by using a kinetic prediction model established from historical data; An invalid marking subunit for marking the set time period as an invalid time period for the data to be filled with a missing time greater than 30% of the set time period length.

[0016] Preferably, the abnormal score calculation module for the abnormal trajectory segment includes: An abnormal trajectory segment truncation unit for setting a time threshold for the abnormal trajectory segment, and when the span of consecutive abnormal points exceeds the time threshold, truncating the abnormal trajectory segment and restarting the timing.

[0017] Preferably, in the abnormal score calculation module for the abnormal trajectory segment, the abnormal score of the abnormal trajectory segment is calculated by the following formula: ; where Score segment is the abnormal score, MSE i is the error at the i-th time point, t start and t end are the start and end time points of the abnormal trajectory segment, n is the number of time points of the abnormal trajectory segment, W duration is the time weight, and τ is the time threshold.

[0018] The present invention improves the detection accuracy of ship abnormal behaviors compared with the prior art. Description of the Drawings

[0019] Figure 1 is a flowchart of a preferred embodiment of the ship abnormal detection method based on TCN trajectory prediction of the present invention.

[0020] Figure 2 is a schematic diagram of the input and output of a sliding time window. Detailed Embodiment

[0021] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions in the embodiments of the present invention will be described in more detail below with reference to the accompanying drawings in the embodiments of the present invention. In the drawings, the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The described embodiments are some, but not all, of the embodiments of the present invention. The embodiments described below by referring to the drawings are exemplary and are intended to explain the present invention and should not be construed as limiting the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts fall within the scope of protection of the present invention. The embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0022] The first aspect of the present invention provides a method for detecting ship anomalies based on TCN trajectory prediction, as Figure 1 shown, mainly including: S1. Obtain AIS data given by the Automatic Identification System of ships for a set time period before the current moment; S2. Based on the AIS data obtained in S1, use a pre-trained temporal convolutional network to predict the position of the ship at the next moment; S3. Determine the error between the actual position and the predicted position of the ship at the next moment; S4. When the error exceeds the threshold, determine that this position is an abnormal point; S5. Take the continuously occurring abnormal points as an abnormal trajectory segment, and use the time length of the abnormal trajectory segment as a weight calculation factor to calculate the abnormal score of the abnormal trajectory segment; S6. Determine the abnormal level of the abnormal trajectory segment according to the abnormal score and multiple abnormal degree intervals.

[0023] The present invention first obtains AIS data of a sliding time window in S1, and then in S2, predicts the position of the ship at the next moment through a trained temporal convolutional network. In S3 - S6, when the actual position of the ship deviates from the predicted position, the position of the ship is marked, and multiple marked points form an abnormal trajectory segment. Finally, the behavior level of the ship is judged according to the abnormal score of the abnormal trajectory segment.

[0024] First, the AIS data is described. AIS is a ship traffic management and navigation safety guarantee system that automatically broadcasts and receives ship information through VHF (Very High Frequency) radio waves. AIS data is divided into static information (such as ship name, MMSI number, IMO number, ship type, ship length, ship width, etc.) and dynamic information (such as ship position, course, speed, navigation status, destination port, etc.). This system can monitor ship dynamics in real time and provide important data support for maritime traffic safety, navigation supervision, and emergency rescue. Among them, MMSI (Maritime Mobile Service Identity) is a unique identification code composed of 9 digits, which is used to identify ships, coastal radio stations, and other maritime facilities. The first three digits of MMSI are the maritime mobile service identification code (MID), representing the country of ship registration, and the last six digits are the ship serial number. This coding plays a key role in the AIS communication, distress alarm, and daily identification of ships. The IMO number (IMO Number, International Maritime Organization number) is a 7-digit permanent ship identification number assigned by the International Maritime Organization (IMO). Once assigned to a ship, this number will accompany the entire service life of the ship. Even if the ship changes its name, flag state, or owner, the IMO number remains unchanged. This permanent identification is of great significance for aspects such as ship safety management, maritime investigation, and insurance claims settlement.

[0025] The present invention uses at least the position information, speed information, and time information in the AIS data. And a sliding time window is used for data collection, so that these time-series data form the input of the time convolutional network in S2.

[0026] The data input and output under the sliding time window are as Figure 2 shown. According to the characteristics of the data and the modeling requirements, the length n of the sliding time window is determined, that is, each window contains n consecutive trajectory points. At time t, the first n - 1 trajectory points and the current trajectory point are extracted to form a subsequence, that is, [T t-n+1 , T t-n+2 ,..., T t . As time goes by, the window slides continuously, generating new subsequences. The sliding time window ensures that each subsequence contains consecutive trajectory points, retains the time-series characteristics of the data, and ensures that the model can capture the dynamic changes of the trajectory.

[0027] In the specific application of the present invention, first, the basic parameters of the sliding time window are determined: the window length n (such as 30 time points) and the sliding step s (such as 1 time point).

[0028] Next, the temporal convolutional network is described. TCN (Temporal Convolutional Network) is a deep learning architecture specifically designed to process time series data. TCN combines the characteristics of causal convolution (ensuring that the model does not use future information) and dilated convolution (expanding the receptive field to capture long-term dependencies), and is suitable for tasks such as time series prediction and anomaly detection. Compared with traditional recurrent neural networks (RNNs), TCN has advantages such as high parallel computing efficiency and more stable gradient propagation.

[0029] In some alternative embodiments, S1 further includes: S11. Map the AIS data given by the Automatic Identification System within a set time period to uniform time points; S12. Eliminate abnormal AIS data values; S13. Use local temporal information to fill in the missing values of the AIS data after eliminating the abnormal values; S14. Perform feature normalization on the AIS data after filling in the missing values.

[0030] The data obtained in S1 of the present invention is also the training data of the temporal convolutional network used in S2. Therefore, in the above embodiments, the steps for preprocessing the AIS data are equally applicable to the preprocessing of training samples.

[0031] Due to the influence of acquisition devices, transmission processes, and environmental factors, AIS data often has problems such as uneven sampling, data missing, and inconsistent formats. To ensure the accuracy of subsequent analysis, the data preprocessing method based on a sliding time window proposed by the present invention can, in addition to being used before the temporal convolutional network, also analyze and process the data within the sliding time window to achieve unified data format, anomaly detection, and missing value repair. That is, the process for normalizing AIS data in this embodiment. This embodiment integrates multi-dimensional information such as longitude, latitude, speed, and heading, and copes with noise and missing values in the data acquisition process by cleaning and complementing the data.

[0032] In S11, for each sliding time window, first map the original irregular sampled data to uniform time points. The specific method is to set time points with a fixed interval (such as 1 minute) within the window, and obtain information such as position and speed at these time points through linear interpolation. This can solve the problem of inconsistent sampling frequencies for different ships and different time periods.

[0033] In S12, within the sliding time window range, outlier detection is performed using the temporal correlation of the data. For example, by calculating the speed changes between position points within the window, abnormal jumps that do not conform to physical constraints can be identified. For the detected outliers, they are corrected or removed in combination with the data points before and after within the window.

[0034] In S13, the sliding time window mechanism enables the present invention to fully utilize local temporal information for missing value filling. In some alternative embodiments, S13 further includes: For the data to be filled with a missing time less than the first preset ratio (set to 10% in this embodiment) of the set time period length, linear interpolation is used for filling; For the data to be filled with a missing time between the first preset ratio and the second preset ratio (set to 10% - 30% in this embodiment) of the set time period length, a kinetic prediction model established from historical data is used for filling; A detailed description of the kinetic prediction model is as follows: This kinetic prediction model is a missing data prediction method developed based on the ship kinematic equation and the Kalman filter algorithm, aiming to predict the position information of the ship during the missing time period using the ship's historical navigation data; In terms of model establishment, the ship kinematic state equation is adopted , where represents the state vector of the ship at time, including the longitude coordinate , the latitude coordinate , the speed and the course angle ; is the state transition matrix; is the process noise, which follows a multivariate normal distribution. The state transition matrix describes how these parameters evolve over time, especially considering the influence of the course on the position change, and its matrix form is: ; where represents the interval between two adjacent time points; The Kalman filter algorithm is the core of this model, and data filling is achieved through an iterative process of prediction - update. In the prediction stage, the algorithm uses the formula to estimate the position and speed of the ship at the next moment based on the state at the previous moment. In this formula, represents the predicted value of the state at time (based on the information at time ), is the optimal state estimate at time , is the above state transition matrix. When new AIS data arrives, it enters the update phase, and through the formula corrects the predicted value, where is the final state estimate at time , is the actual observation value at time (such as the position data provided by AIS), The Kalman gain determines the degree of trust in the new observation data, and the observation matrix maps the state space to the observation space; The training process of the model first needs to preprocess and classify the historical AIS data. Group the data according to the MMSI number and voyage of the ship to ensure that each model is optimized for the specific navigation mode of a specific ship. Subsequently, the maximum likelihood estimation method is used to determine the model parameters, that is, to solve , and find the parameter combination that can maximize the conditional probability of the historical observation data. The specific meaning of this maximum likelihood estimation formula is: represents the set of optimal model parameters to be estimated by us; represents all possible combinations of parameter values; represents the entire historical observation data sequence ; is the likelihood function, which represents the probability of observing the data sequence under the given parameter ; is the log-likelihood function, and using the logarithmic form can simplify the calculation and improve numerical stability; The operation is to find the parameter that makes the log-likelihood function reach the maximum value; Use the known continuous trajectory segments in the historical data to verify the model performance, and select the parameter configuration with the highest prediction accuracy by comparing the error between the predicted trajectory and the actual trajectory.

[0035] For the data to be filled with the missing time greater than the second preset ratio (set to 30% in this embodiment) of the set time period length, mark this set time period as an invalid time period.

[0036] Finally, in S14, based on the characteristics of the ship type and historical ship navigation data, the overall data is normalized. This step is used to ensure the comparability of data in different dimensions. For different feature dimensions, corresponding normalization methods are adopted: longitude and latitude are mapped to the interval [-1, 1] through min-max normalization; speed is normalized to the interval [0, 1] based on the maximum speed of this type of ship; the heading is normalized to the interval [-1, 1] for the 360-degree angle value, the ship status is represented by one-hot encoding, and the time information is cyclically encoded through cosine and sine transformations. This normalization process enables features in different dimensions to be compared and analyzed on the same scale.

[0037] Taking the AIS data of a certain cargo ship as an example, when an original record is collected (such as at 10:00:00 on January 1, 2024, longitude 122.456, latitude 31.234, speed 12 knots, heading 45 degrees, in the sailing state), after normalization, it will be converted into a feature vector, including the normalized longitude and latitude values (0.756, 0.432), speed and heading values (0.4, 0.25), status encoding (1, 0, 0, 0), and time encoding (0.866, 0.5). When constructing the input sequence, a sliding time window is used to extract continuous time-series features. The window length is set to 30 time steps, and the step size is 1, that is, each time it moves one time step, so that the continuity features of the trajectory can be fully captured. Each input sequence contains feature vectors of 30 consecutive time steps, forming a three-dimensional tensor structure [batch_size, 30, feature_dim]; In the input data structure of the deep learning model, [batch_size, 30, feature_dim] represents a three-dimensional tensor, and the meanings of each dimension are as follows: 1. batch_size: The batch size refers to the number of samples processed simultaneously in one training iteration; in the present invention, batch_size is set to 64, which is the balance point of training efficiency and memory usage determined after multiple experimental comparisons; the batch processing mechanism can accelerate model training and improve the utilization rate of computing resources, and at the same time, the mini-batch stochastic gradient descent method helps the model to jump out of local optimal solutions; 2. 30: Represents the length of the time series, that is, the number of consecutive time points included in the sliding time window; this parameter corresponds to "the length n of the sliding time window"; 3. feature_dim: Feature dimension, which refers to the dimension of the feature vector of the ship's state at each time point; in the present invention, feature_dim is set to 10, including features: longitude coordinate (x) and latitude coordinate (y), representing the position of the ship in the geographical space; speed (v), the sailing speed of the ship; course angle (θ), the sailing direction of the ship; one-hot encoding of the ship's state, 4 binary features, respectively representing sailing, anchoring, mooring and restricted sailing states; time encoding, using sine and cosine functions to perform periodic encoding on time, with a total of 2 features.

[0038] The sliding time window mechanism provides a local data analysis perspective, which can more accurately capture the temporal features and abnormal patterns of the data; through the data processing within the window, a trajectory sequence with a unified format and uniform sampling can be generated; through the window mechanism, a reasonable local constraint range is provided for filling missing values, avoiding the error accumulation that may be brought by global filling.

[0039] The processed data contains the following keyword fields in a unified format: timestamp, MMSI number, longitude and latitude (WGS84 coordinate system), course, speed, ship type, and sailing state. These preprocessed data sequences will be used as the input of the subsequent TCN model for trajectory anomaly detection.

[0040] S2 is the use of the Temporal Convolutional Network (TCN). Using this TCN network, the position information of the ship at the next moment can be output. It can be understood that the Temporal Convolutional Network (TCN) should be trained with training data before this. In the model training stage, historical normal sailing data is used to construct the training set. Each training sample takes the feature sequence from time t to t + 29 as the input X, and the feature vector at time t + 30 as the label y. The time series cross-validation method is used to evaluate the model performance to ensure that the model has good temporal prediction ability.

[0041] The Temporal Convolutional Network (TCN) model designed in the present invention is composed of multiple temporal convolutional layers, one one-dimensional global average pooling layer, and one fully connected layer. This design aims to make full use of the spatio-temporal features of time series data and improve the performance of the model in trajectory prediction and anomaly detection. TCN forms a series of causally related network structures by combining multiple one-dimensional convolutional layers, which are mainly used for tasks such as time series prediction, anomaly detection, and pattern recognition. The core of the model design is that it uses one-dimensional convolution to process time series data, rather than the usual two-dimensional convolution. Here, one-dimensional convolution does not mean that the convolution kernel is only one-dimensional, but that the operation direction of the convolution is one-dimensional, that is, the convolution is performed along the time dimension. Through one-dimensional convolution, the model can extract the features that change along the time axis in the time series data and generate a new representation of the time series data.

[0042] In the TCN model, the temporal convolutional layer is its core component, which consists of a dilated causal convolutional layer, a ReLU activation layer, and a SpatialDropout layer. The dilated causal convolutional layer extends the receptive field of the convolutional kernel by inserting holes (i.e., dilation factors) in the convolutional kernel, enabling the model to capture dependencies over longer time spans. This property is well-suited for processing long time series data, such as ship trajectory data.

[0043] (1) Dilated causal convolutional layer.

[0044] Causal convolution ensures that the output at each time step depends only on the current and past inputs, without leaking future information. This is crucial in time series prediction, as it guarantees that the model makes predictions using only known information, in line with the natural order of time series data. Dilated convolution, on the other hand, extends the receptive field of the convolution by inserting gaps between the convolutional kernels, without increasing the size of the convolutional kernel. This approach can capture dependencies over longer time ranges without increasing computational complexity. By adjusting the dilation rate, the TCN can flexibly control the size of the receptive field, thus better adapting to time series data of different lengths.

[0045] The size of the dilated convolutional kernel equivalent to that of a normal convolutional kernel is shown as follows: ; In the formula, the size of the convolutional kernel of the dilated convolution is , the dilation rate is d , and its equivalent convolutional kernel size is .

[0046] The formula for calculating the receptive field of the current layer in dilated convolution is shown as follows: ; In the formula, the receptive field of the th layer is , the receptive field of the th layer is , the equivalent convolutional kernel size is , where represents the stride of the th layer.

[0047] (2) ReLU activation layer and regularization.

[0048] The ReLU activation layer is a non-linear activation function used to introduce non-linear features and help the model capture complex time series patterns. The ReLU activation function avoids the problem of vanishing gradients by setting negative inputs to zero while leaving positive inputs unchanged, thus improving the training efficiency of the model.

[0049] The SpatialDropout layer is a special regularization technique. Different from the traditional dropout mechanism, SpatialDropout drops the connections of neurons by dimension instead of individual neurons. This way can preserve the correlation of adjacent information in time series data, effectively prevent the loss of correlation in sequence data, and avoid the problem of learning rate decline caused by information loss. By dropping connections by dimension, SpatialDropout can better maintain the overall structure of the data and improve the robustness and generalization ability of the model.

[0050] (3) Pooling layer and fully connected layer.

[0051] After the temporal convolutional layer, the TCN model introduces a one-dimensional global average pooling layer. The global average pooling layer generates an output of a fixed size by averaging all the outputs in the time dimension. This method can effectively reduce the model parameters, avoid overfitting, and at the same time retain important time series information. Compared with the traditional fully connected layer, the global average pooling layer can better summarize the features of the entire sequence and improve the performance and stability of the model.

[0052] Finally, the TCN model integrates the features extracted by the temporal convolutional layer and the global average pooling layer through a fully connected layer to perform the final classification or regression task. The fully connected layer linearly combines the input features and applies an activation function to generate the output of the model. Since the fully connected layer can integrate and summarize the features extracted by the previous layers, it can provide accurate prediction results in tasks such as classification or anomaly detection.

[0053] After that, in S3 and S4, the error between the predicted trajectory and the actual trajectory is calculated, and anomalies are determined based on a threshold. The output of the temporal convolutional network is the prediction of the feature vector for the next time step. Whether there is an anomaly is determined by comparing the mean squared error (MSE) between the predicted value and the true value. Specifically, a threshold θ is set based on historical data statistics. When the prediction error at a certain time point exceeds this threshold, it is determined as an anomaly point. For example, when the MSE between the predicted feature vector of the next moment by the model and the actual observation value is 0.0023, which is less than the preset threshold of 0.01, then this point is considered normal.

[0054] In S5, after obtaining the point-by-point anomaly detection results of the TCN model, it is necessary to organically organize these discrete anomaly points into meaningful anomaly trajectory segments and generate a standardized anomaly detection report for subsequent analysis and processing.

[0055] In some alternative embodiments, S5 further includes: Setting a time threshold for the anomaly trajectory segment. When the span of continuously occurring anomaly points exceeds the time threshold, truncate the anomaly trajectory segment and start timing again.

[0056] In this embodiment, the identification of abnormal trajectory segments adopts an aggregation method based on time continuity: ; where: p i represents the trajectory point at time point i, and t start and t end are the start and end times of the abnormal trajectory segment. .

[0057] First, set a time threshold τ, for example, 10 minutes. When multiple consecutive time points are determined to be abnormal and the time interval is less than τ, these points are grouped into the same abnormal trajectory segment. If the time threshold τ is exceeded, truncation is performed to divide multiple abnormal trajectory segments. This method can effectively avoid the interference of sporadic abnormal points caused by data noise and find the trajectory segments that truly have abnormal behavior characteristics. For example, when the trajectory points of a ship show a large deviation from the predicted value for 15 consecutive minutes, this trajectory will be marked as two complete abnormal trajectory segments, with the first 10 minutes being a complete abnormal trajectory segment and the last 5 minutes being a complete abnormal trajectory segment.

[0058] In some alternative embodiments, in S5, the abnormal score of the abnormal trajectory segment is calculated by the following formula: ; where Score segment is the abnormal score, MSE i is the error at the i-th time point, t start and t end are the start and end time points of the abnormal trajectory segment, n is the number of time points of the abnormal trajectory segment, W duration is the time weight, and τ is the time threshold.

[0059] In this embodiment, in order to improve the accuracy of abnormal trajectory segment identification, an abnormal degree scoring mechanism is introduced. For each abnormal trajectory segment, calculate its average abnormal score: sum the errors of all points within the segment and divide by the number of points to obtain the abnormal intensity index of the segment. At the same time, consider the duration of the trajectory segment (t start -t end ) as a weight calculation factor, so as to calculate the time weight W duration . Abnormal segments with longer durations often have higher research value. In this way, different abnormal trajectory segments can be quantitatively evaluated and prioritized.

[0060] After the identification of abnormal trajectory segments is completed, the system automatically generates a standardized abnormal detection report. The report content includes the following key parts: First is the basic information part, which records the identification information such as the MMSI number and ship type of the ship, as well as the time range when the anomaly occurs. Secondly is the description of anomaly characteristics, including quantitative indicators such as the start and end times, geographical range, and anomaly degree score of the abnormal trajectory segment. For each abnormal trajectory segment, the main characteristic parameters causing the anomaly (such as speed anomaly, course anomaly, etc.) and their specific deviation degrees are also recorded.

[0061] In addition, the report also includes environmental information, which records external factors such as weather conditions and sea conditions when the anomaly occurs. This information helps to analyze the cause of the anomaly. Finally, the anomaly level determination is carried out in step S6. Based on the anomaly score, the anomaly situation is divided into three levels: minor, medium, and severe, and corresponding handling suggestions are given: ; Among them, θ1 and θ2 are thresholds determined based on historical data statistics, and multiple anomaly degree intervals are constructed based on this.

[0062] For the convenience of subsequent analysis and statistics, all anomaly detection reports are stored in the database in a structured form. Each anomaly event is assigned a unique event ID, and an association relationship with relevant ship information and historical anomaly records is established. This storage method is convenient for statistical analysis, such as the statistics of anomaly frequencies in specific sea areas and the comparison of abnormal behaviors of different types of ships.

[0063] Through such an abnormal trajectory segment identification and report generation mechanism, the detection results of the TCN model can be converted into clear descriptions of abnormal behaviors.

[0064] The second aspect of the present invention provides a ship anomaly detection device based on TCN trajectory prediction corresponding to the above method, mainly including: An AIS data acquisition module, which is used to acquire AIS data given by the Automatic Identification System of ships for a set time period before the current moment; A position prediction module, which is used to predict the position of the ship at the next moment based on a pre-trained time convolutional network; An error calculation module, which is used to determine the error between the actual position and the predicted position of the ship at the next moment; An abnormal point determination module, which is used to determine this position as an abnormal point when the error exceeds the threshold; An abnormal score calculation module for abnormal trajectory segments, which is used to regard continuously occurring abnormal points as an abnormal trajectory segment, and calculate the abnormal score of the abnormal trajectory segment with the time length of the abnormal trajectory segment as the weight calculation factor; An abnormal level determination module, which is used to determine the abnormal level of the abnormal trajectory segment according to the abnormal score and multiple abnormal degree intervals.

[0065] In some alternative embodiments, the AIS data acquisition module includes: A uniform sampling unit for mapping AIS data given by an Automatic Identification System (AIS) within a set time period to uniform time points; An outlier removal unit for removing abnormal AIS data values; A missing value filling unit for filling missing values in the AIS data with outliers removed using local time series information; A normalization unit for performing feature normalization on the AIS data after missing value filling.

[0066] In some alternative embodiments, the missing value filling unit includes: A linear interpolation filling subunit for filling data to be filled with missing time less than 10% of the length of the set time period using linear interpolation; A kinetic prediction model filling subunit for filling data to be filled with missing time between 10% - 30% of the length of the set time period using a kinetic prediction model established from historical data; An invalid marking subunit for marking the set time period as an invalid time period for data to be filled with missing time greater than 30% of the length of the set time period.

[0067] In some alternative embodiments, the abnormal score calculation module for abnormal trajectory segments includes: An abnormal trajectory segment truncation unit for setting a time threshold for abnormal trajectory segments, and when the span of consecutive abnormal points exceeds the time threshold, truncating the abnormal trajectory segment and restarting the timing.

[0068] In some alternative embodiments, in the abnormal score calculation module for abnormal trajectory segments, the abnormal score of the abnormal trajectory segment is calculated by the following formula: ; where Score segment is the abnormal score, MSE i is the error at the i-th time point, t start and t end are the start and end time points of the abnormal trajectory segment, n is the number of time points in the abnormal trajectory segment, W duration is the time weight, and τ is the time threshold.

[0069] Although the present invention has been described in detail above with general descriptions and specific embodiments, based on the present invention, some modifications or improvements can be made, which are obvious to those skilled in the art. Therefore, these modifications or improvements made without departing from the spirit of the present invention all fall within the scope of the present invention claimed.

Claims

1. A ship anomaly detection method based on TCN trajectory prediction, characterized in that, include: S1, obtaining the AIS data given by the ship automatic identification system for a set time period before the current time; S2, based on the AIS data obtained in S1, uses the pre-trained temporal convolutional network to predict the position of the ship at the next moment; S3, determining the error between the actual position of the ship at the next moment and the predicted position; S4. When the error exceeds a threshold, the position is determined to be an abnormal point; S5, taking the continuously occurring abnormal points as abnormal trajectory segments, taking the time length of the abnormal trajectory segments as a weight calculation factor, and calculating the abnormal score of the abnormal trajectory segments; S6. Determine the abnormality level of the abnormal trajectory segment according to the abnormality score and multiple abnormality degree intervals.

2. The method for ship anomaly detection based on TCN trajectory prediction according to claim 1, wherein, The specific process of S1 is as follows: S11, mapping the AIS data given by the ship automatic identification system within a set time period to uniform time points; S12, eliminating abnormal AIS data values; S13, using local time series information to fill missing values in the AIS data after outliers are removed; S14. Perform feature normalization on the AIS data after missing value filling.

3. The method for detecting ship anomalies based on TCN trajectory prediction according to claim 2, characterized in that, The specific process of S13 is as follows: For the data to be filled whose missing time is less than the first preset ratio of the set time period length, linear interpolation is used for filling; For the data to be filled whose missing time is between the first preset proportion and the second preset proportion of the set time period length, the kinetic prediction model established by the historical data is used for filling; For the data to be filled whose missing time is greater than the second preset ratio of the length of the set time period, the set time period is marked as an invalid time period; Wherein, the first preset ratio is smaller than the second preset ratio.

4. The ship anomaly detection method based on TCN trajectory prediction according to claim 1, wherein, The specific process of treating the continuously occurring abnormal points as abnormal trajectory segments in S5 is as follows: Set the time threshold of the abnormal trajectory segment. When the span of consecutive abnormal points exceeds the time threshold, the abnormal trajectory segment is truncated and the timing starts again.

5. The ship anomaly detection method based on TCN trajectory prediction according to claim 4, wherein, In S5, the anomaly score of the abnormal trajectory segment is calculated by the following formula: ; Among them, Score segment is the anomaly score, MSE i is the error at the i-th time point, t start and t end are the start and end time points of the anomaly trajectory segment, n is the number of time points of the anomaly trajectory segment, W duration is the time weight, and τ is the time threshold.

6. A ship anomaly detection device based on TCN trajectory prediction, characterized in that, include: AIS data acquisition module, used to acquire AIS data given by the ship automatic identification system in a set time period before the current moment; The position prediction module is used to predict the position of the ship at the next moment based on the pre-trained temporal convolutional network; The error calculation module is used to determine the error between the actual position of the ship at the next moment and the predicted position; An outlier determination module, used to determine that the location is an outlier when the error exceeds a threshold; An abnormal score calculation module for an abnormal trajectory segment, used to take the continuously occurring abnormal points as an abnormal trajectory segment, and use the time length of the abnormal trajectory segment as a weight calculation factor to calculate the abnormal score of the abnormal trajectory segment; The abnormality level determination module is used to determine the abnormality level of the abnormal trajectory segment according to the abnormality score and multiple abnormality degree intervals.

7. The ship anomaly detection device based on TCN trajectory prediction according to claim 6, wherein The AIS data acquisition module includes: A uniform sampling unit is used to map the AIS data given by the ship automatic identification system in a set time period to uniform time points; An outlier elimination unit is used to eliminate abnormal AIS data values; A missing value filling unit is used to fill missing values of AIS data with outliers removed by using local time series information; A normalization unit for performing feature normalization processing on the AIS data after missing value filling.

8. The ship anomaly detection device based on TCN trajectory prediction according to claim 7, wherein, The missing value filling unit includes: A linear interpolation filling sub-unit for filling the data to be filled with missing time less than the first preset ratio of the set time period length using linear interpolation; A dynamic prediction model filling sub-unit for filling the data to be filled with missing time between the first preset ratio and the second preset ratio of the set time period length using the dynamic prediction model established from historical data; An invalid marking sub-unit for marking the set time period as an invalid time period for the data to be filled with missing time greater than the second preset ratio of the set time period length; Wherein, the first preset ratio is less than the second preset ratio.

9. The ship anomaly detection device based on TCN trajectory prediction according to claim 6, wherein The abnormal score calculation module for the abnormal trajectory segment includes: An abnormal trajectory segment intercepting unit for setting a time threshold for the abnormal trajectory segment, and when the span of continuously appearing abnormal points exceeds the time threshold, truncating the abnormal trajectory segment and restarting the timing.

10. The ship anomaly detection device based on TCN trajectory prediction according to claim 9, characterized in that, In the abnormal score calculation module for the abnormal trajectory segment, the abnormal score of the abnormal trajectory segment is calculated by the following formula: ; Among them, Score segment is the anomaly score, MSE i is the error at the i-th time point, t start and t end are the start and end time points of the abnormal trajectory segment, n is the number of time points of the abnormal trajectory segment, W duration is the time weight, and τ is the time threshold.

Citation Information

Patent Citations

  • Ship abnormal state detection method based on AIS data

    CN115169527A

Cited By

  • Ship trajectory data security method and system

    CN120874139A

  • A method and system for securing ship trajectory data

    CN120874139B