# Risk Assessment Method of Solar Smart Grid Network Security Based on TimesNet Model
## 3 SSG-NSR Evaluation
### Sgid Model Based on Bi-Lstm
Bi-LSTM is capable of modeling and capturing long-range dependencies in data, which is crucial for intrusion detection in dynamic and constantly changing network environments [24]. By combining forward and backward LSTM, Bi-LSTM can better capture hidden features and patterns of data, improving the effectiveness and reliability of detection. Therefore, this study uses Bi-LSTM for intrusion detection. Figure 4 shows the specific Bi-LSTM framework. In Figure 4, Bi-LSTM consists of two independent LSTM layers, one processing the input sequence in chronological order and the other processing in reverse chronological order. The calculation of Bi-LSTM is shown in Equation (12). \[ \begin{cases}\overset{\rightarrow}{h}_{t}=LSTM(x_{t}),t\in[T,1]\\ \overset{\leftarrow}{h}_{t}=LSTM(x_{t}),t\in[1,T]\end{cases}  \tag{12}\]  
In Equation (12), \(\overset{\rightarrow}{h}_{t}\) and \(\overset{\leftarrow}{h}_{t}\) are forward and backward hidden sequences. \(LSTM\) is forward LSTM. \(LSTM\) is a reverse LSTM. \(x_{i}\) is the input vector for time step \(t\). \(T\) is the gross of \(t\). The combination of two sequences results in the output sequence \(y_{t}\), as shown in Equation (13). \[y_{t}=[\overset{\rightarrow}{h}_{t},\overset{\leftarrow}{h}_{t}] \tag{13}\]  
After Bi-LSTM processing, this study introduces a Dropout layer to randomly set the output of some neurons to zero to avoid overfitting in the network. Through the fully connected layer, the output of the Bi-LSTM network is flattened into higher meaning feature dimension vectors. Finally, the feature dimension vector is input into the Softmax layer to generate the final detection result. The study used detection rate, false detection rate, accuracy rate, recall rate, and F1 score as evaluation indicators. Among them, the detection  
Figure 4: Bi-LSTM structure. rate represents the ratio of the number of correctly identified positive samples to the actual number of positive samples. The false positive rate refers to the ratio of the number of negative samples incorrectly identified as positive to the actual number of negative samples. Accuracy represents the ratio of correctly identified samples to total samples, while recall represents the ratio of correctly identified positive samples to actual positive samples. The calculation of accuracy \(Acc\) and recall \(R\) is shown in Formula (14). \[\left\{ \begin{array}{c}Acc=\frac{TP+TN}{TP+TNFP+FN}\\ R=\frac{TP}{TP+FN}\end{array} \right. \tag{14}\]  
In Equation (14), \(TP\) represents true positives, which is the number of correctly identified positive samples. \(TN\) represents true negative, which is the number of correctly identified negative samples. \(FP\) represents false positives, which refers to the number of samples incorrectly identified as positive. \(FN\) false negative refers to the number of samples incorrectly identified as negative. The \(F1\) value represents the harmonic mean of precision \(P\) and recall \(R\), calculated as shown in Formula (15). \[F1=2\frac{P\cdot R}{P+R} \tag{15}\]  
In summary, the Bi-LSTM-based SGID framework is displayed in Figure 5.  
In Figure 5, the SGID model based on Bi-LSTM first uses DBN for feature dimensionality reduction, and then inputs the reduced features into Bi-LSTM for intrusion detection. When intrusion behavior is detected, access operations are prohibited from being executed. When new intrusion behaviors are discovered, they are learned and saved in the feature knowledge base. In summary, in order to improve Bi LSTM, the study first uses DBN for feature dimensionality reduction to avoid the influence of redundant information and improve the detection accuracy of BiLSTM. Figure 5: Framework diagram of SGID model based on Bi-LSTM.