## 4 Simulation Test and Result Analysis
### Experiments on FDIA Detection of Grid Loads
#### 4.4.1 FDIA Testing Experiments under Standard Operating Conditions
To enhance the comprehensibility of the prediction results generated by the Transformer model, normalized confusion matrices for both the balanced dataset and the imbalanced dataset, reflecting real-world conditions, are presented in Figure 8.  
The Transformer model harnesses a self-attention mechanism, facilitating the modeling of diverse positions within the input sequence and the capture of long-range dependencies. This attribute furnishes the Transformer with remarkable parallel computational proficiency. When juxtaposed against enhanced convolutional neural networks like CNN-GRU and conventional models like LSTM and SVM, the Transformer is superior in its heightened efficiency in handling voluminous datasets, thus accelerating both training and inference. By further enhancing its capabilities, the multi-layer stacking architecture of the Transformer facilitates more in-depth feature extraction and abstraction, thereby augmenting the model's ability to define variables. This capability positions the Transformer at an advantage when grappling with intricate multi-label classification tasks, thereby enhancing its capacity to discern varying data types. Additionally, the variation in the loss values of the Transformer neural network and the method used in the reference [28; 29; 32] during the training process is depicted in Figure 9. \begin{table}
\begin{tabular}{l l l l l l} \hline \hline
**Test Set** & **Detection** & \(\mathbf{\lambda_{\text{Accuracy}}}\) & \(\mathbf{\lambda_{\text{Precision}}}\) & \(\mathbf{\lambda_{\text{Recall}}}\) & \(\mathbf{\lambda_{\text{FI}}}\) \\ \hline \multirow{3}{*}{Balanced data test set} & Transformer & 0.9832 & 0.9837 & 0.9815 & 0.9824 \\  & CNN-GRU & 0.9324 & 0.9436 & 0.9213 & 0.9284 \\  & LSTM & 0.8532 & 0.8412 & 0.8564 & 0.8523 \\  & SVM & 0.7935 & 0.8016 & 0.7932 & 0.7993 \\ \hline \multirow{3}{*}{Unbalanced data test set} & Transformer & 0.9691 & 0.9581 & 0.9426 & 0.9502 \\  & CNN-GRU & 0.8351 & 0.8396 & 0.8475 & 0.8435 \\ \cline{1-1}  & LSTM & 0.7924 & 0.8016 & 0.7869 & 0.7942 \\ \cline{1-1}  & SVM & 0.7496 & 0.7534 & 0.7519 & 0.7526 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Algorithm performance comparison with other deep learning models. Figure 8: _Cont._  
The confusion matrix functions as a visual instrument for portraying the classifications generated using a given model across distinct categories. It juxtaposes the model's predictions against the true labels on a categorical basis, thereby providing a matrix that explains the classification accuracy. The metrics encompassed in Table 4, alongside the depictions in Figure 8, indicate that the Transformer model consistently demonstrates heightened accuracy in discerning false data injection attacks across a spectrum of attacked bus counts. In Figure 9, it is evident that, within the scope of this study, the introduced Transformer algorithm has superior performance with regard to the loss function. Our model consistently achieves lower loss values when addressing the given task in comparison to the other three algorithms. This outcome serves as an indicative measure of our algorithm's exceptional performance in the context of FDIA prediction, thereby offering a more effective solution to the problem at hand. Such findings further substantiate the superiority and potential of our algorithm. This model excels in the precise identification and accurate classification of samples tainted with false data. This underscores the Transformer model's capability to maintain an elevated level of accuracy, notwithstanding the varying degrees of malicious actor behaviors. Figure 8: Confusion matrix of normalized Transformer detection results: (**a**) balanced test dataset; (**b**) unbalanced test dataset. Figure 9: Changes in loss values during the Transformer training process.