# STGAT: Spatial-Temporal Graph Attention Neural Network for Stock Prediction
## 4 Experiments
### Experimental Results  
#### 4.3.1 Predictive Performance of STGAT  
This study introduces various learning models and neural networks to perform a comprehensive comparison of their performance. To assess the predictive capabilities of these models, a diverse set of performance metrics is employed, including mean absolute error (MAE), directional accuracy (DA), relative error (RE), root mean squared error (RMSE), coefficient of determination (\(R^{2}\)), and accuracy in predicting stock price fluctuations. These indicators provide a well-rounded evaluation of the models' effectiveness. As summarized in Table 2, where \(y_{i}\) is the true stock price and \(\hat{y}_{i}\) is the predicted value, these metrics holistically assess STGAT's capabilities in three dimensions: The MAE, RE, and RMSE collectively measure regression accuracy through distinct error quantification methods--MAE by averaging absolute deviations, RE by normalizing errors relative to  
Figure 8: Loss curve generated by K-fold time series validation. Figure 7: Loss curve generated by cross-validation. actual prices, and RMSE by emphasizing large errors through squaring. Simultaneously, DA specifically evaluates the alignment between predicted and actual price change directions (\(\Delta y_{i}\)), a capability essential for generating reliable trading signals. Meanwhile, \(R^{2}\) quantifies the model's ability to explain stock price variance, serving as a direct indicator of how effectively it captures complex market patterns. The integrated evaluation approach here ensures models are assessed not only on numerical precision but also on the financial decision relevance and interpretability of learned relationships. In Table 3, a performance comparison between different models based on the A-share dataset is shown. As shown in the table, STGAT demonstrates significant advantages over other baseline models across all evaluated metrics. STGAT achieves consistently lower prediction errors and improved prediction accuracy compared to the other models. As for the other models, time series models like the GRU and TCN unveil impressive prediction accuracy for their ability to effectively capture sequential dependencies in time series data. However, by integrating temporal features with graph structural features, as seen in STGAT, the model not only preserves the temporal relationships but also leverages the spatial dependencies and interactions between different stocks in the graph. This fusion of temporal and graph-based characteristics allows STGAT to capture more complex patterns and relationships within the data, resulting in its superior performance across all metrics. The combination of these features provides a more holistic understanding of the underlying dynamics, which is especially crucial for predicting intricate systems like stock price fluctuations. Table 4 presents the models' predictive performance using a dataset where training and testing sets were carefully kept entirely independent. Based on this premise, trading days were randomly selected to form the test set, which simulates the randomness and volatility commonly observed in the stock market. From the table, it can be observed that, under this experimental setup, most models show an overall improvement in performance on key indicators, with the exception of GCN. This can be interpreted as an effect of the random data split creating diverse and more independent price trends within the test set, which places a greater demand on the models' ability to reason about temporal features. In this context, models relying solely on graph structure for prediction, such as the GCN, tend to perform poorly because they lack the capacity to effectively capture or infer sequential