## 4 Results and Discussion  
### Stock Price Prediction Results  
The primary objective of the experimental design in this study was to validate the effectiveness of the proposed model in the task of stock price prediction and to compare it with other popular models currently in use. By comparing the performance of different models on four evaluation metrics, namely Precision, Recall, Accuracy, and \(R^{2}\), the intent was to comprehensively assess the predictive capability of each model. Precision and Recall evaluate the model's ability to predict positive instances accurately, Accuracy assesses the model's overall predictive accuracy, and \(R^{2}\) serves to describe the correlation between the model's predicted values and the actual values. The experimental results are presented in Table 1.  
From Table 1, it is evident that the Random Forest exhibits the lowest performance across all metrics. Random Forest primarily relies on an ensemble learning approach, aggregating outputs from multiple decision trees for predictions. Although it has shown commendable performance in many tasks, its capabilities might be limited in intricate time series prediction tasks due to potential difficulties in effectively capturing long-term dependencies. SVM, while outstanding for classification tasks, might not be the best fit for predicting stock prices, a continuous value prediction task. Although its performance in the table is slightly better than the Random Forest, it still lags significantly behind the \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Model** & **Precision** & **Recall** & **Accuracy** & \(R^{2}\) & **Adjusted \(R^{2}\)** \\ \hline Random Forest [24] & 0.83 & 0.81 & 0.84 & 0.73 & 0.73 \\ SVM [25] & 0.86 & 0.84 & 0.86 & 0.77 & 0.77 \\ Temporal Transformer [27] & 0.87 & 0.85 & 0.87 & 0.79 & 0.79 \\ Time-series Neural Network [26] & 0.90 & 0.88 & 0.89 & 0.88 & 0.88 \\ Seq2 Seq Transformer [28] & 0.92 & 0.90 & 0.91 & 0.90 & 0.90 \\ Proposed Method & 0.95 & 0.91 & 0.94 & 0.97 & 0.97 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Performance comparison of different models on the evaluation metrics. deep learning-based models. The Temporal Transformer, designed specifically for time series data and integrating traditional time series analysis techniques, outperforms the aforementioned two models. However, it still falls behind other deep learning approaches, possibly due to its inherent constraints in capturing intricate long-term dependencies. The Time-series Neural Network, a neural network-based time series analysis model, elevates its performance across all metrics, attributed to the potent representation capabilities of deep learning. The multi-layered structure of neural networks enables them to decipher complex patterns within time series data more proficiently. The Seq2 Seq Transformer, leveraging the Transformer architecture for sequence-to-sequence prediction, shows a marginally superior performance over the Time-series Neural Network, attributed to the Transformer's self-attention mechanism, which adeptly captures long-range dependencies. The model introduced in this study consistently excels in performance across all metrics, not only validating its efficacy but also underscoring its superiority in the task of stock price prediction. The Memory Attention module and the Long-Distance Loss function embedded within the model are likely the pivotal factors for its stellar performance, as illustrated in Figure 7.  
Mathematically, models based on the Transformer architecture, especially the proposed model, possess a self-attention mechanism, enabling the model to establish dependencies across varying time steps and to capture long-term trends. Concurrently, the incorporated memory module allows the model to retain and utilize pivotal past information, which is especially pertinent in stock price prediction tasks that are acutely sensitive to past data.