# Optimizing CNN-LSTM for the Localization of False Data Injection Attacks in Power Systems
## 4 Simulation Experiments
### Simulation Results  
For the CNN-LSTM model, there are 10 hyperparameters that need optimization: learning rate, number of iterations, batch size, activation function, number of convolution kernels, size of the convolution kernels, number of convolution layers, number of LSTM layers, lstm_units size, and dropout size. The optimization range of the GA under different hyperparameters and the optimization results for the test systems are shown in Table 1. The search range of all hyperparameters was determined based on relevant research experience and test experiments [29, 30, 31, 32]. For instance, learning rate, batch size, and epochs are three fundamental hyperparameters in the model training process that determine the learning dynamics and final performance of the model. Based on experience and testing, the range of learning rates we selected aimed to provide a balance, allowing the model to learn quickly and converge stably; the range of batch size allowed the model to make a trade-off between training efficiency and convergence stability; the range of epochs was designed to ensure that the model achieved good generalization ability at different stages. The hyperparameters related to the model architecture, such as the number of convolutional layers, the number of convolutional kernels, and the size of the kernels, as well as the number of LSTM layers and LSTM units, determine the model's feature extraction ability and the processing ability of time series data. These parameters' ranges fully consider the dimensions and complexity of the measured data, as well as the learning ability of the model. The range of the number of convolutional layers was chosen to balance the depth of the model and the computational cost; the range of the number of convolutional kernels enabled the model to capture rich features while avoiding overfitting issues; the range of kernel sizes took into account the spatial dimensions of the measured data; the range of LSTM layers and LSTM units was designed to enhance the model's ability to process time series data while avoiding excessive increases in model complexity. Due to differences in system sizes and data, the optimization results of hyperparameters vary for different test systems.  
In this paper, we chose the F1 score as the indicator for performance evaluation. As the harmonic mean of precision and recall, the F1 score not only ensures the accuracy of the model predictions but also emphasizes the model's ability to identify positive instances. Especially when dealing with imbalanced datasets, the advantage of the F1 score becomes particularly prominent, as it can more fairly evaluate the model performance and mitigate biases arising from uneven class distributions. We set the population size of the genetic algorithm to 30 and the number of iterations to 20. The changes in the maximum F1 score of the IEEE bus test systems in each iteration are depicted in Figure 7. It is evident from the figure that in the IEEE bus test systems, as the number of iterations increased, the fitness value gradually ascended and eventually stabilized. In the IEEE 14-bus test system, it reached its maximum value of 99.71% after the 14 th iteration and remained stable thereafter. Conversely, in the IEEE 118-bus test system, it achieved its maximum value of 99.10% after the 15 th iteration and stabilized as well.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Parameters Range** & **IEEE 14-Bus** & **IEEE 118-Bus** \\ \hline learning rate & 0.0005, 0.0008, 0.001, & 0.0005 & 0.0005 \\ epoch & 25, 30, 35, 40 & 35 & 25 \\ batch\_size & 32, 64, 128, 256 & 128 & 64 \\ activation function & relu, tanh & relu & tanh \\ number of layers & 1, 2, 3, 4 & 1 & 4 \\ number of kernels & 32, 64, 128, 256 & 32 & 256, 128, 256, 32 \\ size of kernels & 3, 4, 5, 6 & 6 & 3, 4, 3, 6 \\ LSTM layers & 1, 2 & 1 & 1 \\ lstm\_units & 64, 128, 256, 512 & 512 & 256 \\ dropout & 0.1, 0.2, 0.3 & / & 0.2 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Range and results of hyperparameters for the GA-optimized CNN-LSTM model.