A joint recognition method of driving style and traffic density based on Transformer-GNN
Through the joint recognition method of Transformer-GNN, the problem of separation between driving style and traffic density is solved, and high-precision driving style recognition and traffic density prediction are achieved in complex traffic environments, which improves the adaptability and robustness of the model.
Patent Information
- Application Number
- CN202511056712.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2045-07-30
AI Technical Summary
Existing technologies make it difficult to simultaneously consider the interactive mechanism between driving style and traffic density in intelligent traffic and driving behavior analysis, resulting in a separation between driving style recognition and traffic flow modeling, a lack of a unified framework, and traditional methods are difficult to adapt to complex and changing driving behaviors.
A Transformer-GNN-based method is used to obtain vehicle driving status and environmental perception data, and use the Transformer behavior sequence encoder and graph neural network to construct a dynamic traffic map. This method jointly identifies driving style and traffic density, and combines self-supervised pre-training and multi-task learning strategies to achieve driving style classification, traffic density prediction, and safety risk prediction.
The model's ability to recognize complex scenarios has been improved, and the accuracy and robustness of the joint identification of driving style and traffic density have been enhanced. It can accurately identify driving style and predict traffic efficiency and safety under different traffic densities, and adapt to various traffic environments.
Smart Images

Figure CN120561874B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent transportation and driving behavior analysis, and in particular to a driving style and traffic density joint recognition method based on Transformer-GNN. Background Art
[0002] Driving style refers to the behavioral patterns exhibited by different drivers in vehicle control and traffic decision-making, which has a profound impact on traffic flow efficiency and road safety. For example, conservative driving tends to maintain a large following distance and slow speed fluctuations, while aggressive driving is characterized by frequent lane changes and sudden acceleration / deceleration. Furthermore, traffic density, a key parameter characterizing traffic flow conditions, influences vehicle interaction intensity and driving stability. When traffic density increases, inter-vehicle distances decrease, driving decision-making pressure increases, and accident risk may increase. Conversely, under low-density conditions, some drivers may become more aggressive due to the availability of empty roads, leading to a trade-off between efficiency and safety. Numerous studies have demonstrated a complex coupling relationship between driving style and traffic density: driving style influences driving behavior under different density conditions, while changes in traffic density also modulate drivers' behavioral choices. Therefore, in-depth research on the interaction between these two factors is of great theoretical and practical value for improving traffic efficiency and ensuring safety.
[0003] In recent years, with the development of intelligent driving and connected vehicle technologies, the acquisition of massive amounts of traffic behavior data has become possible, providing a foundation for data-driven approaches to identifying driving styles and modeling traffic density effects. Traditionally, researchers have used rule-based and statistical analysis methods to characterize driving styles, applying thresholds or scoring to vehicle operating parameters (such as speed, acceleration, and steering angle). However, such methods struggle to adapt to complex and changing driving behaviors. Subsequently, machine learning techniques, such as support vector machines, random forests, and XGBoost models, have been introduced for driving style classification, enabling preliminary automatic identification of conservative, moderate, and aggressive styles. For example, Zhao et al. combined principal component analysis and clustering methods to propose a multi-level driving style recognition algorithm that considers the influence of traffic density. They used a random forest classifier to achieve high-precision recognition, maintaining good accuracy across different density levels. Furthermore, Wang et al. employed a multi-task long short-term memory network to identify driving styles, achieving classification accuracy exceeding 95% in complex traffic scenarios. While these works demonstrate the effectiveness of data-driven approaches, they still have some limitations. On the one hand, most existing methods separate driving style recognition and traffic flow modeling, lacking a unified framework to simultaneously consider driver behavior and traffic environment factors; on the other hand, emerging technologies such as Transformer, graph neural network (GNN), and self-supervised learning that have emerged in recent years have not been fully applied to this field to further enhance the model's ability to capture long-term temporal dependencies, represent heterogeneous vehicle interactions, and learn features with limited labeled data.
[0004] In the fields of intelligent transportation and driving behavior analysis, a large number of studies have emerged in recent years on driving style recognition and traffic flow modeling. Driving style recognition, the area of focus in this paper, typically involves automatically classifying driving behaviors into several categories (e.g., conservative, moderate, aggressive) based on vehicle kinematic data or driving maneuver data. Early approaches relied on manually defined rules or statistical thresholds to identify risky driving behaviors. For example, these approaches assessed driving style by measuring the frequency of speeding, sudden braking, and sharp turns. However, these approaches struggled to fully characterize driving style differences across continuous driving. With the advancement of machine learning, supervised learning methods have become widely used for driving style classification. Classic algorithms include support vector machines, decision trees, and ensemble learning methods. These methods achieve a certain degree of automatic classification accuracy by learning a mapping between features such as vehicle speed, acceleration, and following distance and driving style categories. However, traditional machine learning models have limited ability to characterize high-dimensional, nonlinear time series data, often requiring manual feature design and failing to fully utilize continuous time series information. Summary of the Invention
[0005] Aiming at the limitation of the existing separation between driving style recognition and traffic density modeling, the present invention provides a driving style and traffic density joint recognition method based on Transformer-GNN.
[0006] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is:
[0007] A Transformer-GNN-based driving style and traffic density joint recognition method includes the following steps:
[0008] Acquire vehicle driving status data and environmental perception data;
[0009] Extract features from vehicle driving status data and environmental perception data to obtain driving behavior sequence features and vehicle environment features;
[0010] A Transformer-based behavior sequence encoder is used to encode and model driving behavior sequence features, obtaining a latent state behavior representation that includes global time-dependent information. A graph neural network-based traffic interaction model is also used to construct a dynamic traffic map based on vehicle environment characteristics, capturing spatial interaction features between vehicles.
[0011] The latent state behavior representation containing global time-dependent information and the spatial interaction features between vehicles are fused, and multi-task output results including driving style recognition and traffic density prediction are generated based on the fused features.
[0012] Furthermore, the vehicle driving state data includes driving behavior time series parameters and corresponding index parameters;
[0013] Environmental perception data includes traffic environment parameters and traffic flow parameters.
[0014] Furthermore, a Transformer-based behavior sequence encoder is used to encode and model the driving behavior sequence features to obtain a latent state behavior representation containing global time-dependent information, including:
[0015] The driving behavior sequence features are positionally encoded and input mapped, and then input into several layers of Transformer encoders. In each layer of Transformer encoders, the multi-head self-attention weights between each time step in the sequence are calculated through a multi-head self-attention mechanism. Finally, after residual, layer normalization and feedforward network, a latent state representation containing global time-dependent information is obtained.
[0016] Furthermore, a traffic interaction model based on a graph neural network is used to construct a dynamic traffic map based on the vehicle environment characteristics, and obtain the spatial interaction characteristics between vehicles, including:
[0017] Construct dynamic traffic maps based on vehicle environment characteristics;
[0018] The local traffic density is used as the global feature of the graph, and the graph attention is updated through graph convolution or graph attention network;
[0019] After cyclic iteration, the spatial interaction features between vehicles are obtained.
[0020] Furthermore, constructing a dynamic traffic map based on vehicle environment characteristics includes:
[0021] The vehicle to be identified is regarded as the target node, and the adjacent vehicles within the set range are regarded as neighbor nodes. Edge connections are established based on relative distance and lane relationship; the initial features of each node are vehicle environment features.
[0022] Furthermore, the local traffic density is used as the global feature of the graph, and graph attention is updated through graph convolution or graph attention network. Specifically:
[0023]
[0024] in, For the Nodes in a layered graph neural network For adjacent nodes 's attention relevance score; is the activation function, is the attention vector, T is the transpose, is the learnable weight matrix, 、 Node Its neighboring nodes In the Node representation in layer graph neural networks, is the local traffic density, is the attention weight after softmax normalization, For nodes The set of adjacent nodes, k is the number of nodes traversed in the normalization operation Index variables of all adjacent nodes.
[0025] Furthermore, the model training adopts a staged training strategy. First, self-supervised pre-training is performed to optimize mask reconstruction and contrast learning objectives based on unlabeled driving data to obtain the initial model parameters. Then, supervised fine-tuning training is performed using labeled data. At the same time, a multi-task learning strategy is adopted to conduct multi-task joint training on driving style classification, traffic density estimation, and safety risk prediction.
[0026] Furthermore, mask reconstruction includes:
[0027] Randomly mask the scaled time step features and minimize the objective function:
[0028]
[0029] in, is the mask reconstruction loss function, is the reconstructed feature matrix, is the original feature matrix.
[0030] Furthermore, contrastive learning includes:
[0031] Calculate the NT-Xent loss for two data augmented views of the same driving clip and from different driving clips:
[0032]
[0033] in, is the contrastive learning loss, is the cosine similarity between the data augmentation view v and the data augmentation view v', is the temperature coefficient, is the cosine similarity between the data augmentation view v and the driving segment u.
[0034] Furthermore, the loss function used in model training is:
[0035]
[0036] in, is the total loss function, is the driving style cross entropy, For traffic efficiency, is the logarithmic loss of the binary classification of security risk, is the traffic efficiency loss weight coefficient, is the safety risk loss weight coefficient.
[0037] The present invention has the following beneficial effects:
[0038] The present invention adopts a multi-module collaborative approach, using parallel sub-networks to extract driver operation behavior characteristics and traffic environment characteristics respectively, and then realizes the interactive coupling modeling of the two through a fusion layer. This unified framework can simultaneously capture the relationship between micro-driving behavior and macro-traffic status, improve the model's ability to recognize complex scenarios, and enhance the accuracy and robustness of the joint identification of driving style and traffic density. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 A flowchart of a Transformer-GNN-based driving style and traffic density joint recognition method;
[0040] Figure 2This is the overall framework diagram of a Transformer-GNN-based driving style and traffic density joint recognition method;
[0041] Figure 3 This is a comparison chart of accuracy in different density scenarios;
[0042] Figure 4 This is a diagram of robustness analysis under noise disturbance;
[0043] Figure 5 This is an analysis diagram of the representation mode of the model's attention mechanism under different driving styles and traffic scenarios;
[0044] Figure 6 Heatmap of collision risk under different combinations of driving styles and traffic density. DETAILED DESCRIPTION
[0045] The specific embodiments of the present invention are described below to facilitate understanding of the present invention by those skilled in the art. However, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the appended claims, these changes are obvious, and all inventions and creations utilizing the concepts of the present invention are protected.
[0046] like Figure 1 and Figure 2 As shown, an embodiment of the present invention provides a driving style and traffic density joint recognition method based on Transformer-GNN, including the following steps S1 to S4:
[0047] S1. Acquire vehicle driving status data and environmental perception data;
[0048] In an optional embodiment of the present invention, the data acquired in step S1 includes two categories: the vehicle's own driving state data and environmental perception data: (1) driving behavior data, such as time-varying time series signals of vehicle speed, acceleration, steering angle, pedal position, and the like, and derived features calculated therefrom (speed fluctuation, acceleration distribution, following vehicle distance, headway, etc.); and (2) traffic environment data, including traffic density within a certain range around the vehicle, the relative positions and speeds of adjacent vehicles, lane characteristics, and more macroscopic traffic flow parameters (such as the average speed or congestion index of the current road section). These data can be acquired through vehicle sensors, V2X communication, and road monitoring systems.
[0049] S2. Extract features from the vehicle driving state data and the environmental perception data to obtain driving behavior sequence features and vehicle environment features;
[0050] In an optional embodiment of the present invention, step S2 pre-processes and performs feature engineering on the raw data at the feature extraction layer. For vehicle trajectory and sensor time series data, the study first performs data cleaning and smoothing (for example, using a Kalman filter to reduce measurement noise), and then extracts statistical features and physical meaning features. For example, in terms of driving behavior, the average speed, speed standard deviation, acceleration mean, acceleration extreme value, number of brakes, and following distance mean are extracted. In terms of traffic environment, indicators such as local traffic density, average vehicle speed difference, and relative distance within the current spatiotemporal window are calculated. In addition, the study normalizes and reduces the dimensionality of some features (such as using principal component analysis to extract comprehensive features) to reduce data dimension and correlation redundancy. The feature sequence obtained in this step will be sent to the subsequent driving behavior recognition module and traffic density modeling module respectively.
[0051] S3: A Transformer-based behavior sequence encoder is used to encode and model driving behavior sequence features to obtain a latent state behavior representation containing global time-dependent information. A graph neural network-based traffic interaction model is also used to construct a dynamic traffic map based on vehicle environment characteristics to obtain spatial interaction features between vehicles.
[0052] In an optional embodiment of the present invention, step S3 of the driving behavior recognition module employs a Transformer-based temporal neural network to encode and model driving behavior sequence features. Compared to traditional RNNs, Transformers can better capture long-range dependencies and process sequences in parallel. The study feeds the preprocessed driving behavior feature sequence into several layers of Transformer encoders. Each layer uses a multi-head self-attention mechanism to calculate the correlation weights between each time step in the sequence, thereby obtaining a latent state representation that incorporates global temporal dependency information. Simultaneously, the traffic density modeling module uses a graph neural network to characterize the interaction between vehicles and surrounding traffic. The study constructs a dynamic traffic graph: the target vehicle is regarded as the target node, and neighboring vehicles within a certain range are considered neighbor nodes. Edge connections are established in the graph based on relative distance and lane relationships. Graph convolution (GCN) or graph attention network (GAT) is then used to iteratively update the node representation, so that the target vehicle node's representation incorporates the influence of neighboring vehicles. Notably, the study incorporates the global feature of traffic density into the graph network: local traffic density is treated as a global attribute of the graph, influencing the weight of message passing at each layer. This fusion approach enables the model to adjust the importance of vehicle-to-vehicle interactions based on the current traffic density, simulating strong interactions caused by tight vehicle spacing at high density and relative independence of vehicles at low density.
[0053] This embodiment uses a Transformer-based behavior sequence encoder to encode and model driving behavior sequence features to obtain a latent state behavior representation containing global time-dependent information, including:
[0054] Set in the sampling period The driving behavior sequence extracted from the .
[0055] ,
[0056] in, For the moment The extracted multi-dimensional behavioral feature vector.
[0057] Perform position encoding and input mapping on the driving behavior sequence features, expressed as:
[0058]
[0059] in, is the sine-cosine position encoding; it is unified to dimension by linear layer .
[0060] Then, several layers of Transformer encoders are input. In each layer, the Transformer encoder calculates the multi-head self-attention weights between each time step in the sequence through the multi-head self-attention mechanism. Suppose the output of the previous layer is:
[0061]
[0062] First, we can obtain the following linear mapping:
[0063]
[0064] Then calculate the attention:
[0065]
[0066] Then based on the multi-head mechanism, the process is executed Second cascade:
[0067]
[0068] Finally, after residual, layer normalization and feedforward network, the hidden state representation containing global time dependency information is obtained, which is expressed as:
[0069]
[0070]
[0071] Transformer's self-attention can capture long-range dependencies in one forward propagation and can identify style signals such as "continuous subtle fluctuations" or "periodic acceleration and deceleration". However, the attention complexity is In actual deployment, Control it between 64 and 128, and downsample the high-frequency signal to ensure a single sequence Inference latency.
[0072] This embodiment uses a traffic interaction model based on a graph neural network to construct a dynamic traffic map based on vehicle environment characteristics. It depicts the dynamic impact of the target vehicle and surrounding vehicles under different traffic densities, thereby obtaining spatial interaction characteristics between vehicles, including:
[0073] Construct a dynamic traffic graph based on the vehicle environment characteristics, which is expressed as:
[0074]
[0075] in, For the target vehicle, if the distance or lane position between the two vehicles meets the threshold, an undirected edge is connected between them. The initial features of each node include relative distance, relative speed, absolute speed and acceleration.
[0076] The local traffic density is used as the global feature of the graph, and the graph attention is updated through graph convolution or graph attention network; for nodes and its neighbors :
[0077]
[0078] in, For the In a layer graph neural network, nodes For adjacent nodes 's attention relevance score; is the activation function, is the attention vector, T is the transpose, is the learnable weight matrix, , Represents nodes respectively Its neighboring nodes In the Node representation in layer graph neural networks. is the local traffic density, is the attention weight after softmax normalization, which reflects the Nodes in layer networks For Node Characterizes the impact of the update, For nodes The set of adjacent nodes, that is, the target node neighbors participating in the current attention aggregation, k is the number of nodes traversed in the normalization operation Index variables of all neighboring nodes, used to normalize attention scores .
[0079] go through Layer loop iteration is performed to obtain the spatial interaction features between vehicles, which can be expressed as:
[0080] .
[0081] This embodiment improves the spatiotemporal feature extraction capability by introducing Transformer and graph neural network. In view of the fact that driving behavior sequence data has long-term correlation, this embodiment integrates a Transformer-based temporal coding module in the framework, and uses the self-attention mechanism to efficiently extract long-term temporal dependencies. At the same time, in order to model the mutual influence between vehicles in high-density traffic scenarios, this embodiment designs a vehicle interaction graph neural network module, which regards neighboring vehicles as graph nodes and captures the spatial interaction features between vehicles through graph convolution / attention mechanism. Transformer provides global feature extraction capabilities, while the GNN module introduces neighbor interaction constraints. The combination of the two enables the model to maintain high recognition accuracy and stability in complex traffic environments. Compared with methods that only use sequence models such as LSTM, this embodiment has obvious advantages in extracting long-sequence dependencies and characterizing multi-vehicle interaction relationships.
[0082] S4. Feature fusion is performed on the latent state behavior representation containing global time-dependent information and the spatial interaction features between vehicles, and multi-task output results including driving style recognition and traffic density prediction are generated based on the fused features.
[0083] In an optional embodiment of the present invention, the behavior recognition module and the density modeling module each generate a high-dimensional representation vector for the target vehicle. The former focuses on characterizing the vehicle's own behavior pattern, while the latter focuses on reflecting the traffic environment in which it finds itself. In step S4, these two vectors are fused through a decision fusion layer. Strategies such as vector-level concatenation, weighted addition, and attention-based fusion have been explored. The fused comprehensive features are then passed through a fully connected neural network to output the final driving style recognition result. Simultaneously, the fusion layer also outputs evaluation metrics related to traffic flow efficiency and safety. For example, the average speed and passing rate of the local traffic flow in which the vehicle is located are predicted based on comprehensive feature regression, and the potential accident risk level is predicted through classification. These outputs are used to further analyze and validate the coupling between driving style and traffic density. During the training phase, these additional outputs, along with the main task (driving style classification), form a multi-task learning objective and, to a certain extent, provide regularization, preventing single-minded judgments based solely on behavioral or environmental characteristics, thereby improving model generalization performance.
[0084] This example employs a multi-module collaborative approach: parallel subnetworks are used to extract driver behavior characteristics and traffic environment characteristics, respectively, and then a fusion layer is used to achieve interactive coupling modeling of the two. Compared with previous methods that separately perform driving style classification and traffic flow characteristic analysis, this unified framework can simultaneously capture the relationship between micro-level driving behavior and macro-level traffic conditions, improving the model's ability to understand complex scenarios.
[0085] In order to improve the generalization performance of the model under conditions of limited labeled data, this embodiment introduces a self-supervised learning mechanism to pre-train driving behavior representations. Specifically, a pre-training task based on mask signal reconstruction and contrastive learning is designed to enable the model to learn robust behavioral feature representations on large-scale unlabeled driving data. On this basis, a multi-task learning strategy is adopted to jointly train tasks such as driving style classification, traffic density estimation, and safety risk prediction. The generalization ability and practical applicability of the model are improved through shared representation and task collaboration. On the one hand, self-supervised pre-training reduces the dependence on manual labeling and enhances the model's adaptability to unknown scenarios; on the other hand, multi-task learning enables the model to output driving style, predicted traffic flow efficiency and safety indicators at one time, achieving a comprehensive assessment of the impact of driving behavior.
[0086] In order to make full use of a large amount of unlabeled driving data, this embodiment first performs self-supervised pre-training on the Transformer-GAT encoder and then conducts joint multi-task fine-tuning.
[0087] The mask reconstruction tasks include:
[0088] Randomly mask the scaled time step features and minimize the objective function:
[0089]
[0090] in, To mask the reconstruction loss function, this loss drives the Transformer-GNN to learn a robust representation of missing / noisy data in the self-supervised stage, thereby improving the generalization ability of the subsequent joint recognition of driving style and traffic density. is the reconstructed feature matrix (predicted value), is the original feature matrix (true value). It forces the encoder to learn the internal structure of the sequence.
[0091] Contrastive learning includes:
[0092] Calculate the NT-Xent loss for two data augmented views of the same driving clip and from different driving clips:
[0093]
[0094] in, For contrastive learning loss (NT-Xent), by minimizing this value, Transformer-GNN obtains a more discriminative representation, providing a solid feature foundation for the subsequent "driving style-traffic density joint recognition". is the cosine similarity between the data augmentation view v and the data augmentation view v', is the temperature coefficient, is the cosine similarity between the data augmentation view v and the driving segment u.
[0095] The loss function used in model training is:
[0096]
[0097] in, is the total loss function, is the driving style cross entropy, For traffic efficiency, is the logarithmic loss of the binary classification of security risk, is the traffic efficiency loss weight coefficient, is the safety risk loss weighting coefficient. Joint training allows the model to simultaneously serve driving style identification, efficiency assessment, and safety warning. Multi-task coupling acts as a regularizer, significantly improving the accuracy of the primary tasks and providing the model with interpretable traffic indicator outputs.
[0098] This example addresses the limitations of existing driving style recognition and traffic density modeling, and proposes a spatiotemporal coupled Transformer-GNN end-to-end method. The inference process is as follows:
[0099] 1. Feature extraction: real-time sampling of sensors to form behavioral sequences With vehicle diagram .
[0100] 2. Coding:
[0101] .
[0102] 3. Fusion and discrimination
[0103] .
[0104] 4. Output: Given a driving style category, it returns efficiency and safety predictions in real time.
[0105] After extensive offline evaluation, the fusion model achieved an average classification F1-score of 0.93 on the NGSIM public dataset and self-collected highway-urban mixed data, with an inference latency of 80-95ms, meeting the requirements for vehicle-side deployment.
[0106] This embodiment adopts a phased training strategy in the model training phase. First, self-supervised pre-training is performed, which uses only unlabeled driving data to optimize mask reconstruction and contrast learning objectives. The pre-training uses the Adam optimizer with an initial learning rate of After about 10 epochs, the model converged and obtained good initial parameters. Subsequently, supervised fine-tuning was performed on labeled data, and the multi-task model was jointly trained. To balance the magnitude of the losses of different tasks, each loss term was appropriately weighted, and gradient clipping was used to prevent gradient explosion. The implementation is as follows:
[0107]
[0108] Model size: Number of Transformer layers , long number ; Number of graph neural network layers ; Hidden Dimension The overall model converged after training for about 5 hours on GPU, and the driving style classification accuracy of the validation set was , the mean square error of traffic efficiency and safety indicators reaches an acceptable range.
[0109] Convergence analysis: During the training process, the total loss The loss decreases monotonically with iterations and tends to stabilize. Using piecewise constant or cosine annealing learning rate schedules, the empirically sufficient conditions for Adam convergence are met. Multitasking does not cause instability; auxiliary tasks smooth the loss curve. Full convergence curves are presented in the Experiments section.
[0110] Complexity analysis:
[0111] Assume that the length of the behavior sequence is , the number of neighbor vehicles is ;
[0112] Comprehensive reasoning complexity: ;
[0113] In practice, only the latest 5 seconds of data are taken. ; and limit the neighbor radius, , enabling real-time computation (<100ms). The spatial complexity is primarily driven by model parameters and activations, both of which are in the hundreds of thousands, easily accommodated by a single GPU. Further acceleration can be achieved through model pruning, distillation, or additional hardware, enabling deployment on vehicle terminals for online monitoring.
[0114] In summary, this embodiment constructs a unified model that integrates Transformer+GNN, self-supervised pre-training, and multi-task learning, realizing the joint modeling of driving style and traffic density.
[0115] Next, experiments are conducted to verify its various performance advantages.
[0116] Dataset and preprocessing:
[0117] NGSIM measured data set: The study uses the NGSIM (Next Generation Simulation) public data provided by the U.S. Federal Highway Administration as the main data source. This data set contains high-resolution traffic flow data for a section of highway in California, including trajectory information of thousands of vehicles at different time periods. The study selected data from time periods with stable traffic flow and various levels of congestion, totaling about hundreds of vehicle trajectories, and manually labeled the corresponding driving style categories (divided into conservative, normal, and aggressive categories based on vehicle speed changes and following behavior). In data preprocessing, the trajectory data is cleaned and features are extracted. Specifically, the velocity, acceleration, jerk (rate of change of acceleration), headway, headway and other characteristic sequences are calculated for each vehicle's trajectory, and the Kalman filter is applied to smooth the velocity and acceleration curves. The study also calculates the instantaneous traffic density based on the local traffic flow conditions at the moment of each vehicle (the number of vehicles within 200 meters in front and behind it), and divides it into three levels: low, medium, and high to assist in analysis. The final data tensor shape is ,in is the number of trajectories, is the number of time steps (different trajectory studies are truncated or padded to a uniform length, for example 100 steps), is the feature dimension.
[0118] Simulation Dataset: To validate the model's performance under controlled conditions, the study constructed a high-fidelity driving behavior simulation environment using the SUMO (Simulation of Urban Mobility) simulation platform. A 500-meter-long, two-lane circular road was used to generate several virtual driver agents. Their driving behavior parameters (such as headway preference and acceleration distribution) were configured based on three types of style characteristics identified using NGSIM data. For example, aggressive agents set a smaller minimum headway and a larger maximum acceleration, while conservative agents set the opposite. In different simulation experiments, the number of vehicles on the road was adjusted to control traffic density, ranging from sparse (20 vehicles) to congested (60 vehicles). Each simulation ran for 300 seconds, and motion data from all vehicles was collected. Since the simulated trajectories were naturally labeled (the study knew each agent's style type in advance), they could be directly used to validate the model. Simulation data preprocessing involved extracting relevant features similar to NGSIM, but without the need for Kalman filtering (the simulation data was free of measurement noise). The simulated data provides a repeatable test bench for research to evaluate the model's recognition performance for different density and style combinations.
[0119] Experimental setup and comparison algorithms:
[0120] The model was trained and evaluated on the two aforementioned data types. NGSIM data was used for training and validation. Due to limited labeled data, a 5-fold cross-validation approach was employed to assess model robustness. Simulation data was used to independently test the model's generalization under extreme conditions. For comprehensive comparison, five representative recent approaches were selected for comparison, encompassing both traditional and deep learning approaches:
[0121] 1. SVM + Manual Features: This method uses a support vector machine classifier with manually selected statistical features (such as average speed, standard deviation, 85th percentile acceleration, and number of sudden braking). This represents a traditional approach used to evaluate the advantages of deep learning.
[0122] 2. Random Forest (RF): An ensemble of decision trees trained on the same handcrafted features. RF has shown excellent performance in previous driving style studies.
[0123] 3. MTL-LSTM: A multi-task LSTM model from the literature. This study implements the MTL-MTF-LSTM framework proposed by Wang et al., including the primary task of driving style classification and the auxiliary task of time series prediction, using the same network structure and training strategy as the original paper.
[0124] 4. GAT-LSTM: This method combines a graph attention network with an LSTM. Following the ideas of Huang et al., this method first encodes the target vehicle's speed sequence using an LSTM, then uses a GAT to incorporate the final states of neighboring vehicles, and finally outputs a classification of driving style. This method represents a class of deep models that incorporate neighbor interactions.
[0125] 5. RiskField-MaskedLearning: This paper utilizes the driving style recognition algorithm with risk field perception and mask learning proposed by Jin et al. This research implements the key concepts described in the paper. By introducing an environmental risk assessment matrix and performing random masking training on a portion of the input signal, the model improves its consistency across diverse environments.
[0126] Of the compared methods, the first two are traditional machine learning methods that require hand-crafted features, while the last three are deep learning methods that utilize different mechanisms such as temporal networks or self-attention. All methods were trained on the same feature data processed by the study to ensure a fair comparison. Regarding evaluation metrics, the study used classification accuracy and macro-average F1 score to measure the accuracy of driving style recognition; robustness metrics were used to assess the degree of degradation in model performance under different noise or abnormal conditions in the simulation environment; and inference time and number of model parameters were used to evaluate real-time performance and resource utilization. Specifically, during robustness testing, the study added a certain amount of perturbation to the input (such as 5% Gaussian noise or position error caused by simulated positioning deviation) to observe changes in the model recognition results.
[0127] The experimental results are shown in Table 1.
[0128] Table 1 Comparison results of various models on NGSIM
[0129]
[0130] Table 1 shows the style classification accuracy, F1 score, and aggressive driving recall of various models on the NGSIM dataset. As can be seen, the traditional SVM and RF methods achieved accuracies of 88.5% and 91.2%, respectively, with deep learning models significantly outperforming. The MTL-LSTM achieved an accuracy of 95.4%, thanks to its utilization of temporal information. The GAT-LSTM further improved this to 96.8%, demonstrating that considering neighboring vehicle interactions improves recognition accuracy. The RiskField method also performed quite well, achieving an accuracy of 96.5%, demonstrating that the inclusion of environmental risk factors improves the model's adaptability to diverse scenarios. In contrast, the proposed Transformer+GNN unified framework achieved an accuracy of 98.3% and an F1 score of 0.981 on the same test set, surpassing all other methods. This demonstrates the effectiveness of our approach in integrating long-term temporal dependencies and spatial interactions. Specifically, for the recognition of "aggressive" driving, our approach achieved a recall of 99%, approximately 2 percentage points higher than the next-best GAT-LSTM, demonstrating its ability to capture dramatic changes in driving behavior.
[0131] Test results on SUMO simulation data also validated the robustness of the model. When the simulation environment closely matched the training data distribution (e.g., medium-density scenarios), most models maintained high accuracy. However, in extreme cases (e.g., extremely high-density congestion or extremely low-density open space), the discrepancy widened.
[0132] Figure 3The accuracy of different models is compared under two scenarios: 60 simulated vehicles (high density) and 20 simulated vehicles (low density). The accuracy of the SVM and RF models drops below 80% when the model exceeds their training distribution, demonstrating strong scenario dependence. The MTL-LSTM and GAT-LSTM models are relatively robust, maintaining approximately 90% accuracy at high density. However, they exhibit some misjudgment of aggressive behaviors at low density, likely due to training based primarily on measured data and the low-density nature of aggressive behaviors in real data. The RiskField method maintains near 95% accuracy in both scenarios, demonstrating improved generalization due to contextual awareness. The proposed method exhibits minimal performance fluctuation: 97.5% accuracy in the high-density scenario and 98.0% accuracy in the low-density scenario, showing almost no significant drop. This demonstrates that the unified framework for jointly modeling the environment and behavior, coupled with a self-supervised pre-training strategy, allows the model to be more adaptable to unseen environments.
[0133] At the same time, the study introduced noise perturbation test in the simulation, and the results are as follows Figure 4 As shown in Figure 3, as the input noise intensity increases from 0 to 10%, the performance of all models decreases, but the studied method shows the smallest decrease (less than 3 percentage points), while the traditional method decreases by more than 10 percentage points. Overall, the proposed model performs best in the robustness evaluation.
[0134] The experimental results of real-time performance and model complexity are shown in Table 2.
[0135] Table 2 Comparison of inference delay and model complexity of different driving style recognition models
[0136]
[0137] illustrate:
[0138] Inference time: refers to the time it takes for the model to forward propagate a single sample, excluding preprocessing;
[0139] Total latency: SVM / RF includes explicit feature extraction time, other models are end-to-end;
[0140] Real-time performance can be achieved: refer to the typical response time of vehicle control systems (≤100ms);
[0141] Parameter quantities are approximate and are used to illustrate the difficulty of deployment.
[0142] This example measured the single inference time required for various models in the same computing environment (NVIDIA RTX 3080 GPU). Due to their simpler models, SVM and RF achieved inference times under 1ms, but they required manual feature computation (approximately 5ms), resulting in an overall latency of approximately 6ms. The MTL-LSTM model averaged 2.5ms per sample for inference, while the GAT-LSTM model, due to its inclusion of graph operations, took approximately 5.7ms. The RiskField method achieved an average inference time of 4.3ms. Despite its complex structure, the optimized model achieved an average single inference time of approximately 6.8ms, including 3.5ms for the Transformer portion, 2.0ms for the GNN portion, and 1.3ms for other fully connected layers. This speed fully meets real-time requirements (vehicle control systems typically require a 100ms response time). Regarding parameter size, the research model has approximately 0.8 million parameters, slightly higher than the 0.6M for GAT-LSTM and 0.5M for RiskField, but still within an acceptable range. Given the current performance of in-vehicle computing equipment, deploying and operating models with fewer than 1 million parameters is feasible. Therefore, from the perspective of engineering application, the research method can meet the real-time and resource-constrained requirements while ensuring high precision.
[0143] To further understand the model’s behavior, the study visualized the model’s internal representation under different combinations of driving styles and traffic density. Figure 5 As shown in the figure, the feature patterns that the research model focuses on when identifying conservative and aggressive driving are demonstrated. By extracting the Transformer self-attention weights, the study found that for conservative driving, the model pays more attention to stable features such as the mean and variance in the speed sequence; while for aggressive driving, the attention is concentrated on the spikes in the acceleration sequence (moments of rapid acceleration / deceleration) and segments where the headway between vehicles changes sharply. This shows that the model can automatically capture the key moment features that distinguish between conservative driving and aggressive driving. For example, by visualizing the attention of the GNN module, the study found that when the target vehicle is aggressive and in a high-density environment, the model gives higher attention weights to the vehicle in front and the vehicle immediately behind, reflecting that these neighbors have a greater influence on the behavior of the target vehicle; on the contrary, for conservative vehicles or in low-density environments, the attention weights are more evenly distributed or concentrated on the target vehicle itself, which is in line with intuitive expectations.
[0144] In addition, the study analyzed the impact of driving style and traffic density on traffic efficiency and safety. Based on the average speed and collision risk predicted by the model, the study statistically analyzed the mean values of indicators under different combinations. The results are as follows: Figure 6 The horizontal axis represents traffic density (low / medium / high); the vertical axis represents driving style (conservative / normal / aggressive). Darker cells indicate higher collision risk. It is easy to see that the risk of an aggressive driving style increases significantly under high density (risk value reaches 2.25).
[0145] As traffic density increases from low to high, the average speed of all driving styles decreases, but the extent of the decrease varies by style: Conservative drivers experience a speed reduction of approximately 40% at high density, while aggressive drivers experience only a 20% decrease, as the latter tend to attempt to overtake to maintain speed. However, the predicted collision risk for aggressive drivers at high density increases by approximately 60% compared to low density, far exceeding the 20% increase for conservative drivers. This is consistent with the trend observed in real-world data: aggressive driving has a particularly significant impact on safety in congested environments. In medium-density conditions, the efficiency and safety indicators of average and conservative driving styles fall between the two. This analysis demonstrates that the model not only categorizes driving styles but also provides a quantitative assessment of traffic performance in corresponding scenarios. This provides valuable insights for traffic management agencies in formulating strategies, such as strengthening controls or warnings against aggressive driving on high-density roads to reduce accident risks.
[0146] In summary, this example, through extensive experimental comparison and visual analysis, validates the superiority of the present invention in terms of driving style recognition accuracy, environmental adaptability, and real-time performance. It also demonstrates that the model can reveal the impact of the interaction between driving behavior and traffic density on traffic flow efficiency and safety.
[0147] This invention achieves improved generalization through unified end-to-end modeling of micro-behavior and macro-environment, integration of spatiotemporal feature extraction using Transformer and GNN, self-supervised pre-training, and multi-task learning. Experimental results on public data and simulation environments fully verify the superiority of this method in terms of accuracy, robustness, and real-time performance. The model can effectively identify different driving styles and quantify their impact on traffic efficiency and safety at different traffic densities. Studies have shown that aggressive driving can significantly reduce safety in high-density traffic, while conservative driving can reduce efficiency in low-density traffic. This provides a valuable reference for traffic management and autonomous driving decision-making.
[0148] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0149] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0150] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0151] Specific embodiments are used in the present invention to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas. At the same time, for those skilled in the art, according to the ideas of the present invention, there may be changes in the specific implementation methods and application scopes. In summary, the contents of this specification should not be understood as limiting the present invention.
[0152] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and it should be understood that the scope of protection of the present invention is not limited to such specific descriptions and embodiments. Those skilled in the art can make various other specific variations and combinations based on the technical teachings disclosed in the present invention without departing from the essence of the present invention, and such variations and combinations are still within the scope of protection of the present invention.
Claims
1. A driving style and traffic density joint recognition method based on Transformer-GNN, characterized by: The following steps are involved: Acquire vehicle driving status data and environmental perception data; Extract features from vehicle driving status data and environmental perception data to obtain driving behavior sequence features and vehicle environment features; A Transformer-based behavior sequence encoder is used to encode and model driving behavior sequence features, obtaining a latent state behavior representation that includes global time-dependent information. A graph neural network-based traffic interaction model is also used to construct a dynamic traffic map based on vehicle environment characteristics, capturing spatial interaction features between vehicles. Specifically include: Construct a dynamic traffic map based on vehicle environment characteristics; specifically including: The vehicle to be identified is regarded as the target node, and the adjacent vehicles within the set range are regarded as neighbor nodes. Edge connections are established based on relative distance and lane relationship. The initial features of each node are the vehicle environment features. The local traffic density is used as the global feature of the graph, and the graph attention is updated through graph convolution or graph attention network; After cyclic iteration, the spatial interaction characteristics between vehicles are obtained; The latent state behavior representation containing global time-dependent information and the spatial interaction features between vehicles are fused, and multi-task output results including driving style recognition and traffic density prediction are generated based on the fused features.
2. The driving style and traffic density joint recognition method based on Transformer-GNN according to claim 1 is characterized in that: Vehicle driving status data includes driving behavior time series parameters and corresponding index parameters; Environmental perception data includes traffic environment parameters and traffic flow parameters.
3. The driving style and traffic density joint recognition method based on Transformer-GNN according to claim 1 is characterized in that: A Transformer-based behavior sequence encoder is used to encode and model driving behavior sequence features to obtain a latent state behavior representation containing global time-dependent information, including: The driving behavior sequence features are positionally encoded and input mapped, and then input into several layers of Transformer encoders. In each layer of Transformer encoders, the multi-head self-attention weights between each time step in the sequence are calculated through a multi-head self-attention mechanism. Finally, after residual, layer normalization and feedforward network, a latent state representation containing global time-dependent information is obtained.
4. The driving style and traffic density joint recognition method based on Transformer-GNN according to claim 1 is characterized in that: The local traffic density is used as the global feature of the graph, and the graph attention is updated through graph convolution or graph attention network. Specifically: in, For the Nodes in a layered graph neural network For adjacent nodes 's attention relevance score; is the activation function, is the attention vector, T is the transpose, is the learnable weight matrix, 、 Node Its neighboring nodes In the Node representation in layer graph neural networks, is the local traffic density, is the attention weight after softmax normalization, For nodes The set of adjacent nodes, k is the number of nodes traversed in the normalization operation Index variables of all adjacent nodes.
5. The driving style and traffic density joint recognition method based on Transformer-GNN according to claim 1 is characterized in that: The model training adopts a staged training strategy. First, self-supervised pre-training is performed to optimize mask reconstruction and contrast learning objectives based on unlabeled driving data to obtain the initial model parameters. Then, supervised fine-tuning training is performed using labeled data. At the same time, a multi-task learning strategy is adopted to conduct multi-task joint training for driving style classification, traffic density estimation, and safety risk prediction.
6. The driving style and traffic density joint recognition method based on Transformer-GNN according to claim 5 is characterized in that: Mask reconstruction includes: Randomly mask the scaled time step features and minimize the objective function: in, is the mask reconstruction loss function, is the reconstructed feature matrix, is the original feature matrix.
7. The driving style and traffic density joint recognition method based on Transformer-GNN according to claim 5 is characterized in that: Contrastive learning includes: Calculate the NT-Xent loss for two data augmented views of the same driving clip and from different driving clips: in, is the contrastive learning loss, is the cosine similarity between the data augmentation view v and the data augmentation view v', is the temperature coefficient, is the cosine similarity between the data augmentation view v and the driving segment u.
8. The driving style and traffic density joint recognition method based on Transformer-GNN according to claim 5 is characterized in that: The loss function used in model training is: in, is the total loss function, is the driving style cross entropy, For traffic efficiency, is the logarithmic loss of the binary classification of security risk, is the traffic efficiency loss weight coefficient, is the safety risk loss weight coefficient.
Citation Information
Patent Citations
Vehicle track prediction method based on driver interaction behavior characteristics in network connection environment
CN115520223A
Trajectory prediction method fusing traffic state and driving style and related equipment
CN119091628A