## 3 Model and Algorithm Design
### CNN-LSTM Model
Mathematically, this process is represented as follows:  
\[Flatten(X)=[x_{1},x_{2},\dots,x_{n}] \tag{9}\]  
This step ensures that the feature data meet the input requirements of the time-series model. **Step 4**: Time-Series Analysis (LSTM Part). Long Short-Term Memory (LSTM) networks are powerful tools for handling time-series data, capable of capturing temporal changes in physiological signals. LSTM is particularly well-suited for analyzing variations in the driver's physiological state, as it effectively captures long-term dependencies in the time series. The internal structure of LSTM consists of three main gating mechanisms: the input gate, forget gate, and output gate, with the state updates of each gate defined by the following formulas:  
1. Input Gate: Controls the retention of current input information, represented by the following formula: \[i_{t}=\sigma(W_{i}\cdot[h_{t-1},x_{t}]+b_{i})\] (10) where \(W_{i}\) is the weight for the input gate, \(\sigma\) is the sigmoid activation function, and \(b_{i}\) is the bias term. 2. Forget Gate: Determines the retention of information from the previous state, calculated as follows: \[x^{\prime}=\frac{x-\min(X)}{\max(X)-\min(X)} \tag{2}\]0 (11)Through this mechanism, LSTM can selectively forget unnecessary information, improving learning efficiency. 3. Cell State Update: The update process of the cell state combines the effects of the input gate and forget gate, represented by the following: \[x^{\prime}=\frac{x-\min(X)}{\max(X)-\min(X)} \tag{2}\]1 This formula ensures the effective storage and updating of information, allowing the cell state to flexibly capture temporal information. 5. Hidden State Update: Based on the current cell state, the hidden state update is given by the following: \[x^{\prime}=\frac{x-\min(X)}{\max(X)-\min(X)} \tag{2}\]2 (12)  
This updating mechanism ensures that the LSTM can retain important contextual information within the time series. These formulas work together to enable selective storage and forgetting of information, allowing the model to dynamically adjust its memory content to adapt to the ever-changing driving environment [3]. The design of the LSTM allows it to handle both long-term and short-term dependencies in sequential data, ensuring that changes in the driver's physiological state can be promptly captured. When processing time-series data, the LSTM model can flexibly capture patterns and variations within the input sequences. To further enhance model performance, the parameters of the LSTM can be tuned using specific methods, including the following: selecting the sequence length (choosing an appropriate sequence length can influence the model's ability to learn long-term dependencies; longer sequences can capture further time dependencies but increase computational costs) and using multi-layer LSTM (stacking multiple LSTM units can improve the model's complexity and expressive capability). This structure helps the model extract features from different levels, thereby enhancing its ability to capture complex patterns. **Step 5**: Output Layer. After the LSTM layer, a fully connected (dense) layer is typically added to the network for classification or regression tasks. This layer generates the final output by applying a linear transformation to the LSTM output:  
\[x^{\prime}=\frac{x-\min(X)}{\max(X)-\min(X)} \tag{2}\]3  
where \(\hat{y}\) represents the output, \(W\) is the weight matrix, \(h_{t}\) is the final hidden state from the LSTM, and \(b\) is the bias term. Choosing an appropriate loss function is crucial for model training. A commonly used cross-entropy loss function can be expressed as follows:  
\[x^{\prime}=\frac{x-\min(X)}{\max(X)-\min(X)} \tag{2}\]4  
where \(N\) is the number of samples, \(C\) is the number of classes, \(y_{i,c}\) represents the true label, and \(\hat{y}_{i,c}\) is the predicted value.