Real-time abnormal sub-trajectory detection method based on multi-level self-supervised learning
By employing multi-level self-supervised learning and multi-scale strategies, the problem of fine-grained anomaly sub-trajectory detection in trajectory data is solved, achieving efficient and accurate detection without relying on source-target point information. This approach is suitable for real-time traffic monitoring and fraud detection.
Patent Information
- Application Number
- CN202511624644.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-07
- Publication Date
- 2026-02-17
AI Technical Summary
Existing technologies struggle to achieve real-time localization and accuracy assessment of fine-grained anomalous sub-trajectories in trajectory data without relying on prior information between the source and target points, and lack effective methods for detecting local anomalies, thus limiting their application in real-world scenarios.
We employ a multi-level self-supervised learning approach, utilizing a multi-scale strategy and a hierarchical fusion mechanism, along with a hybrid convolutional recurrent encoder and self-supervised learning, to generate embedding vectors for trajectory segments. We then use reconstruction errors to determine the anomalousness of trajectory segments and combine the intersection-over-union ratio (IoU) and dual-threshold evaluation system for accurate localization and evaluation.
It achieves efficient and accurate fine-grained anomaly sub-trajectory detection of trajectory data without relying on source-target point information, improving detection performance and evaluation accuracy, and is suitable for real-world real-time traffic monitoring and fraud detection scenarios.
Smart Images

Figure CN121542798A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of spatiotemporal data mining and intelligent transportation systems, and more specifically, to a real-time abnormal sub-trajectory detection method based on multi-level self-supervised learning. Background Technology
[0002] With the rapid proliferation of mobile devices and location technologies, hundreds of millions of trajectory data points are generated globally every day. These trajectory data contain a wealth of information about the activities of vehicles, pedestrians, and ships. Detecting anomalous patterns in these trajectories is crucial, supporting a variety of applications, such as managing potential risks to maritime traffic by detecting route deviations, ensuring air traffic safety by monitoring flight paths, and improving urban road safety and traffic efficiency by identifying accidents, congestion, and taxi fraud. Developing methods for detecting anomalous sub-trajectories and identifying these anomalies in a timely manner is essential for ensuring public safety, optimizing operations, and preventing potential threats.
[0003] The existing technology has the following main shortcomings: (1) It is difficult to locate fine-grained trajectory anomalies in real time: Anomalies are typically transient, occurring only within a small portion of the entire journey, making real-time capture of these localized anomalies invaluable. However, many methods can only determine whether the entire path is abnormal, failing to pinpoint the location of the deviation. These methods often encode the entire variable-length trajectory into a single, fixed-size latent vector, then use reconstruction errors or similarity differences to determine the overall trajectory's anomaly. This frequently overlooks these transient local anomalies, classifying the entire path as normal. These locally anomalous trajectories may contain information about traffic accidents, road congestion, road maintenance, taxi fraud, etc. Without a fine-grained, online localization method, traffic management departments or navigation systems will miss this crucial information, hindering timely adjustments and decisions, severely limiting their application value.
[0004] (2) Lack of a suitable evaluation system for the accuracy of abnormal sub-trajectory detection: Most existing anomaly sub-trajectory detection methods lack a rigorous evaluation system for positioning accuracy. Their evaluation methods typically rely on classifying the entire trajectory, failing to delve into the accuracy of local anomaly detection for a comprehensive and detailed assessment. For example, some methods determine whether an entire trajectory is anomaly simply by judging whether the proportion of detected anomaly sub-trajectories exceeds a manually set threshold. In this case, the model is considered correct as long as it successfully identifies a trajectory as anomaly, even if the specific anomaly location is completely incorrect. This approach fails to reflect the model's real-world application value and hinders meaningful comparisons between different models.
[0005] (3) Depends on prior information of the source-target (SD) point: Most existing methods require prior knowledge of the trajectory's source-end point information to compare the detected trajectory with normal trajectories sharing the same start and end points to identify anomalies. However, while effective in certain constrained scenarios, this paradigm is difficult to apply to a large number of real-world scenarios. This is because much real-world data (such as maritime surveillance tracks or ordinary vehicle tracking data) lacks such prior information on start and end points, severely impacting the practicality of these methods. A SD-independent anomaly detection model is better suited to the needs of realistic, unconstrained scenarios. This means the model must learn to distinguish between normal and anomalous behavior based solely on the trajectory's inherent patterns, rather than relying on external path comparisons. Summary of the Invention
[0006] The purpose of this invention is to provide a real-time abnormal sub-trajectory detection method based on multi-level self-supervised learning, which aims to solve the technical problems of existing abnormal sub-trajectory detection methods that heavily rely on source-target (SD) prior information, thus limiting their application scenarios, and making it difficult to achieve fine-grained real-time localization of local abnormal behaviors.
[0007] To solve the above problems, the technical solution adopted by the present invention is as follows: A real-time abnormal sub-trajectory detection method based on multi-level self-supervised learning includes: Obtain the original trajectory data of the moving object, which consists of a series of geospatial coordinate points arranged in time sequence; map the original trajectory data onto a two-dimensional grid to generate a discretized grid sequence; A multi-scale strategy is adopted to segment the grid sequence into multiple trajectory segments of different scales; a shared local encoder is used to generate a corresponding segment embedding vector for each trajectory segment, thereby obtaining multiple sets of segment embedding sequences at different scales; a hierarchical fusion mechanism is adopted to fuse the multiple sets of segment embedding sequences at different scales into a single fused embedding sequence containing context information. The segment embedding vectors corresponding to some segments in the fused embedding sequence are randomly masked; the embedding vectors of the masked segments are predicted by the context encoder using the unmasked segment embedding vectors to obtain the predicted embedding vectors; and the masked trajectory segments are reconstructed by the decoder based on the predicted embedding vectors to obtain the reconstructed trajectory segments. Calculate the reconstruction error between the reconstructed trajectory segment and the original trajectory segment corresponding to the segment, and use the reconstruction error as an anomaly score; compare the anomaly score with a preset anomaly threshold to determine whether the corresponding trajectory segment is an anomalous sub-trajectory.
[0008] Furthermore, the local encoder is a hybrid convolutional recurrent encoder (HCRE), which is specifically implemented by: mapping the grid ID sequence in the trajectory segment to word embedding vectors, extracting local spatial features through a one-dimensional convolutional neural network (1D CNN), capturing temporal dependencies based on the local spatial features through a bidirectional gated recurrent unit (Bi-GRU) network, and finally aggregating features through a max pooling layer and an average pooling layer to generate the segment embedding vector.
[0009] Furthermore, the multi-scale strategy includes three scales defined by different window sizes and step sizes: a coarse-grained scale for capturing macroscopic behavior of the overall trajectory, a medium-grained scale for capturing behavior dependencies over a medium time span, and a fine-grained scale for capturing instantaneous micro-motion patterns; the hierarchical fusion mechanism is a bottom-up fusion process, which specifically includes: First, the coarse-grained fragment embedding sequence is upsampled using linear interpolation to align its sequence length with that of the medium-grained fragment embedding sequence. Then, the upsampled coarse-grained fragment embedding sequence and the medium-grained fragment embedding sequence are spliced and fused to generate an intermediate fused embedding sequence. Next, the intermediate fused embedding sequence is upsampled again by linear interpolation to align its sequence length with the fragment embedding sequence at the fine-grained scale. Then, the upsampled intermediate fused embedding sequence is spliced and fused with the fine-grained fragment embedding sequence to generate a single fused embedding sequence.
[0010] Furthermore, the context encoder and decoder are used to execute a mask-based self-supervised learning strategy; the context encoder is a bidirectional gated recurrent unit (Bi-GRU) network, which processes the masked segment embedding sequence in both the forward and reverse directions to learn the global contextual relationships between trajectory segments, thereby generating the predicted embedding vector; the decoder is a unidirectional gated recurrent unit (GRU) network, which uses the predicted embedding vector as the initial hidden state and generates the reconstructed trajectory segment in parallel at once by processing a constant input sequence.
[0011] Furthermore, the model corresponding to the real-time abnormal sub-trajectory detection method adopts a dual training objective during the training phase, and is trained by minimizing a combined loss function. The combined loss function includes: embedding recovery loss, used to minimize the mean square error between the predicted embedding vector output by the context encoder and the original segment embedding vector generated by the local encoder; and segment reconstruction loss, used to minimize the cross-entropy between the reconstructed trajectory segment generated by the decoder and the original trajectory segment. The combined loss function is formed by weighted summation of the embedding recovery loss and the segment reconstruction loss.
[0012] Furthermore, the anomaly threshold is dynamically determined based on the reconstruction error distribution calculated by the model on the normal trajectory dataset. Specifically, the determination method includes calculating the mean of the reconstruction errors for all normal trajectory segments. μ and standard deviation σ And set the abnormal threshold to τ = μ + k · σ ,in k These are adjustable hyperparameters used to control the sensitivity of the decision boundary, thereby enabling the anomaly threshold to adapt to the error characteristics of different datasets.
[0013] Furthermore, when the real-time abnormal sub-trajectory detection method is applied to a continuous trajectory data stream, its specific implementation method includes: maintaining a first-in-first-out buffer queue to receive and temporarily store continuous trajectory points after discretization and deduplication; when the number of trajectory points temporarily stored in the buffer queue reaches a preset minimum detection length, all trajectory points in the buffer queue are moved into a detection queue, and then the buffer queue is cleared; the trajectory point sequence in the detection queue is segmented, and the abnormal score of all divisible trajectory segments is calculated in parallel; the state of a temporary observation area is updated according to whether the abnormal score of each trajectory segment exceeds the abnormal threshold; and based on the continuous abnormal judgment status recorded in the temporary observation area (e.g., the number of segments continuously judged as abnormal), the abnormal sub-trajectory containing abnormal trajectory points is finally determined and output.
[0014] Furthermore, when generating the discretized grid sequence, the continuous repeating sequence points in the grid sequence are deleted. The specific implementation method includes: traversing the grid sequence arranged in time sequence, and when it is detected that the current grid sequence point is the same as the grid ID identified by the immediately preceding grid sequence point, the current grid sequence point is removed from the sequence, thereby generating a grid sequence without continuous repeating points.
[0015] Furthermore, when determining whether a trajectory segment is an anomalous sub-trajectory, the calculation of the anomalous score adopts a leave-one-out reconstruction process, which specifically includes: for a specific trajectory segment to be scored, its corresponding segment embedding vector is temporarily masked in the fused embedding sequence, and then the context encoder uses the context information provided by all other unmasked segments to predict the embedding vector at the masked position, and finally reconstructs the trajectory segment based on the prediction and calculates the reconstruction error, thereby obtaining the anomalous score of the specific trajectory segment.
[0016] Furthermore, it also includes a fine-grained evaluation method for assessing the detection results, including: for a trajectory that is actually abnormal, calculating the intersection-over-union ratio (IoU) between the set of abnormal points predicted by the model and the set of actual abnormal points; when the IoU is greater than a preset threshold, it is recorded as a true positive example (TP), otherwise it is recorded as a false negative example (FN); for a trajectory that is actually normal, in order to avoid interference from subtle anomalies caused by GPS disturbances on human anomaly detection, when the proportion or absolute number of the set of abnormal points predicted by the model exceeds a preset dual threshold, it is recorded as a false positive example (FP), otherwise it is recorded as a true negative example (TN).
[0017] Compared with the prior art, the beneficial effects of the present invention are: (1) A self-supervised detection model independent of prior knowledge was constructed, achieving excellent detection performance in general scenarios that do not rely on source-target (SD) information. This invention employs a self-supervised learning paradigm based on fragment mask reconstruction, enabling the model to learn normal spatiotemporal behavior patterns solely from the intrinsic structure of the trajectory data itself, completely eliminating the dependence on prior information about source-target points. Validation on two large-scale real-world datasets shows that the average F1 score of this invention is 9.8% higher than the best existing model, demonstrating its superiority in general scenarios requiring high-precision positioning, such as real-time traffic monitoring and fraud detection.
[0018] (2) By employing multi-level feature representation and hierarchical fusion, the detection accuracy of fine-grained anomalies is significantly improved. This invention innovatively adopts a multi-scale strategy and hierarchical fusion mechanism, combined with a hybrid convolutional recurrent encoder, to capture the hierarchical features of the trajectory. This enables the simultaneous characterization of local behavioral deviations (such as detours) that rely on global path comparison for detection, as well as instantaneous motion pattern anomalies (such as sharp turns). This comprehensive feature representation capability allows this invention to more accurately locate and identify various local anomaly sub-trajectories, meeting the application requirements for real-time precise positioning.
[0019] (3) A highly efficient parallel computing architecture was designed, achieving low-latency online detection and demonstrating excellent practical value. This invention employs highly parallelizable CNN and GRU components, particularly the decoder, which uses a one-time generation strategy, avoiding the inefficiency of traditional sequence generation models. Combined with a first-in-first-out data stream processing queue, it enables online detection to be completed with extremely low latency. This balance between accuracy and efficiency makes this invention a practical solution that meets the needs of real-world scenarios.
[0020] (4) A novel fine-grained evaluation system is proposed, providing a fairer and more scientific performance comparison benchmark for research in this field. This invention introduces a fine-grained evaluation method based on Intersection over Union (IoU) and dual thresholds. This system pays more attention to the positioning accuracy of anomalous sub-trajectories, while effectively avoiding interference from subtle anomalies caused by GPS positioning disturbances to human anomaly detection through dual thresholds. This solves the problem that existing evaluation methods cannot accurately measure positioning accuracy, providing a fairer and more robust benchmark for performance comparison between different models in this field, and promoting the development of the technology.
[0021] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, embodiments of the present invention are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0022] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a schematic diagram of an abnormal sub-trajectory; Figure 2 This is a schematic diagram of the overall framework of the real-time abnormal sub-trajectory detection method based on multi-level self-supervised learning proposed in this invention; Figure 3 This is a flowchart of the online abnormal sub-trajectory detection algorithm proposed in this invention; Figure 4 This is a comparison chart of the trajectory detection efficiency test results of this invention and other models; Figure 5 This is a practical example of the invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.
[0025] Before elaborating on the invention in detail, the core terms involved in the invention are first defined as follows: (1) Trajectory Point: The trajectory point is the most basic element in trajectory data, defining the position of a moving object at a specific moment. A trajectory point can be represented as... ,in and They represent latitude and longitude, respectively. Represents a timestamp.
[0026] (2) Trajectory: A trajectory is a sequence of trajectory points arranged in chronological order, i.e. ,in n This represents the number of points in the trajectory. Each trajectory represents a path taken by a moving object in the physical world.
[0027] (3) Sub-trajectory: A sub-trajectory is a continuous segment of a trajectory, consisting of a series of trajectory points within a specific time period or interval extracted from the complete trajectory. Given the original trajectory its sub-trajectory S It can be represented as ,in .
[0028] (4) Abnormal sub-trajectories: such as Figure 1 As shown, taking a set of trajectories from the starting point S to the destination D as an example, if most of the trajectory follows a regular path (as shown in the blue part of the figure), while some sub-trajectories of a certain trajectory suddenly enter an atypical route (as shown in the red part of the figure), then that sub-trajectory is judged as abnormal.
[0029] (5) Real-time trajectory: A real-time trajectory is a continuous flow of trajectory points, which can be represented as ,in This is the latest recorded trajectory point.
[0030] (6) Definition of Online Anomaly Sub-Track Detection Problem: Given only one real-time track, this problem aims to find the local anomalies in the track.
[0031] The original latitude and longitude coordinates are continuous floating-point numbers, which can be complex to process directly and are sensitive to noise. We divide the space into a discrete two-dimensional grid, map these trajectory points into the grid, and replace the GPS coordinates of these trajectory points with their grid numbers, thus obtaining a new representation of the original trajectory, i.e. The core of this method lies in discretizing a continuous geographic space, assigning each grid a unique number as an identifier for that region. Directly using grid mapping instead of road network matching methods is applicable to various geographic environments, such as road network traffic and maritime traffic environments.
[0032] The Hi-ASD real-time anomaly sub-trajectory detection framework based on multi-level self-supervised learning, designed in this embodiment of the invention, is used to accurately and in real-time capture local anomaly segments in a trajectory by utilizing the temporal features of the trajectory, even without prior source-target point information. For example... Figure 2As shown, the framework mainly includes a multi-scale local encoder, a context encoder and decoder module, and a dual training module. Its core idea is to utilize the inherent sequence dependencies within a normal trajectory to reconstruct randomly masked trajectory segments by training a model. The following example of detecting local detour anomalies in a trajectory will be used to elaborate on the components of the Hi-ASD framework and their working principles. We will first introduce how the model learns normal patterns through training on normal trajectories, and then explain how the trained model uses this knowledge to detect anomalies such as "detours": (1) Multi-scale local encoder: responsible for extracting rich features from trajectory segments at different scales. First, we input the discrete grid number sequence into the multi-scale local encoder for processing. This module ensures that the model can simultaneously learn short-term, fine-grained motion patterns and long-term, more macroscopic behavioral context.
[0033] The local encoder operates at three different scales: fine-grained (S), medium-grained (M), and coarse-grained (L). Each scale is defined by a specific window size. w ) and step size ( s This is defined by ) and also determines how the trajectory is segmented: Fine-grained scale (S): It is used to capture minute motion patterns in real time.
[0034] Medium scale (M): It is used to capture behavioral dependencies over a medium time span.
[0035] Coarse-grained scale (L): It is used to capture the macroscopic behavior of the overall trajectory.
[0036] For each segment of the trajectory, We use a hybrid convolutional recurrent encoder (HCRE) shared across all scales to generate its fixed-dimensional vector representation. .
[0037] First, we will use the discrete grid cell ID sequence Mapped to a dense set of word embedding vectors HCRE uses a one-dimensional convolutional layer (1D CNN) to extract local spatial features, and then captures the full temporal dependencies through a bidirectional gated recurrent unit (Bi-GRU). Next, we aggregate the features by concatenating the results of max pooling and average pooling, and project them onto the final fragment embedding vector. middle: After obtaining three scales ( After embedding the fragment sequence, we employ a bottom-up hierarchical fusion mechanism. First, the coarse-grained (L) embedding sequence is upsampled using linear interpolation to align and fuse it with the medium-grained (M) sequence: Similarly, the fused medium-granularity embedding sequence is upsampled again and fused with the fine-granularity (S) embedding sequence to obtain the final output embedding sequence: This multi-scale process ensures the final fine-grained fragment representation. It can integrate global contextual information from a coarser-grained scale.
[0038] (2) Context encoding and decoding module: fused embedding sequence generated by multi-scale local encoder This will serve as input to our context encoding module. The goal of this module is to model global dependencies between trajectory segments and learn a robust representation of normal sub-trajectory patterns.
[0039] To achieve this, we randomly mask (e.g., 10%) a subset of the fragment embeddings. The fragment encoder then uses the surrounding unmasked fragments as context to recover these masked embeddings.
[0040] 1) Fragment Encoder: Our fragment encoder is also constructed using a Bi-GRU. It processes the entire masked fragment embedding sequence in both the forward and backward directions. The forward GRU captures historical context (how the trajectory arrived at the current segment), while the backward GRU captures future context (where the trajectory will go). The final linear layer projects the state back to the original embedding dimension, generating the recovered embedding sequence. This recovery process can be formalized as follows: The restored embedding corresponding to the masked position It will be passed to the fragment decoder for further reconstruction tasks.
[0041] 2) Fragment Decoder: The fragment decoder is a key component responsible for reconstructing the original grid cell ID sequence for the masked fragment. It receives the recovered embedding from the output of the context encoder. And decode it back into a grid ID sequence.
[0042] For each recovered fragment embedding It first uses a linear layer as the initial hidden state of the GRU. Then, the GRU network starts from this unique initial state. Given a pre-defined constant input sequence with a length consistent with the trajectory segment, process the input sequence. To generate the hidden state of the output. This non-autoregressive process improves computational efficiency by generating the entire sequence at once.
[0043] Finally, we obtain the final reconstructed grid cell ID sequence. .
[0044] (3) Dual training objectives: The model is trained by minimizing a combined loss function, which consists of two parts: high-level embedding recovery and low-level trajectory reconstruction. 1) Embedding recovery loss ( ): Embedded in the original fragment (From a multi-scale local encoder) and the recovered embedding Calculate the mean squared error (MSE) loss between them.
[0045] 2) Fragment reconstruction loss ( ): in the sequence reconstructed by the decoder and the real grid cell ID sequence of the masked fragment Calculate the cross-entropy loss between them.
[0046] The ultimate training objective is the weighted sum of these two losses: in and It is a hyperparameter that controls the weights of each loss component.
[0047] The above is the complete process of model training. Now, we will take the detection of abnormal sub-trajectories of a trajectory as an example to illustrate how to use this model.
[0048] The underlying logic of the model's anomaly detection is that normal trajectory segments are context-predictable and can be accurately reconstructed from their surrounding segments. Conversely, anomalous segments that deviate from the learned normal patterns are difficult to reconstruct well from their context, leading to significantly higher reconstruction errors. To detect anomalies in the trajectory under test, a threshold for defining anomalies must first be determined, and then anomalies are detected based on this threshold. (1) Context reconstruction and anomaly scoring: First, the trajectories in all the given training sets are input into the multi-scale local encoder module to obtain a segment embedding sequence. The outlier score for each segment is determined through a leave-one-out reconstruction process. This is to assign an outlier score to a specific segment. Rating, and its corresponding embedding The vector is temporarily masked (i.e., replaced with a zero vector). The entire modified embedding sequence is then processed by the model's context encoder, which uses the context provided by all other unmasked segments to predict the embedding at the masked location. This predicted embedding It is then passed to the decoder to generate a reconstructed sequence of symbols. The final anomaly score for this segment is its context reconstruction loss. .
[0049] (2) Threshold determination: A threshold is determined by analyzing the reconstruction loss distribution obtained on the normal training trajectory set. Specifically, we calculate the reconstruction loss for each segment in the training set using a Gaussian distribution-based method. We calculate the mean of all collected reconstruction scores ( ) and standard deviation ( Abnormal threshold It was then set at the distance from the mean. Location of one standard deviation: hyperparameters It controls the sensitivity of decision-making boundaries.
[0050] (3) Anomaly detection: For a segment in a new trajectory If its reconstruction loss exceeds the determined threshold If it does, it will be marked as an exception.
[0051] After understanding the entire logic of anomaly detection, this invention designs an online anomaly sub-trajectory detection algorithm, the main idea of which is as follows: Figure 3 As shown, this algorithm can handle continuous data streams input in the form of a queue. Anomaly detection begins when the queue size reaches a certain level. We also designed a delayed decision-making strategy: if a segment is detected as an anomaly, it is first placed in the "observation zone". Only when its score exceeds the threshold multiple times consecutively in subsequent periods will it be formally confirmed and added to the final anomaly set.
[0052] Since simple, trajectory-level binary metrics are insufficient to evaluate the positioning accuracy of sub-trajectories, this invention also proposes a fine-grained evaluation framework designed to address this issue, aiming to measure positioning accuracy while maintaining robustness to small prediction noise (GPS perturbations).
[0053] First, for a given trajectory containing anomalies... We define two point sets: Trajectory The set of all real outliers in the dataset.
[0054] Trajectory The set of all points that the model predicts to be anomalous.
[0055] We use the intersection-to-union ratio (IoU) to measure positioning accuracy: True Positive (TP): The detection was classified as a true case, meaning that the model not only successfully identified the anomalous trajectory but also located the anomaly with sufficient precision.
[0056] False Negative (FN): This detection is recorded as a false negative. This indicates that the model failed to detect the anomaly at all, or its localization was not accurate enough.
[0057] These rules can be converted into the following formulas: Second, for a completely normal trajectory (i.e., there are no real anomalies, therefore...) ,in (where represents the empty set), according to formula (1), the calculated IoU result will always be 0 regardless of the predicted anomaly ratio. In order to robustly evaluate the model's performance on normal trajectories (while filtering out irrelevant noise and avoiding missed detections), we introduce a dual threshold criterion: a prediction on a normal trajectory is classified as a false positive (FP) if it violates any of the following conditions; otherwise, it is considered a true negative (TN), meaning that the model has effectively filtered out irrelevant minor alarms.
[0058] 1) The predicted proportion of outliers meets the following requirements. 2) The absolute number of predicted outliers satisfies Third, we use formula (2) to calculate the final performance index: Where P represents precision, R represents recall, and F1 represents the F1 score.
[0059] Our experiments were conducted on two large-scale real-world taxi trajectory datasets: Chengdu and Xi'an, both of which were provided by Didi Chuxing.
[0060] First, we map the trajectory to In the grid, each GPS point is converted into a corresponding grid cell ID. Then, consecutive duplicate grid IDs are removed to ensure that our model focuses on the dynamic changes of the trajectory. To ensure data quality, we filtered the trajectories in the Chengdu dataset by length, retaining only those between 40 and 270; for the Xi'an dataset, we retained those between 35 and 270. Detailed statistics for the two datasets after preprocessing are shown in Table 1.
[0061] Table 1. Dataset information after preprocessing For anomalous data, we followed most conventional methods, creating anomalous trajectories manually. We set two hyperparameters. and . This represents the proportion of outlier segments in a trajectory, while This represents the number of grid cells that deviate from the normal path in this abnormal segment. We also set an observation scale. This represents the proportion of the observed trajectory length to the total length, used to simulate online detection scenarios. For example, setting... This indicates that the anomalous segment accounts for 30% of the total trajectory, the anomalous part deviates from 4 grid cells, and we perform anomaly detection when the first 60% of the trajectory length has been observed.
[0062] We compared the method of this invention with five baseline models: (1) IBOAT: A metric-based method that detects anomalous trajectories by measuring the difficulty of isolating them from normal trajectories that have the same start and end points (SD).
[0063] (2) GM-VSAE: A deep generative model that uses Gaussian mixture variational sequence autoencoder to model complex normal paths and adopts the "generative detection" paradigm for online abnormal trajectory detection.
[0064] (3) DeCoRTAD: A conditional representation learning method based on a diffusion model for real-time detection. It utilizes two encoders and their respective sliding windows to capture historical and current trajectory information.
[0065] (4) VAE: A variational sequence autoencoder that uses a single Gaussian distribution to model the underlying distribution of the entire trajectory.
[0066] (5) SAE: A traditional Seq2Seq model based on LSTM. We use it to reconstruct the behavior of normal trajectory sequences and use the reconstruction error to detect anomalies.
[0067] To verify the effectiveness of key components in the Hi-ASD model, we designed and evaluated several ablation versions: (1) Hi-ASD w / o MS: This variant aims to evaluate the contribution of the multi-scale feature fusion mechanism of this invention. We disabled the medium-scale (M) and large-scale (L) encoding paths. Compared with the full model, its overall F1 score decreased by about 5.6%, which verifies the effectiveness of fusing multi-scale contextual information.
[0068] (2) Hi-ASD w / o Context: This variant aims to verify the functionality of the context-based recovery paradigm of this invention. We completely removed the masking mechanism and the Bi-GRU context encoder. Its overall F1 score decreased by approximately 3.4%, demonstrating the necessity of learning the relationships between segments relative to modeling each trajectory segment in isolation.
[0069] The experimental results on the Chengdu dataset are shown in Table 2. This represents the proportion of outlier segments in a trajectory; This represents the number of grid cells that deviate from the normal path in this abnormal segment.
[0070] Table 2 F1 scores on the Chengdu dataset The experimental data on the Xi'an dataset are shown in Table 3.
[0071] Table 3 F1 scores on the Xi'an dataset As shown in Tables 1 and 2, we can draw the following conclusions: (1) Overall performance: Under all experimental configurations, the proposed model Hi-ASD exhibits strong performance. On average, it outperforms the best baseline GM-VSAE by approximately 17.4% on the Chengdu dataset and by 3.0% on the Xi'an dataset in terms of F1 score. These findings demonstrate that our method is robust and generalizable in different urban scenarios.
[0072] (2) Effects of offline trajectory analysis: On fully observed trajectories ( When evaluated (representing an offline analysis scenario), Hi-ASD outperformed the best model, SAE, achieving relative F1 score improvements of 9.1% and 5.3% on the Chengdu and Xi'an datasets, respectively. This result validates the effectiveness of our multi-level framework in capturing the complete structure of trajectories.
[0073] (3) Robustness in online detection scenarios: When only 40% of the trajectories are observed ( At this stage, our model already achieved an average F1 score of 0.89 on both datasets. This early-stage performance surpasses the best baseline (GM-VSAE) with complete trajectory information. When the observation ratio increases to 70% ( When the performance gap widens further, Hi-ASD's F1 score surpasses GM-VSAE and DeCoRTAD by 15.6% and 47.1%, respectively. On the Xi'an dataset, Hi-ASD outperforms VSAE and GM-VSAE by 29.3% and 1.8%, respectively. These findings demonstrate that our model possesses accurate and early detection capabilities, a crucial requirement for real-time applications.
[0074] In addition, we conducted a detection efficiency test on multiple models using a single 32 GB vGPU. For example... Figure 4 As shown, Hi-ASD demonstrates superior detection efficiency. It achieves an average latency of only 5.2ms per trajectory on both datasets. In contrast, deep generative models like GM-VSAE and DeCoRTAD are significantly slower due to their complex sampling processes (latencies ranging from 63.6ms to 96.1ms). Furthermore, Hi-ASD outperforms reconstruction-based methods like SAE and VSAE. This high efficiency stems from its highly parallelizable CNN and GRU-based architecture, which achieves fast forward propagation by avoiding the overhead of complex generative models or database lookups. This demonstrates that Hi-ASD is a practical solution applicable to real-world scenarios.
[0075] at last Figure 5This is a visualization example of the present invention in actual abnormal sub-trajectory detection. We visualize the anomaly detection results of four randomly selected SD trajectories from the Chengdu dataset. All trajectories shown here are real data, not experimentally generated examples. The green parts represent normal trajectories detected by the model, and the red segments represent abnormal sub-trajectories detected by the model. Through these four examples, it can be seen that Hi-ASD can effectively detect multiple local abnormal segments in a trajectory, and whether it is a small deviation or a large detour, it can be accurately identified by the model, indicating that the present invention has excellent practical value.
[0076] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. 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 protection of the present invention.
Claims
1. A real-time abnormal sub-trajectory detection method based on multi-level self-supervised learning, characterized in that, The method comprises: obtaining original trajectory data of a moving object, the original trajectory data being composed of a series of geospatial coordinate points arranged in time sequence; mapping the original trajectory data into a two-dimensional grid to generate a discretized grid sequence; adopting a multi-scale strategy to segment the grid sequence into a plurality of trajectory segments of different scales; generating a corresponding segment embedding vector for each trajectory segment through a shared local encoder, thereby obtaining a plurality of segment embedding sequences of different scales; adopting a hierarchical fusion mechanism to fuse the plurality of segment embedding sequences of different scales into a single fusion embedding sequence containing context information; randomly masking the segment embedding vectors corresponding to part of the segments in the fusion embedding sequence; predicting the embedding vectors of the masked segments by using the unmasked segment embedding vectors through a context encoder, thereby obtaining predicted embedding vectors; reconstructing the masked trajectory segments according to the predicted embedding vectors through a decoder, thereby obtaining reconstructed trajectory segments; calculating the reconstruction error between the reconstructed trajectory segments and the original trajectory segments corresponding to the segments, and taking the reconstruction error as an anomaly score; comparing the anomaly score with a preset anomaly threshold to determine whether the corresponding trajectory segment is an abnormal sub-trajectory.
2. The method of claim 1, wherein, The local encoder is a hybrid convolutional recurrent encoder, and its specific implementation manner comprises: mapping the grid ID sequence in the trajectory segment into a word embedding vector, extracting local spatial features through a one-dimensional convolutional neural network, capturing time dependence on the basis of the local spatial features through a bidirectional gated recurrent unit network, and finally aggregating features through a max-pooling layer and an average-pooling layer to generate the segment embedding vector.
3. The method of claim 1, wherein, The multi-scale strategy comprises three scales defined by different window sizes and steps, namely a coarse-grained scale for capturing macro behaviors of the overall trajectory, a medium-grained scale for capturing behavior dependence within a medium time span, and a fine-grained scale for capturing immediate micro motion patterns; and the hierarchical fusion mechanism is a bottom-up fusion process, which specifically comprises: first, up-sampling the segment embedding sequence under the coarse-grained scale through linear interpolation to align it with the segment embedding sequence under the medium-grained scale in sequence length, and then splicing and fusing the up-sampled coarse-grained segment embedding sequence with the medium-grained segment embedding sequence to generate an intermediate fusion embedding sequence; second, up-sampling the intermediate fusion embedding sequence again through linear interpolation to align it with the segment embedding sequence under the fine-grained scale in sequence length, and then splicing and fusing the up-sampled intermediate fusion embedding sequence with the fine-grained segment embedding sequence, thereby generating a single fusion embedding sequence.
4. The method of claim 1, wherein, The context encoder and decoder are used to perform a mask-based self-supervised learning strategy; the context encoder is a bidirectional gated recurrent unit network which processes the masked segment embedding sequence in both forward and backward directions to learn the global context relationship between trajectory segments, thereby generating the predicted embedding vector; the decoder is a unidirectional gated recurrent unit network which generates the reconstructed trajectory segment in parallel at one time by processing a constant input sequence with the predicted embedding vector as the initial hidden state.
5. The method of claim 1, wherein, The model corresponding to the real-time abnormal sub-trajectory detection method adopts a double training target in the training stage and is trained by minimizing a combined loss function; the combined loss function includes: an embedding recovery loss for minimizing the mean square error between the predicted embedding vector output by the context encoder and the original segment embedding vector generated by the local encoder; a segment reconstruction loss for minimizing the cross entropy between the reconstructed trajectory segment generated by the decoder and the original trajectory segment; the combined loss function is constituted by weighted summation of the embedding recovery loss and the segment reconstruction loss.
6. The method of real-time abnormal sub-trajectory detection according to claim 5, wherein, The abnormal threshold is dynamically determined based on a reconstruction error distribution of the model calculated on a normal trajectory dataset, and the specific determination manner comprises: calculating a mean value of reconstruction errors of all normal trajectory segments μ and a standard deviation σ , and setting the abnormal threshold as τ = μ + k · σ , wherein k is an adjustable hyperparameter for controlling the sensitivity of the decision boundary, so that the abnormal threshold can be adapted to the error characteristics of different datasets.
7. The method of real-time abnormal sub-trajectory detection of claim 1, wherein, When the real-time abnormal sub-trajectory detection method is applied to continuous trajectory data stream, the specific implementation method includes: maintaining a first-in-first-out buffer queue for receiving and temporarily storing the continuous trajectory points after discretization and deduplication processing; when the number of trajectory points temporarily stored in the buffer queue reaches a preset minimum detection length, moving all the trajectory points in the buffer queue into a detection queue, and then emptying the buffer queue; segmenting the trajectory point sequence in the detection queue and calculating the anomaly scores of all divisible trajectory segments in parallel; updating the state of a temporary observation area according to whether the anomaly scores of each trajectory segment exceed the anomaly threshold; and finally determining and outputting the abnormal sub-trajectory containing abnormal trajectory points according to the continuous abnormal determination state recorded in the temporary observation area.
8. The method of real-time abnormal sub-trajectory detection of claim 1, wherein, When generating the discretized grid sequence, the continuous repeated sequence points in the grid sequence are deleted, and the specific implementation method includes: traversing the grid sequence arranged in time sequence, and when it is detected that the current grid sequence point and the immediately preceding grid sequence point identify the same grid ID, the current grid sequence point is removed from the sequence, thereby generating a grid sequence without continuous repeated points.
9. The method of real-time abnormal sub-trajectory detection according to claim 1, wherein, When determining whether a trajectory segment is an abnormal sub-trajectory, the calculation of the anomaly score adopts a leave-one-out type reconstruction process, which specifically includes: for a specific trajectory segment to be scored, temporarily masking the segment embedding vector corresponding to the specific trajectory segment in the fusion embedding sequence, and then using the context information provided by all other unmasked segments to predict the embedding vector at the masked position by the context encoder, and finally reconstructing the trajectory segment based on the prediction and calculating the reconstruction error, thereby obtaining the anomaly score of the specific trajectory segment.
10. The method of real-time abnormal sub-trajectory detection of claim 1, wherein, The application also provides a fine-grained evaluation method for evaluating the detection result, comprising: for a real abnormal trajectory, calculating an intersection-union ratio between the model-predicted abnormal point set and the real abnormal point set, and recording as a true positive example when the intersection-union ratio is greater than a preset threshold, or recording as a false negative example otherwise; and for a real normal trajectory, recording as a false positive example when the proportion or absolute quantity of the model-predicted abnormal point set exceeds a preset double threshold, or recording as a true negative example otherwise.
Citation Information
Patent Citations
Integrated learning network traffic prediction method, system, device, terminal and medium
CN113905391A
Diversity problem automatic generation method based on Transform problem keyword prediction
CN116050401A
Short text similarity determination method and device and terminal
CN117076946A
Trajectory abnormal route detection method and system based on self-supervised trajectory representation learning
CN120724351A