Driving style recognition method based on lstm-attention neural network
By using an LSTM-Attention neural network, driving style features are automatically extracted using a sliding time window and attention mechanism. This solves the problems of high cost, insufficient feature extraction, and poor interpretability in existing technologies for driving style recognition, and achieves high-precision and interpretable driving style recognition.
Patent Information
- Application Number
- CN202610816584.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-08
- Publication Date
- 2026-07-10
AI Technical Summary
Existing driving style identification methods rely on manual subjective annotation, which is costly and inconsistent. They also lack sufficient feature extraction, making it difficult to effectively process long-term driving data. Furthermore, traditional deep learning models lack interpretability.
An LSTM-Attention neural network is used to extract horizontal and vertical motion parameters through a sliding time window. It combines PCA dimensionality reduction and K-means clustering to generate style labels, introduces an attention mechanism to automatically focus on key behavioral segments, and constructs a two-layer LSTM structure for driving style recognition.
It automates and objectifies driving style labels, improves feature capture capabilities and recognition accuracy, provides interpretability for model decisions, and enhances trustworthiness in safety-critical scenarios.
Smart Images

Figure CN122354544A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent driving technology, and in particular relates to a driving style recognition method based on LSTM-Attention neural network. Background Technology
[0002] Driving style, as a stable behavioral pattern formed by a driver over long-term operation, directly reflects their decision-making preferences, operating habits, and dynamic response characteristics. Accurate driving style identification is crucial for human-machine interaction strategies, driving safety, and personalized services in Advanced Driver Assistance Systems (ADAS) and autonomous driving systems. Existing research primarily relies on vehicle kinematic parameters, utilizing traditional machine learning models such as Support Vector Machines (SVM) and Random Forests (RF) or deep learning models such as LSTM for identification.
[0003] However, existing methods have the following technical drawbacks: 1) Driving style labels usually rely on subjective manual annotation, which is costly and inconsistent; 2) Feature extraction is mostly focused on longitudinal motion, and the lateral and longitudinal coupling characteristics are not fully utilized; 3) When processing long-term (e.g., more than 15 seconds) natural driving data, key behavioral segments that determine the style (e.g., rapid acceleration, forced lane change) are easily diluted by redundant information from smooth driving, resulting in a decrease in model recognition accuracy; 4) Traditional deep learning models are "black boxes" and lack decision interpretability.
[0004] Therefore, there is an urgent need for a driving style identification method that can automatically construct objective labels, accurately capture key long-term features, and is interpretable. Summary of the Invention
[0005] The purpose of this invention is to provide a driving style recognition method based on LSTM-Attention neural network, which aims to solve the problems mentioned in the background art.
[0006] The present invention is implemented as follows: a driving style recognition method based on an LSTM-Attention neural network includes the following steps:
[0007] Step 1: Obtain raw vehicle trajectory data in a natural driving scenario, and preprocess the raw vehicle trajectory data. The preprocessing includes: using filtering to eliminate sensor noise and removing invalid samples based on vehicle dynamics limits.
[0008] Step 2: Using a sliding time window, driving behavior features are extracted from the preprocessed trajectory data. Within each window segment, eight motion parameters are extracted: standard deviation of lateral velocity, mean of lateral velocity, standard deviation of longitudinal velocity, mean of longitudinal velocity, standard deviation of lateral acceleration, mean of lateral acceleration, standard deviation of longitudinal acceleration, and mean of longitudinal acceleration.
[0009] Step 3: Dimensionality reduction is performed on the extracted motion parameters, and unsupervised clustering is performed based on the dimensionality-reduced features to automatically classify driving behavior into a preset number of driving style categories and generate style labels;
[0010] Step 4: Construct an LSTM-Attention driving style recognition model. The model includes a temporal encoder and attention mechanism with a two-layer LSTM structure, using window segments as input and style labels as supervision signals for training.
[0011] Step 5: After the vehicle trajectory data to be identified is processed by the same preprocessing and sliding time window extraction, it is input into the trained model, and the category with the highest probability value is output as the driving style of the current driver.
[0012] A further technical solution is that, in step 1, the filtering method is Gaussian filtering; removing invalid samples based on vehicle dynamics limits includes: removing samples with lateral acceleration greater than 5 m / s². 2 Or longitudinal acceleration greater than 8 m / s 2 Invalid samples.
[0013] In a further technical solution, in step 2, the sliding time window has a window length T = 15 s, a sliding step size of 7.5 s, and a sampling frequency of 10 Hz. Each window contains 150 time steps, and each time step corresponds to 8-dimensional kinematic features, constituting... The input matrix.
[0014] In a further technical solution, in step 3, the dimensionality reduction process uses principal component analysis to extract the top three principal components with a cumulative variance contribution rate exceeding 90%; the unsupervised clustering uses the K-means clustering algorithm and combines it with the elbow method to determine the number of clusters as 3, corresponding to the driving style categories of "conservative", "moderate" and "aggressive".
[0015] In a further technical solution, in step 4, for a time encoder using a dual-layer LSTM structure, the hidden layer dimension of each LSTM is set to 64, and dropout with a dropout rate of 0.2 is used for regularization between layers; the first layer LSTM receives the input 8-dimensional feature sequence, and the second layer LSTM uses the high-order features output from the first layer as input.
[0016] In a further technical solution, in step 4, the attention mechanism automatically learns the importance weights of different time steps in the sequence for driving style classification, and first calculates its energy score. :
[0017] (1)
[0018] in, To score energy, These are trainable row vectors. The hyperbolic tangent activation function is used. For a trainable weight matrix, For the timing encoder at time step The hidden state vector, It is a trainable bias vector;
[0019] Subsequently, the energy scores for all time steps were normalized using the Softmax function, and the attention weights that sum to 1 were calculated. :
[0020] (2)
[0021] in, The total number of time steps in the input sequence. For the natural constant An exponential function with base 0. For the first in the sequence Unnormalized attention score at each time step;
[0022] Finally, the hidden states at all time steps are summed according to their corresponding attention weights to obtain a context vector that gathers all the important global information. :
[0023] (3)
[0024] Context vector The input sequence is then fed into a fully connected layer with Dropout regularization, and finally output by a classification layer as a probability distribution vector of the input sequence belonging to the three driving style categories.
[0025] The driving style recognition method based on LSTM-Attention neural network provided in this invention has the following advantages:
[0026] (1) Automation and objectivity: Through PCA and K-means clustering technology, the driving style label is automatically and objectively labeled, completely eliminating the dependence on manual labeling, reducing costs and improving label consistency.
[0027] (2) Strong feature representation ability: By extracting multi-dimensional kinematic parameters with two degrees of freedom in the horizontal and vertical directions, the dynamic response information of the driver under multiple degrees of freedom is captured more comprehensively, which enhances the model's ability to represent complex trajectories.
[0028] (3) High precision and high robustness: An attention mechanism is introduced, which enables the model to automatically focus on key behavioral segments that determine driving style in long sequence data (such as rapid acceleration and forced lane change), effectively overcoming the problem of key information being diluted by redundant data.
[0029] (4) Interpretability: The weight distribution of the attention mechanism output can intuitively indicate the time segment that contributes the most to the final style determination, providing interpretability for model decision-making and enhancing trust in safety-critical scenarios. Attached Figure Description
[0030] Figure 1 A technical roadmap for the driving style recognition method based on LSTM-Attention neural network provided in the embodiments of the present invention;
[0031] Figure 2 This is a loss curve;
[0032] Figure 3 For accuracy curves;
[0033] Figure 4 Performance comparison chart for different driving style recognition models (where a is precision, b is recall, and c is F1 score).
[0034] Figure 5 The confusion matrix of different driving style recognition models is compared (where a is LSTM, b is CNN-LSTM, and c is LSTM-Attention driving style recognition model). Detailed Implementation
[0035] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0036] The specific implementation of the present invention will be described in detail below with reference to specific embodiments.
[0037] like Figure 1 As shown, a driving style recognition method based on an LSTM-Attention neural network, provided in an embodiment of the present invention, includes the following steps:
[0038] Step 1: Data selection and preprocessing;
[0039] To address sensor noise in the raw vehicle trajectory data acquired during natural driving scenarios, Gaussian filtering is used for smoothing to eliminate noisy samples. Simultaneously, dynamic boundary constraints are set: based on vehicle dynamics limits, samples with lateral acceleration greater than 5 m / s² are removed. 2 Or longitudinal acceleration greater than 8 m / s 2 Invalid samples are eliminated to ensure the physical consistency of kinematic parameters.
[0040] Step 2: Feature parameter extraction;
[0041] After trajectory smoothing, a sliding time window mechanism is introduced to extract driving behavior features. The window length T = 15 s (to fully cover typical lane-changing or following adjustment cycles), and the sliding step size is 7.5 s (i.e., 50% time overlap). Within each 15 s window segment, eight core vehicle motion parameters covering both lateral and longitudinal degrees of freedom are extracted: lateral velocity standard deviation, lateral velocity mean, longitudinal velocity standard deviation, longitudinal velocity mean, lateral acceleration standard deviation, lateral acceleration mean, longitudinal acceleration standard deviation, and longitudinal acceleration mean. Then, a data-driven unsupervised clustering and label mapping mechanism for driving styles is established. Due to the high dimensional correlation of the original extracted 8-dimensional feature space, manual labeling of driving styles is costly and subjective. Therefore, this method introduces dimensionality reduction and unsupervised clustering algorithms. Principal component analysis (PCA) is performed on the standardized 8-dimensional features to extract the top three principal components (PC1, PC2, PC3) with a cumulative variance contribution rate exceeding 90%. These three dimensions can cover most of the driving behavior information in the original data.
[0042] Step 3: Classify driving styles;
[0043] Based on the PCA dimensionality reduction results, K-means clustering algorithm is used for unsupervised exploratory analysis, and the number of clusters (K value) is determined to be 3 using the elbow method. Through this step, the system automatically maps and classifies the unlabeled temporal features into three categories: "conservative", "moderate", and "aggressive", providing high-quality supervision signals for the subsequent training of deep learning models.
[0044] Step 4: Driving style recognition;
[0045] Construct an LSTM-Attention driving style recognition model that considers key dynamic features. Model input: The extracted 15-second sliding window sequence is transformed into a dimensional... The model uses a matrix (based on a 10 Hz sampling frequency, with 150 time steps, each containing 8-dimensional kinematic features). A two-layer LSTM structure is used as the core temporal encoder. The core parameters of this design are as follows: the network contains two LSTM layers, each with a hidden layer dimension of 64; dropout with a dropout rate of 0.2 is used for regularization between layers to alleviate overfitting. The first LSTM layer receives the input 8-dimensional feature sequence and is responsible for learning the underlying temporal patterns. The second LSTM layer uses the higher-order features output from the first layer as input to further capture complex driving behavior combinations across longer time scales. To overcome the information loss that may result from compressing long sequences into a single vector and to make the model's decision-making process interpretable, an attention mechanism is introduced after the LSTM encoder. This mechanism can automatically learn the importance weights of different time steps in the sequence for driving style classification. First, its energy score is calculated. :
[0046] (1)
[0047] in, To score energy, It is a trainable row vector (weight vector). The hyperbolic tangent activation function is used. Given a trainable weight matrix, For the timing encoder at time step The hidden state vector, is a trainable bias vector.
[0048] Subsequently, the energy scores for all time steps were normalized using the Softmax function, and the attention weights that sum to 1 were calculated. :
[0049] (2)
[0050] in, This represents the total number of time steps (i.e., the sequence length) of the input sequence. It is an exponential function with the natural constant e ≈ 2.718. For the first in the sequence The unnormalized attention score for each time step.
[0051] Through this weight, the model intuitively quantifies The contribution of driving behavior at each time step to the overall style determination. Finally, the hidden states of all time steps are weighted and summed according to their corresponding attention weights to obtain a context vector that gathers all important global information. :
[0052] (3)
[0053] This design enables the model to automatically focus on the most style-discriminative key high-frequency dynamic segments. The context vector is then fed into a fully connected layer with Dropout regularization, and finally outputs a probability distribution vector of the input sequence belonging to the three driving style categories through a classification layer.
[0054] The final style recognition logic is to calculate the probability distribution vector, that is, to take the category with the highest probability value as the driver's final driving style output within the current sliding time window, thereby achieving high-precision and highly interpretable driving style recognition.
[0055] Step 5: Performance verification and analysis;
[0056] To fully verify the effectiveness and advancement of this method, rigorous comparative verification experiments were designed. The specific verification process is as follows: In terms of model comparison settings, the LSTM-Attention driving style recognition model constructed in this invention was used as the core test object, while a traditional single LSTM model and a CNN-LSTM hybrid model were established as benchmark comparison models. Under the same dataset partitioning standards and experimental environment, the above three models were compared and verified through training and testing.
[0057] In terms of evaluation metrics analysis, a multi-dimensional classification performance evaluation metric system is introduced to quantitatively evaluate the identification results of each model. A comprehensive comparison is made of the overall identification accuracy of each model, as well as key metrics such as precision, recall, and F1 score for each specific driving style: "conservative," "moderate," and "aggressive." Through rigorous data comparison and metric analysis, the significant performance advantages of the attention mechanism introduced in this method in overcoming the dilution of long sequences of key information, reducing driving misjudgment rates, and improving the overall system identification accuracy are objectively demonstrated.
[0058] The specific design and implementation of the simulation experiment are as follows:
[0059] (I) Experimental Environment and Dataset Division: All experiments were conducted on a hardware platform configured with an AMD 9700X processor, 32GB of memory, and an NVIDIA GeForce RTX 5070 GPU. The processed data was divided into a training set and a test set, with the training set accounting for 75% and the test set accounting for 25%.
[0060] (II) Evaluation Metrics: To comprehensively evaluate model performance, the following widely accepted evaluation metrics are adopted:
[0061] Accuracy: The proportion of samples that are correctly classified overall; it is a macro-level measure of model performance.
[0062] Precision, recall, and F1 score: Calculated for each driving style category. Precision measures the proportion of samples that the model predicts as belonging to that category, but which actually belong to that category; recall measures the proportion of samples that actually belong to that category, but which are correctly identified by the model; the F1 score is the harmonic mean of precision and recall, providing a better comprehensive assessment of the model's ability to identify each category.
[0063] Confusion matrix: Visually displays the model's correct and incorrect classifications in each category in matrix form, which helps in analyzing categories that the model is easily confused with.
[0064] (III) Model Comparison;
[0065] To verify the effectiveness of the LSTM-Attention driving style recognition model, this paper sets up two representative models, LSTM and CNN-LSTM, for comparison.
[0066] like Figure 2 As shown, both training loss and test loss decrease rapidly with increasing training cycles, while the test loss maintains a small and stable difference from the training loss, eventually converging to a lower value. This phenomenon clearly indicates that the model did not exhibit significant overfitting during the optimization process.
[0067] The accuracy curve of the model intuitively reflects its learning effectiveness. For example... Figure 3 As shown, in the early stages of training, the training accuracy and test accuracy increased rapidly in tandem, indicating that the model architecture can efficiently capture the core discriminative features of driving style. The best performance point achieved by the model on the validation set is indicated by the red asterisk.
[0068] like Figure 4 As shown in Figure a, in terms of accuracy, the LSTM-Attention driving style recognition model exhibits a significant advantage across all categories, with the most significant improvement in identifying the neutral type. The basic LSTM model achieves an accuracy of only 0.834 on the neutral type, indicating that many samples of other styles are misclassified as belonging to this category. The CNN-LSTM model, which incorporates a convolutional module, improves this to 0.948, while the LSTM-Attention driving style recognition model further enhances this metric to 0.975. This demonstrates that the attention mechanism effectively suppresses the interference of atypical features by assigning higher weights to key features. Notably, in the conservative type with a large sample size and relatively stable features, all three models maintain high accuracy, but the model of this invention still outperforms the comparative models.
[0069] Recall, a metric that reflects a model's ability to cover samples of a specific style, is most clearly demonstrated by its performance on aggressive models. For example... Figure 4As shown in b, the basic LSTM model has a recall rate of only 0.785 for aggressive driving behaviors, indicating that more than 20% of aggressive driving behaviors are not successfully detected, which may lead to the failure of dangerous driving warnings in practical applications. In contrast, the LSTM-Attention driving style recognition model significantly improves the recall rate of this category to 0.971, an improvement of approximately 18.6 percentage points compared to the basic LSTM, and also shows a significant improvement compared to CNN-LSTM (0.908). This breakthrough demonstrates that the attention mechanism can effectively capture fleeting aggressive operation segments in long sequences, thereby avoiding the omission of key information.
[0070] The F1 score, as the harmonic mean of precision and recall, comprehensively reflects the overall stationarity of the model. Figure 4 As shown in Figure c, experimental data shows that the LSTM-Attention driving style recognition model achieved F1 scores of 0.975, 0.994, and 0.976 across the three categories, respectively. This not only resulted in the best overall numerical performance but also minimized the performance variance between categories. In contrast, the basic LSTM model's F1 score hovered around 0.85 for the moderate and aggressive types. While the CNN-LSTM model improved overall performance, its F1 score (0.947) for the moderate type was still significantly lower than that of the LSTM-Attention driving style recognition model. In conclusion, by introducing an attention mechanism, the model not only achieved a breakthrough in macroscopic accuracy but also realized performance improvements in microscopic category feature capture through the "attention point" mechanism, effectively solving the problem of missed detections and misjudgments caused by feature sparsity in long-sequence driving data.
[0071] To further explore the fine-grained classification performance and misclassification distribution of the models across different driving style categories, this paper compares and analyzes the confusion matrices of LSTM, CNN-LSTM, and LSTM-Attention driving style recognition models. The diagonal values of the confusion matrix represent the probability of each category being correctly classified, while the off-diagonal elements intuitively reflect the degree of confusion between categories.
[0072] like Figure 5 a, Figure 5 b and Figure 5As shown in Figure c, the LSTM-Attention driving style recognition model achieved classification accuracies of 97.54%, 99.47%, and 97.09% across the three categories, respectively. Particularly noteworthy is the reduction in the false positive rate for the most difficult-to-distinguish "aggressive" category to 2.91%, a decrease of nearly 18.5% compared to the basic LSTM model. This result fully demonstrates the core advantage of the attention mechanism: by automatically focusing on key segments within a 15-second time window that determine driving style, the model successfully avoids the dilution of crucial information caused by excessively long sequences, thus accurately distinguishing the essential differences in driving styles and significantly improving the system's recognition reliability and driving safety.
[0073] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A driving style recognition method based on LSTM-Attention neural network, characterized in that, Includes the following steps: Step 1: Obtain raw vehicle trajectory data in a natural driving scenario, and preprocess the raw vehicle trajectory data. The preprocessing includes: using filtering to eliminate sensor noise and removing invalid samples based on vehicle dynamics limits. Step 2: Using a sliding time window, driving behavior features are extracted from the preprocessed trajectory data. Within each window segment, eight motion parameters are extracted: standard deviation of lateral velocity, mean of lateral velocity, standard deviation of longitudinal velocity, mean of longitudinal velocity, standard deviation of lateral acceleration, mean of lateral acceleration, standard deviation of longitudinal acceleration, and mean of longitudinal acceleration. Step 3: Dimensionality reduction is performed on the extracted motion parameters, and unsupervised clustering is performed based on the dimensionality-reduced features to automatically classify driving behavior into a preset number of driving style categories and generate style labels; Step 4: Construct an LSTM-Attention driving style recognition model. The model includes a temporal encoder and attention mechanism with a two-layer LSTM structure, using window segments as input and style labels as supervision signals for training. Step 5: After the vehicle trajectory data to be identified is processed by the same preprocessing and sliding time window extraction, it is input into the trained model, and the category with the highest probability value is output as the driving style of the current driver.
2. The driving style recognition method based on LSTM-Attention neural network according to claim 1, characterized in that, In step 1, the filtering method is Gaussian filtering; Invalid samples were removed based on vehicle dynamics limits, including those with lateral acceleration greater than 5 m / s². 2 Or longitudinal acceleration greater than 8 m / s 2 Invalid samples.
3. The driving style recognition method based on LSTM-Attention neural network according to claim 1, characterized in that, In step 2, the sliding time window has a window length T = 15 s, a sliding step size of 7.5 s, and a sampling frequency of 10 Hz. Each window contains 150 time steps, and each time step corresponds to 8-dimensional kinematic features, constituting... The input matrix.
4. The driving style recognition method based on LSTM-Attention neural network according to claim 1, characterized in that, In step 3, the dimensionality reduction process uses principal component analysis to extract the top three principal components with a cumulative variance contribution rate of over 90%; the unsupervised clustering uses the K-means clustering algorithm and combines it with the elbow method to determine the number of clusters to be 3, corresponding to the driving style categories of "conservative", "moderate" and "aggressive".
5. The driving style recognition method based on LSTM-Attention neural network according to claim 1, characterized in that, In step 4, for a time encoder using a two-layer LSTM structure, the hidden layer dimension of each LSTM is set to 64, and dropout with a dropout rate of 0.2 is used for regularization between layers; the first LSTM receives the input 8-dimensional feature sequence, and the second LSTM takes the high-order features output from the first layer as input.
6. The driving style recognition method based on LSTM-Attention neural network according to claim 5, characterized in that, In step 4, the attention mechanism automatically learns the importance weights of different time steps in the sequence for driving style classification, and first calculates its energy score. : (1) in, To score energy, These are trainable row vectors. The hyperbolic tangent activation function is used. For a trainable weight matrix, For the timing encoder at time step The hidden state vector, It is a trainable bias vector; Subsequently, the energy scores for all time steps were normalized using the Softmax function, and the attention weights that sum to 1 were calculated. : (2) in, The total number of time steps in the input sequence. For the natural constant An exponential function with base 0. For the first in the sequence Unnormalized attention score at each time step; Finally, the hidden states at all time steps are summed according to their corresponding attention weights to obtain a context vector that gathers all the important global information. : (3) Context vector The input sequence is then fed into a fully connected layer with Dropout regularization, and finally output by a classification layer as a probability distribution vector of the input sequence belonging to the three driving style categories.