A ship track prediction and abnormal behavior detection method based on AIS data
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- THE 54TH RESEARCH INSTITUTE OF CHINA ELECTRONICS TECHNOLOGY GROUP CORPORATION
- Filing Date
- 2026-04-21
- Publication Date
- 2026-08-07
AI Technical Summary
[0003]现有技术中,AIS数据预处理通常通过空间范围过滤和时间阈值剔除明显异常点并插值补全,但对长时缺测段重构、系统性偏差等复杂情形仍存在局限
[0040] 1. This invention can improve trajectory quality through preprocessing.
Smart Images

Figure CN122531179A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent monitoring and safety early warning technology for maritime traffic, and in particular to a method for predicting ship tracks and detecting abnormal behavior based on AIS data. Background Technology
[0002] AIS (Automatic Identification System) provides dynamic information such as a vessel's identity, location, speed, and course, serving as a crucial data source for modern maritime traffic monitoring. The long-term accumulation of AIS data has resulted in massive amounts of vessel navigation trajectory data, providing a foundation for analyzing vessel behavior and improving maritime traffic safety using data mining and machine learning techniques.
[0003] In existing technologies, AIS data preprocessing typically involves spatial range filtering and temporal thresholding to remove obvious outliers and then interpolating to complete the data. However, this approach still has limitations in complex scenarios such as reconstructing long-term missing data segments and handling systematic biases. Regarding trajectory prediction, most models only output point predictions, lacking quantification of prediction uncertainty and often operating independently of anomaly detection, making it difficult to provide a reliable basis for risk warnings. In anomaly detection, fixed threshold or rule-based methods have insufficient coverage, and data-driven methods that do not consider prediction uncertainty are prone to false positives / false negatives.
[0004] Therefore, there is an urgent need for a closed-loop method that integrates AIS data cleaning, rolling prediction, prediction interval evaluation and dynamic anomaly judgment to achieve high-precision and high-reliability anomaly early warning. Summary of the Invention
[0005] In view of this, the present invention provides a method for ship track prediction and abnormal behavior detection based on AIS data. This method performs high-quality preprocessing of AIS data, utilizes a deep learning model for rolling multi-step track prediction, and generates a prediction interval based on the prediction error distribution. When actual observations exceed the prediction interval, dynamic anomaly judgment and classification are performed, and the anomalies are verified and classified using a historical normal track pattern library. The method outputs early warning information including deviation and confidence level explanations, thereby reducing false alarms / missed alarms and improving interpretability.
[0006] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0007] A method for ship trajectory prediction and abnormal behavior detection based on AIS data includes an offline preparation stage and an online detection stage;
[0008] The offline preparation phase includes the following steps:
[0009] Step 11: Obtain historical AIS trajectory data, preprocess the historical AIS trajectory data to obtain a continuous sequence of ship motion trajectories;
[0010] Step 12: Construct a training sample dataset based on a continuous sequence of ship motion trajectories. The training samples include an input sequence consisting of a historical trajectory window of length L and a position label sequence for the next H steps corresponding to the input sequence.
[0011] Step 13: Construct a deep learning model for trajectory prediction. Train the deep learning model for trajectory prediction using the training sample dataset to obtain a trained trajectory prediction model.
[0012] Step 14: Cluster the historical AIS trajectory data to generate representative trajectory sequences and form a trajectory pattern library;
[0013] Step 15: Based on the validation samples or training residuals of the training sample dataset, establish a prediction error sample set and determine the interval estimation parameters used for prediction interval calculation.
[0014] The online detection phase cyclically executes the following steps:
[0015] Step 21: Collect real-time AIS observation data of the target vessel and perform preprocessing;
[0016] Step 22: Construct an input sequence of length L based on real-time AIS observation data. When there are missing real-time AIS data points, use the predicted positions output from the previous loop to fill in the missing data points.
[0017] Step 23: Input the input sequence into the trained trajectory prediction deep learning model to obtain the predicted position sequence of the target ship in the next H steps;
[0018] Step 24: Based on the interval estimation parameters, calculate the prediction interval at a predetermined confidence level for at least one prediction location in the prediction location sequence;
[0019] Step 25: Compare the real-time AIS observed position with the predicted position and prediction interval at the corresponding time. When the real-time AIS observed position falls outside the prediction interval, it is judged as an anomaly. The anomaly is verified and classified based on the track pattern library.
[0020] Step 26: Output abnormal warning information.
[0021] Furthermore, the preprocessing in steps 11 and 21 includes at least: deleting records exceeding the preset sea area, deleting records with abnormal or duplicate timestamps, and filtering, cleaning, and interpolating the remaining records. The interpolation method is as follows:
[0022] When the time difference Δt between two adjacent AIS records is not greater than the first time threshold ΔT1, kinematic interpolation is performed to fill the missing points between the two adjacent AIS records based on air speed and heading.
[0023] When the time difference Δt is greater than the second time threshold ΔT2, the trajectory endpoints before and after the interruption and their adjacent trajectory segments are matched with the trajectory representative sequences in the trajectory pattern library. If the match is successful, the matched representative sequence segments are extracted and time-aligned to generate the replacement point; if the match is unsuccessful, kinematic extrapolation is performed based on the airspeed and heading to generate the replacement point.
[0024] Among them, ΔT2 is greater than ΔT1, and ΔT2 is used to characterize long-term data interruption.
[0025] Furthermore, the deep learning model for trajectory prediction in step 13 is a sequence-to-sequence model, including: an input layer for receiving time-series inputs containing at least position, speed, and heading; a sequence modeling layer for extracting time dependencies; and a regression output layer for outputting the future H-step position; the sequence modeling layer is a Transformer structure, a gated recurrent unit (GRU) structure, or a long short-term memory (LSTM) network structure, and includes an attention mechanism.
[0026] Further, the training in step 13 includes: using the future H-step position label sequence as a supervision signal, calculating the position error between the predicted position sequence and the label sequence as the loss, and iteratively updating the model parameters until a preset termination condition is met; the termination condition includes at least one of the following: the verification loss is less than a preset threshold, the verification loss no longer decreases in several consecutive iterations, and the number of iterations reaches a preset upper limit.
[0027] Furthermore, the clustering in step 14 uses the density-based clustering algorithm DBSCAN to cluster the set of trajectory points or trajectory feature vectors obtained from historical AIS trajectory data, and the cluster center or representative trajectory within each trajectory cluster is used as the trajectory representative sequence; the neighborhood radius parameter eps_db and the minimum number of samples minPts of DBSCAN are optional parameters.
[0028] In step 25, the position observed by real-time AIS is compared with the predicted position and prediction interval at the corresponding time, including: calculating the distance between the current trajectory segment and each trajectory representative sequence, selecting the trajectory representative sequence with the smallest distance as the matching result, and comparing the distance with a preset threshold ε to determine whether the matching is successful; the distance is the Hausdorff distance or the Dynamic Time Warping (DTW) distance.
[0029] Further, step 24 is specifically implemented as follows: constructing a probability density function of the prediction error based on the prediction error sample set, and determining the error limit according to a predetermined confidence level; mapping the error limit to the prediction position to obtain the prediction interval; wherein, the probability density function is constructed by kernel density estimation (KDE).
[0030] Furthermore, the kernel density estimation KDE takes the following form:
[0031] For the error sample set {e i Construct the error density function:
[0032]
[0033] Where K is the kernel function, h is the bandwidth, and n is the total number of error samples;
[0034] Based on the error density function, the quantile boundary is calculated according to a predetermined confidence level and used as the error limit.
[0035] Furthermore, step 24 is specifically implemented as follows: while keeping the deep learning model for trajectory prediction in step 13 unchanged, Monte Carlo Dropout is used to perform multiple forward inferences on the same input sequence to obtain multiple sets of predicted position samples, and the prediction interval is determined by the statistical distribution of the predicted position samples.
[0036] Furthermore, in step 25, when the position observed by the real-time AIS falls outside the prediction interval, the anomaly is classified according to the confidence level corresponding to the prediction interval; the speed deviation and / or heading deviation are compared with the preset threshold to form a joint anomaly criterion.
[0037] The abnormal warning information output in step 26 includes at least the time of the abnormality, the level of the abnormality, the type of the abnormality, and an explanatory description of the deviation amount and corresponding confidence level that triggered the abnormality. The explanatory description is generated by a feature contribution evaluation method, which is the SHAP value method. The features include at least position deviation, speed deviation, heading deviation, and pattern matching distance.
[0038] Furthermore, the online detection phase also includes online learning: collecting recent input sequences within a preset update cycle, forming an incremental sample set with the corresponding real AIS observation labels, and fine-tuning and updating the trajectory prediction model when preset error conditions are met.
[0039] The beneficial effects of this invention compared to the prior art include at least the following:
[0040] 1. This invention can improve trajectory quality through preprocessing.
[0041] 2. This invention maintains consistency between prediction and observation by fusing rolling prediction with missing data.
[0042] 3. This invention quantifies the uncertainty of prediction through interval estimation and forms a dynamic threshold, which can improve the accuracy of prediction.
[0043] 4. This invention uses a pattern library to verify classification, which can improve the stability and interpretability of anomaly identification.
[0044] 5. This invention improves processing efficiency through hierarchical alarms and explanatory outputs. Attached Figure Description
[0045] Figure 1 This is a flowchart of a method for ship trajectory prediction and abnormal behavior detection based on AIS data according to the present invention.
[0046] Figure 2 This is a structural diagram of a ship trajectory prediction and abnormal behavior detection system based on AIS data according to the present invention. Detailed Implementation
[0047] The technical solution of the present invention will be further described below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0048] A method for ship trajectory prediction and abnormal behavior detection based on AIS data, such as Figure 1 As shown, it includes an offline preparation phase and an online detection phase.
[0049] The offline preparation phase includes:
[0050] S11. Obtain historical AIS trajectory data and preprocess the historical AIS trajectory data. The preprocessing includes at least: deleting records that exceed the preset sea area range, deleting records with abnormal and duplicate timestamps, filtering, cleaning and interpolating the remaining records to obtain a continuous sequence of ship motion trajectories.
[0051] S12. Construct a training sample dataset based on the continuous ship motion trajectory sequence. The training sample dataset includes: an input sequence consisting of historical trajectory windows of length L and a future H-step position label sequence corresponding to the input sequence.
[0052] S13. Construct a deep learning model for trajectory prediction, and train the deep learning model for trajectory prediction using the training sample dataset to obtain a trained trajectory prediction model.
[0053] S14. Cluster the historical AIS trajectory data, generate and store the trajectory representative sequence to form a trajectory pattern library;
[0054] S15. Based on the validation samples or training residuals of the training sample dataset, establish a prediction error sample set and determine the interval estimation parameters used for prediction interval calculation.
[0055] The online detection phase includes a cyclical execution:
[0056] S21. Collect real-time AIS observation data of the target vessel and preprocess the real-time AIS observation data according to the preprocessing rules in step S11.
[0057] S22. Update the input sequence of length L based on the real-time AIS observation data; when there are missing real-time AIS measurements, use the predicted positions output by the previous loop to fill in the missing time points to form the input sequence.
[0058] S23. Input the input sequence into the trained trajectory prediction deep learning model to obtain the predicted position sequence of the target ship in the next H steps;
[0059] S24. Based on the interval estimation parameters determined in step S15, calculate the prediction interval at a predetermined confidence level for at least one prediction position in the prediction position sequence.
[0060] S25. Compare the real-time AIS observation position with the predicted position and prediction interval at the corresponding time; when the real-time AIS observation position falls outside the prediction interval, it is determined to be abnormal, and the abnormality is verified and classified based on the track pattern library formed in step S14.
[0061] S26. Output abnormal warning information.
[0062] The specific implementation of the preprocessing in steps S11 and S21 is as follows:
[0063] (1) Sea area range filtering: Based on the preset geofence or sea area boundary, remove records that fall outside the boundary;
[0064] (2) Timestamp consistency processing: Remove records with out-of-order, duplicate, or obviously abnormal timestamps;
[0065] (3) Outlier handling: Identify and remove outliers based on conditions such as speed, heading, and position jumps;
[0066] (4) Filtering and cleaning: Kalman filtering is used to smooth the trajectory;
[0067] (5) Interpolation completion: When the time difference Δt between two adjacent AIS records is not greater than the first time threshold ΔT1, kinematic interpolation is performed based on air speed and heading to complete the points; when Δt is greater than the second time threshold ΔT2, similarity matching and time alignment are performed based on the track pattern library to complete the points. If the matching fails, kinematic extrapolation is used to complete the points.
[0068] The specific implementation methods of steps S12 and S13 are as follows:
[0069] The training samples are constructed using a sliding window: input sequence X t =[s t−L+1 , s t−L+2 ,…, s t ], where s i It should at least include position, speed, and heading. Tag sequence Y t =[p t+1 ,…,p t+H [This represents the predicted position sequence for the next H steps. H is the predicted step size, p] is the predicted position sequence for the next H steps. t+K Represents the true position at time t+K.
[0070] The trajectory prediction deep learning model adopts a sequence-to-sequence structure, including an input layer, a sequence modeling layer, and an output layer. The sequence modeling layer can be a Transformer structure or a GRU / LSTM structure and includes an attention mechanism. The output layer outputs a sequence of predicted positions for the next H steps.
[0071] The training employs supervised learning, with the loss function example being the multi-step position mean square error:
[0072]
[0073] Termination conditions include at least: the verification loss is less than a threshold, the verification loss no longer decreases for several consecutive rounds, or the number of iterations reaches the upper limit.
[0074] The specific implementation methods of the trajectory pattern library and matching verification in steps S14 and S25 are as follows:
[0075] Historical normal AIS trajectories are clustered according to geographical location sequences to obtain multiple trajectory clusters. A representative trajectory sequence is generated for each trajectory cluster and stored to form a trajectory pattern library. Optionally, the clustering algorithm used is DBSCAN, with parameters including the neighborhood radius eps_db and the minimum number of samples minPts.
[0076] During anomaly verification / classification, extract the recent trajectory segment A of the target vessel and compare it with representative sequences B from the pattern library. j Calculate the distance Dist(A,B) jThe algorithm selects the distance with the smallest distance and compares it with a threshold ε to determine if they match. The distance can be the Hausdorff distance or the Dynamic Time Warping (DTW) distance; when the minimum distance is greater than ε, it can be determined as a global anomaly that does not match the normal pattern.
[0077] The specific implementation of the prediction interval in steps S15 and S24 is as follows:
[0078] Construct a prediction error sample set {e} on the validation set or training residuals. i Kernel density estimation of KDE is the main focus:
[0079]
[0080] Where K is the kernel function and h is the bandwidth; the quantile boundary q is calculated based on a predetermined confidence level c. c Make P(e≤q) c )=c, then q c This serves as an error bound and is mapped to the prediction location to generate the prediction interval. Center, radius The confidence circle or confidence rectangle.
[0081] Optionally, Monte Carlo Dropout is used: during the inference phase, multiple forward inferences are performed on the same input sequence to obtain a prediction sample set, and the prediction interval is determined by its statistical distribution.
[0082] The specific implementation methods of steps S22, S25 and S26 are as follows:
[0083] Input sequence update and missing data fusion: Maintain an input sequence cache of length L; if a real AIS observation exists at a certain time, the prediction at that time in the previous cycle is overwritten with the real observation; if the data is missing, the predicted points are retained to fill the gaps.
[0084] Anomaly detection and classification: When the real-time AIS observation position falls outside the prediction interval, an anomaly is detected, and the anomaly can be classified according to the confidence level corresponding to the prediction interval; optionally, the speed deviation and / or heading deviation are compared with a preset threshold to form a joint anomaly criterion.
[0085] Warning output: The output should at least include the time of anomaly occurrence, anomaly level, anomaly type, and an explanatory description of the deviation from the triggering anomaly and its corresponding confidence level; optionally, the explanatory description is generated using a feature contribution evaluation method, which may be the SHAP value method. The features include at least position deviation, speed deviation, heading deviation, and pattern matching distance.
[0086] Optionally, the online detection phase also includes online learning: collecting recent input sequences and their corresponding real AIS observation labels to form an incremental sample set within a preset update cycle, and fine-tuning and updating the trajectory prediction model when preset error conditions are met.
[0087] Here is a more specific example:
[0088] A method for ship trajectory prediction and abnormal behavior detection based on AIS data.
[0089] Relative terminology and optional parameter descriptions: L is the input sequence window length (number of points or time window), H is the prediction step number; Δt is the time difference between adjacent AIS records; ΔT1 is the short-term missing threshold, ΔT2 is the long-term interruption threshold and ΔT2>ΔT1; ε is the pattern matching threshold; confidence level c∈(0,1).
[0090] Example range: L can be 10 to 200 trajectory points; H can be 1 to 60 steps; ΔT1 can be 10 to 180 seconds; ΔT2 can be 5 to 30 minutes; ε can be 0.1 to 5 kilometers equivalent distance; confidence level c can be 0.90, 0.95, 0.99, etc.
[0091] Example of Kalman filtering (for S11 / S21 filtering and cleaning): The state vector can take the form x. k =[x k ,y k ,v x , k ,v y , k ] T Where x k y k Represents the position component, v x , k v y , k Represents the velocity component. x k y k It can be approximated by latitude and longitude or by using equivalent planar coordinates. Observation vector z k =[x k ,y k ] T .
[0092] State transition matrix:
[0093]
[0094] Observation matrix:
[0095]
[0096] The prediction steps are as follows:
[0097]
[0098]
[0099] Update steps:
[0100]
[0101] Output: Smooth position (x̂) k|k , ŷ k|k ), and is used for subsequent interpolation completion and sample construction. Q k R is the noise covariance, which can be determined empirically or by verification set tuning parameters.
[0102] Example of interpolation completion (for S11 / S21): Kinematic interpolation is used when Δt≤ΔT1, taking speed v and heading ψ as an example:
[0103] x(τ+δ)=x(τ)+v(τ)·cosψ(τ)·δ
[0104] y(τ+δ)=y(τ)+v(τ)·sinψ(τ)·δ
[0105] Where δ∈(0,Δt). When Δt>ΔT2, priority is given to supplementing points in the pattern library: the endpoints before and after the interruption and their neighborhood trajectory segments are matched with the representative sequence in the pattern library. If the match is successful, the points are extracted and time-aligned to generate supplementary points; if the match fails, kinematic extrapolation is used to supplement the points.
[0106] Example of sample construction and labeling (for S12): Using a sliding window for a continuous trajectory sequence: Input X t =[s t−L+1 , s t−L+2 ,…, s t ], tag Y t =[p t+1 ,…,p t+H It can normalize input features and split training / validation datasets.
[0107] Example of model structure (for S13): The input layer receives time-series features (position, speed, heading) of length L; the sequence modeling layer uses Transformer or GRU / LSTM to extract time-dependent features, and an attention mechanism is used to fuse multi-source features; the output layer regresses and outputs a future H-step position prediction sequence P̂=[p̂ t+1 ,…,p̂].
[0108] Example of training loss and termination condition (for S13): Possible loss functions:
[0109]
[0110] Examples of termination conditions: verification loss is less than a threshold, verification loss does not decrease for several consecutive rounds, or the number of iterations reaches the upper limit (all are optional settings).
[0111] Example of pattern library construction (for S14): Cluster historical normal trajectories to obtain trajectory clusters, and generate a representative trajectory sequence for each cluster. DBSCAN can be used optionally: the parameters eps_db are the neighborhood radius, and minPts are the minimum number of samples (both optional parameters). The representative sequence can be selected from the representative trajectory (medoid) within the cluster or the mean trajectory. The pattern library stores information such as the representative sequence, cluster number, and statistical range.
[0112] Example of similarity metric and matching threshold ε (for S25):
[0113] Hausdorff distance:
[0114]
[0115] DTW distance recursion:
[0116] D(i,j)=d(a i ,b j )+min{D(i−1,j),D(i,j−1),D(i−1,j−1)},
[0117] DTW distance is:
[0118] DTW(A,B)=D(|A|,|B|).
[0119] Matching determination: Matching trajectory segment A with each representative sequence B j Calculate Dist(A,B) j Take the minimum value. When d min A match is considered successful if the value is less than or equal to ε; otherwise, the match is considered unsuccessful (ε is an optional parameter; see the example range).
[0120] Example of KDE interval estimation and confidence mapping (for S15 / S24): constructing {e} on the validation set or training residuals from the error sample set. i}, where e i Acceptable ||p̂ i -p i ||2.
[0121] Kernel density estimation:
[0122]
[0123] K is the kernel function, h is the bandwidth, and n is the number of samples.
[0124] Confidence mapping: Calculate the quantile boundary q for a predetermined confidence level c. c Make P(e≤q) c )=c, then q c This serves as an error bound and is mapped to the prediction location to form the prediction interval (centered at p̂, with a radius of q). c (Confidence circle).
[0125] Monte Carlo Dropout alternative (for S24) implementation example:
[0126] During the inference phase, M forward inferences are performed on the same input sequence to obtain the prediction sample set. (m=1,…,M), calculate the specified confidence boundary to form the prediction interval based on the sample distribution (M is an optional parameter).
[0127] Online learning implementation example: Collect recent input sequences and their corresponding real AIS observation labels to form an incremental sample set according to a preset update cycle; when the average prediction error exceeds the threshold, fine-tune and update the trajectory prediction model with a small learning rate, and mix historical samples to suppress drift (all optional settings).
[0128] Example implementation of the warning explanation module (for explanatory description):
[0129] Explanatory descriptions can be generated using a feature contribution evaluation method, such as the SHAP value method; features may include position deviation, speed deviation, heading deviation, and pattern matching distance, etc.
[0130] Pseudocode example of a rolling loop during the online detection phase:
[0131] Input: Trained prediction model (Model), pattern library (Lib), interval parameters (KDE / quantile boundaries), window length (L), number of prediction steps (H)
[0132] cycle:
[0133] 1) Collect real-time AIS points s t And preprocessing (filtering / interpolation)
[0134] 2) Update window W: If a measurement is missing, use the prediction from the previous loop to fill the gap; if there is a real observation, overwrite the prediction at the same time.
[0135] 3) Prediction: P̂ = Model(W) outputs the prediction for the next H steps.
[0136] 4) Interval: Generate a prediction interval (Region) for P with confidence level c.
[0137] 5) Judgment: If the observed p t If it falls outside a Region, mark it as an anomaly and classify it using Lib matching.
[0138] 6) Output: Anomaly warning information (time / level / type / deviation / confidence level interpretation)
[0139] A ship trajectory prediction and abnormal behavior detection system based on AIS data, such as Figure 2 As shown, it includes an offline preparation unit and an online detection unit. The offline preparation unit includes a historical data preprocessing module, a sample construction module, a model training module, a pattern library construction module, and an interval parameter calibration module; the online detection unit includes a real-time data acquisition and preprocessing module, an input sequence update and missing test fusion module, a rolling prediction module, an interval generation module, an anomaly detection and classification module, and an early warning output module.
[0140] In this example, the following parameters are used: L=30, H=12, ΔT1=60 seconds, ΔT2=600 seconds, c∈{0.95,0.99}, eps_db=1 km, minPts=10, ε=0.5 km. During the online phase, an advanced alarm is triggered and an explanatory description is output when the observed location falls outside the 99% interval and the joint anomaly criterion is met.
[0141] This invention enables closed-loop coordination of trajectory prediction, uncertainty quantification, and anomaly detection, reducing false alarms and missed alarms caused by fixed thresholds, and improving the reliability and interpretability of maritime monitoring.
[0142] Those skilled in the art will recognize that the above embodiments are intended to help readers understand the principles of the present invention, and should be understood that the scope of protection of the present invention is not limited to the described embodiments. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of the claims of the present invention.
Claims
1. A method for ship trajectory prediction and abnormal behavior detection based on AIS data, characterized in that, Includes an offline preparation phase and an online testing phase; The offline preparation phase includes the following steps: Step 11: Obtain historical AIS trajectory data, preprocess the historical AIS trajectory data to obtain a continuous sequence of ship motion trajectories; Step 12: Construct a training sample dataset based on a continuous sequence of ship motion trajectories. The training samples include an input sequence consisting of a historical trajectory window of length L and a position label sequence for the next H steps corresponding to the input sequence. Step 13: Construct a deep learning model for trajectory prediction. Train the deep learning model for trajectory prediction using the training sample dataset to obtain a trained trajectory prediction model. Step 14: Cluster the historical AIS trajectory data to generate representative trajectory sequences and form a trajectory pattern library; Step 15: Based on the validation samples or training residuals of the training sample dataset, establish a prediction error sample set and determine the interval estimation parameters used for prediction interval calculation. The online detection phase cyclically executes the following steps: Step 21: Collect real-time AIS observation data of the target vessel and perform preprocessing; Step 22: Construct an input sequence of length L based on real-time AIS observation data. When there are missing real-time AIS data points, use the predicted positions output from the previous loop to fill in the missing data points. Step 23: Input the input sequence into the trained trajectory prediction deep learning model to obtain the predicted position sequence of the target ship in the next H steps; Step 24: Based on the interval estimation parameters, calculate the prediction interval at a predetermined confidence level for at least one prediction location in the prediction location sequence; Step 25: Compare the real-time AIS observed position with the predicted position and prediction interval at the corresponding time. When the real-time AIS observed position falls outside the prediction interval, it is judged as an anomaly. The anomaly is verified and classified based on the track pattern library. Step 26: Output abnormal warning information.
2. The method for ship trajectory prediction and abnormal behavior detection based on AIS data according to claim 1, characterized in that, The preprocessing in steps 11 and 21 includes at least the following: deleting records outside the preset sea area, deleting records with abnormal or duplicate timestamps, and filtering, cleaning, and interpolating the remaining records. The interpolation method is as follows: When the time difference Δt between two adjacent AIS records is not greater than the first time threshold ΔT1, kinematic interpolation is performed to fill the missing points between the two adjacent AIS records based on air speed and heading. When the time difference Δt is greater than the second time threshold ΔT2, the trajectory endpoints before and after the interruption and their adjacent trajectory segments are matched with the trajectory representative sequences in the trajectory pattern library. If the match is successful, the matched representative sequence segments are extracted and time-aligned to generate the replacement point; if the match is unsuccessful, kinematic extrapolation is performed based on the airspeed and heading to generate the replacement point. Among them, ΔT2 is greater than ΔT1, and ΔT2 is used to characterize long-term data interruption.
3. The method for ship trajectory prediction and abnormal behavior detection based on AIS data according to claim 1, characterized in that, The deep learning model for trajectory prediction in step 13 is a sequence-to-sequence model, including: an input layer for receiving time-series inputs containing at least position, speed and heading, a sequence modeling layer for extracting time dependencies, and a regression output layer for outputting the future H-step position; the sequence modeling layer is a Transformer structure, a gated recurrent unit (GRU) structure, or a long short-term memory (LSTM) network structure, and includes an attention mechanism.
4. The method for ship trajectory prediction and abnormal behavior detection based on AIS data according to claim 1, characterized in that, The training in step 13 includes: using the future H-step position label sequence as a supervision signal, calculating the position error between the predicted position sequence and the label sequence as the loss, and iteratively updating the model parameters until a preset termination condition is met; the termination condition includes at least one of the following: the verification loss is less than a preset threshold, the verification loss no longer decreases in several consecutive iterations, and the number of iterations reaches a preset upper limit.
5. The method for ship trajectory prediction and abnormal behavior detection based on AIS data according to claim 1, characterized in that, The clustering in step 14 uses the density-based clustering algorithm DBSCAN to cluster the set of trajectory points or trajectory feature vectors obtained from historical AIS trajectory data. The cluster center or representative trajectory within each trajectory cluster is used as the trajectory representative sequence. The neighborhood radius parameter eps_db and the minimum number of samples minPts in DBSCAN are optional parameters. In step 25, the position observed by real-time AIS is compared with the predicted position and prediction interval at the corresponding time, including: calculating the distance between the current trajectory segment and each trajectory representative sequence, selecting the trajectory representative sequence with the smallest distance as the matching result, and comparing the distance with a preset threshold ε to determine whether the matching is successful; the distance is the Hausdorff distance or the Dynamic Time Warping (DTW) distance.
6. The method for ship trajectory prediction and abnormal behavior detection based on AIS data according to claim 1, characterized in that, The specific method of step 24 is as follows: construct the probability density function of the prediction error based on the prediction error sample set, and determine the error limit according to the predetermined confidence level; map the error limit to the prediction position to obtain the prediction interval; wherein, the probability density function is constructed by kernel density estimation (KDE).
7. The method for ship trajectory prediction and abnormal behavior detection based on AIS data according to claim 6, characterized in that, The kernel density estimation KDE takes the following form: For the error sample set {e i Construct the error density function: Where K is the kernel function, h is the bandwidth, and n is the total number of error samples; Based on the error density function, the quantile boundary is calculated according to a predetermined confidence level and used as the error limit.
8. The method for ship trajectory prediction and abnormal behavior detection based on AIS data according to claim 1, characterized in that, The specific method of step 24 is as follows: while keeping the deep learning model for trajectory prediction in step 13 unchanged, Monte Carlo Dropout is used to perform multiple forward inferences on the same input sequence to obtain multiple sets of predicted position samples, and the prediction interval is determined by the statistical distribution of the predicted position samples.
9. The method for ship trajectory prediction and abnormal behavior detection based on AIS data according to claim 1, characterized in that, In step 25, when the position observed by the real-time AIS falls outside the prediction interval, the anomaly is classified according to the confidence level corresponding to the prediction interval; the speed deviation and / or heading deviation are compared with the preset threshold to form a joint anomaly criterion. The abnormal warning information output in step 26 includes at least the time of the abnormality, the level of the abnormality, the type of the abnormality, and an explanatory description of the deviation amount and corresponding confidence level that triggered the abnormality. The explanatory description is generated by a feature contribution evaluation method, which is the SHAP value method. The features include at least position deviation, speed deviation, heading deviation, and pattern matching distance.
10. The method for ship trajectory prediction and abnormal behavior detection based on AIS data according to claim 1, characterized in that, The online detection phase also includes online learning: collecting recent input sequences within a preset update cycle, forming an incremental sample set with the corresponding real AIS observation labels, and fine-tuning and updating the trajectory prediction model when preset error conditions are met.