## 4 BP and GA-BP Neural Network Realization
### GA-BP Neural Network Model Analysis  
Part of the code parameters are shown in Algorithm 2:  
```
Procedure test2() net. trainParam.epochs \(\leftarrow\) 1000 net. trainParam.goal \(\leftarrow\) 1e\(-\)4 net. trainParam.lr \(\leftarrow\) 0.01 net. trainParam.showWindow \(\leftarrow\) 0 maxgen \(\leftarrow\) 100 sizeof \(\leftarrow\) 100 cross \(\leftarrow\) 0.8 pmutation \(\leftarrow\) 0.1 end procedure
```  
**Algorithm 2** GA-BP neural network parameters  
Crossover operations are the core operations in the GA-BP neural network training. Because of its overall searchability, the crossover operation can greatly enhance the searchability of the genetic algorithm. Under the condition of maximizing the structure of chromosomes, two randomly selected chromosomes were partially replaced and recombined to generate new genes, to expand the search space. In this model, 0.8 is set to the crossover probability and 0.1 is set to the mutation probability. This model also chooses line 1-60 data as the training set and line 61-96 data as the test set to check the learning effect. The result of the fitness curve, training set, test set, and test set prediction error are demonstrated in Figures 9-12. Figure 11: Actual value and predicted value in test set. Figure 12: Prediction error in test set. Figure 10: Actual value and predict value in train set. In the test set, we can see that the coefficient of determination (R\({}^{2}\)) = 0.96602; root mean square error (RMSE) = 1.422; mean square error (MSE): 2.0221; and residual prediction deviation (RPD): 5.4975. Additionally, the test set error is between [\(-\)3.91%, 2.4646%]. Such a small error is very accurate. Table 2 compares the BP and GA-BP neural network errors in the test set. It can be seen from Table 2 that in terms of overall prediction accuracy, the mean square error (MSE) of the GA-BP neural network prediction model is 2.0221, which is significantly smaller than the 30.3493 of the BP neural network prediction model. The error reduction is 93.3%. This shows that the prediction accuracy of the GA-BP neural network prediction model is significantly better than that of the BP neural network prediction model. In terms of the volatility and overall effect of the prediction results, the root mean square error (RMSE) and mean absolute error (MAE) of the GA-BP neural network prediction model are 1.422 and 1.1213, respectively, which are smaller than 5.509 and 2.2985 of the BP neural network prediction model. Additionally, the value of the error reduction is 74.18% and 51.2%, respectively. This shows that the prediction effect of the GA-BP neural network prediction model is also significantly better than the BP and GA-BP neural network prediction model. As for R\({}^{2}\), R\({}^{2}\) itself is a widely used index to determine the quality of regression models. The value of R\({}^{2}\) is larger (close to 1), the better performance of the regression equation fitness. Therefore, it can be concluded that the GA-BP neural network prediction model is better than the BP neural network prediction model in the precision and effect of microgrid load prediction. Moreover, the model with the GA optimized weight threshold has higher prediction accuracy and a faster convergence speed. Additionally, at the point where the BP error is larger, the error decreases more obviously. The results of the GA-BP algorithm are better than those of traditional BP neural networks. The main reason is that GA modifies the random initial weights and thresholds of the BP network. This may make a remedy for the defects of the BP network to some extent. This improves the accuracy of the prediction. Similarly, wind power and market price can also be used as the output of the model to predict as long as the data corresponding to the input can be obtained. In the machine learning algorithm, the wind power and market electricity price and load are all random data. After training and testing a specific algorithm, the corresponding data will also be obtained.