# EL-MTSA: Stock Prediction Model Based on Ensemble Learning and Multimodal Time Series Analysis
## 3 Model Construction
### Deep-Learning-Based Sequential Prediction Network  
As the basic sequential prediction network, we utilize the LSTM, GRU, Bi-LSTM, and CNN-GRU architecture introduced earlier. Each model generates a single prediction result for the given input data vectors. These models were selected based on extensive experimentation, and their effectiveness as part of the basic learning module has been demonstrated in subsequent experiments. LSTM (long short-term memory) is a special type of recurrent neural network (RNN) designed to address the vanishing gradient problem encountered by traditional RNNs when processing long sequences. It controls the flow of information through the introduction of three gates: the forget gate, the input gate, and the output gate. The network structure diagram of LSTM is shown in Figure 3a. The forgetting gate formula is as follows:  
\[f_{t}=\sigma(W_{f}[h_{t-1},x_{t}]+b_{f}) \tag{10}\]  
The input gate formula is as follows:  
\[i_{t}=\sigma(W_{i}\cdot[h_{t-1},x_{t}]+b_{i}) \tag{11}\]  
\[\widetilde{C}_{t}=\tanh(W_{c}\cdot[h_{t-1},x_{t}]+b_{c}) \tag{12}\]  
The cell state is shown in the following equation:  
\[C_{t}=f_{t}\odot C_{t-1}+i_{t}\odot\widetilde{C}_{t} \tag{13}\]  
The output gate formula is as follows:  
\[O_{t}=\sigma(W_{o}[h_{t-1},x_{t}]+b_{o}) \tag{14}\]  
\[h_{t}=O_{t}\odot\tanh(C_{t}) \tag{15}\]  
Bi-LSTM (bidirectional long short-term memory) is an extension of LSTM that consists of two LSTM layers. One layer processes the sequence in the forward direction, while the other processes it in the backward direction. This allows it to capture both forward and backward dependencies in the sequence simultaneously. The specific structure is illustrated in Figure 3d. GRU (gated recurrent unit) is a streamlined version of the recurrent neural network (RNN) designed to address the vanishing gradient problem inherent in traditional RNNs. It controls the flow of information through the introduction of two gates: the update gate and the reset gate, resulting in a more concise structure compared to LSTM. The network structure diagram of GRU is shown in Figure 3c. Figure 3: Structure illustration of sequential prediction network. (**a**) LSTM unit (**b**) Convolution and pooling operation (**c**) GRU unit (**d**) Bi-LSTM architecture. The update gate formula is as follows:  
\[z_{t}=\sigma(W_{z}\cdot[h_{t-1},x_{t}]) \tag{16}\]  
The reset gate formula is as follows:  
\[r_{t}=\sigma(W_{r}\cdot[h_{t-1},x_{t}]) \tag{17}\]  
Candidate hidden state is as follows:  
\[\widetilde{h}_{t}=\tanh(W\cdot[r_{t}*h_{t-1},x_{t}]) \tag{18}\]  
Hidden state at the current time step is as follows:  
\[i_{t}=\sigma(W_{i}\cdot[h_{t-1},x_{t}]+b_{i}) \tag{11}\]0  
When processing time-series data, CNNs (convolutional neural networks) typically transform one-dimensional time-series data into a two-dimensional matrix format using a sliding window approach, which facilitates subsequent operations. The formula for the convolution operation is as follows:  
\[i_{t}=\sigma(W_{i}\cdot[h_{t-1},x_{t}]+b_{i}) \tag{11}\]1  
The formula for the max pooling operation is as follows:  
\[i_{t}=\sigma(W_{i}\cdot[h_{t-1},x_{t}]+b_{i}) \tag{11}\]2  
The flatten operation can be expressed as follows:  
\[i_{t}=\sigma(W_{i}\cdot[h_{t-1},x_{t}]+b_{i}) \tag{11}\]3  
The formulation of the fully connected layer is as follows:  
\[i_{t}=\sigma(W_{i}\cdot[h_{t-1},x_{t}]+b_{i}) \tag{11}\]4  
Analyzing the frequency components of a time series using the fast Fourier transform (FFT) allows for the identification of its dominant periodic patterns. The FFT converts the time series from the time domain to the frequency domain, revealing the intensity of different frequency components.