# HTSA-LSTM: Leveraging Driving Habits for Enhanced Long-Term Urban Traffic Trajectory Prediction
## 2 Model Development
### Driving Style Analysis Module  
To better utilize sensor data and capture driving styles, temporal state continuity is introduced to segment and cluster vehicle sensor data. A sparse inverse covariance clustering method based on temporal sequence state continuity (SICC-SC) was developed. For semantic analysis of driving primitives, a network analysis method is applied. Using the network structure of each driving primitive obtained from SICC-SC, the driving primitives are semantically interpreted and defined without manually predefined labels. The SICC-SC method is used to segment the driver's trajectory data, resulting in five clusters in Table 1.  
As shown in Figure 3, after obtaining the multidimensional vehicle sensor data, a sliding window with a size of \(sw\) is used to extract local time-series data. First, the relative distance series \(Pre_{\Delta D}\) of neighboring data points within the window \(sw\) is calculated, including the mean \(\mu\) and standard deviation \(\sigma\). Based on the characteristics of the normal distribution, each value in \(Pre_{\Delta D}\) is assigned a similarity metric, representing the temporal \begin{table}
\begin{tabular}{c c} \hline \hline
**Driving Primitives** & **Explanation** \\ \hline \#0 & Stable High Speed \\ \#1 & Stopping \\ \#2 & Accelerating \\ \#3 & Low Speed \\ \#4 & Turning \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Centrality score of network nodes. continuity of the time series. Subsequently, the Expectation-Maximization (EM) algorithm is used to solve the sparse inverse covariance matrix \(\Theta\). This matrix encapsulates conditional dependencies among sensor variables (e.g., throttle-velocity correlations during acceleration), effectively serving as a feature dictionary that defines discriminative interactions for each driving primitive. The sliding window mechanism, analogous to a dynamic lens scanning temporal behaviors, enables the model to decompose complex driving sequences into semantically coherent units, as visualized in Figure 3.  
A dynamic programming (DP)-based clustering assignment method is introduced to address the issue of state continuity in time-series data. In the E-step of the EM algorithm, the combinatorial optimization problem is solved by maximizing the expected likelihood. The objective function minimizes the sum of the negative log-likelihood and a penalty term \(\alpha_{t}\):  
\[min\sum_{i=1}^{K}\sum_{X_{t}\in P_{i}}-logL(X_{t},\Theta_{i})+\alpha_{t}\cdot \{X_{t-1}\
otin P_{i}\} \tag{18}\]  
In the proposed dynamic programming (DP)-based clustering assignment method, the objective function in Equation (18) is designed to balance model fitness and state continuity in time-series data. Specifically, the term \(-\text{log}L(X_{t},\Theta_{i})\) represents the negative log-likelihood of assigning time point \(X_{t}\) to cluster \(P_{i}\) under the current parameter estimates \(\Theta_{i}\), which measures the discrepancy between the observed data and the model's predictions. The second term, \(\alpha_{t}\cdot\{X_{t-1}\
otin P_{i}\}\), introduces a state continuity constraint: it imposes a penalty proportional to the parameter \(\alpha_{t}\) whenever a time point \(X_{t}\) is assigned to a different cluster than its predecessor \(X_{t-1}\). This encourages adjacent time points to be clustered together, enhancing the temporal coherence of the resulting clusters. The dynamic programming approach optimizes this objective by constructing an optimal path that minimizes the cumulative cost across all time points. This path is determined by iteratively solving subproblems that balance the trade-off between local likelihood maximization and global continuity constraints, ensuring that the final clustering assignment is both statistically plausible and temporally smooth. The parameter \(\alpha_{t}\) can be adaptively adjusted to control the strength of the continuity constraint, allowing the method to handle varying degrees of temporal dependence in different segments of the time series.