## 4 Comparative Analysis of the Prediction Results
Under the wei  
Figure 5: Flow prediction results of traditional water measurement methods, the BP model, the GA-BP model, and the PSO-BP model under different flow patterns: (**a**) free outflow with gate control; (**b**) submerged outflow with gate control; (**c**) weir flow; and (**d**) combined flow patterns. flow condition, the error ranges of the BP, GA-BP, and PSO-BP models are \(-\)10.6-12.1%, \(-\)7.9-11.1%, and \(-\)0.4-11.2%, respectively. In the case of a combination of the three flow patterns, the error ranges of the GA-BP model and the PSO-BP model are relatively close to each other, ranging from \(-\)10.7% to 15.7% and \(-\)11.4% to 12.2%, respectively. The error range of the BP model is relatively large, ranging from \(-\)13.9% to 21.4%. In summary, both the GA-BP model and the PSO-BP model have higher prediction accuracy than the BP model. Both genetic algorithms and particle swarm algorithms can be used to optimize the initial weights and thresholds of a BP neural network model. To further understand the error distributions of the three models under different flow patterns, the error distribution statistics of the three models are given in Figure 7. Under conditions of free outflow with gate control and submerged outflow with gate control, the error distributions of the GA-BP and PSO-BP models are characterized by an approximately normal distribution, while the BP model has more outliers with relative errors of 15% and above. Under the weir flow condition, the BP model has 14 samples distributed at 10% and above. The GA-BP and PSO-BP models do not have outliers with large relative errors, but the PSO-BP model has a more concentrated distribution of errors. In the case of a combination of the three flow patterns, when the relative error is within \(-\)10-10%, the number of samples predicted by the GA-BP and PSO-BP models is significantly greater than that of the BP model. The BP model has more outliers with relative errors of 15% and above. In summary, the GA algorithm and PSO algorithm improve the error distribution  
Figure 6: Relative errors of traditional water measurement methods, the BP model, the GA-BP model, and the PSO-BP model under different flow patterns: (**a**) free outflow with gate control; (**b**) submerged outflow with gate control; (**c**) weir flow; and (**d**) combined flow patterns. of the BP model, narrow the error distribution range of the BP model, and stabilize more samples within an acceptable range. The PSO algorithm has a better optimization effect on the error distribution of the BP model than the GA algorithm, making the error distribution more concentrated. For the flow predicted by different neural network models, the coefficient of determination \(R^{2}\) and the mean absolute percentage error (MAPE) were used to evaluate the flow prediction accuracy, which can be expressed as in Equations (8) and (9). A higher \(R^{2}\) indicates a better regression of the model and a smaller value of MAPE indicates a higher prediction accuracy [21]. The evaluation indicators for the prediction results of the three methods are shown in Table 2.  
\[R^{2}=1-\sum_{i=1}^{n}\bigl{(}Q_{i}-Q_{i}^{\prime}\bigr{)}^{2}/\sum_{i=1}^{n} \bigl{(}Q_{i}-\overline{Q_{i}}\bigr{)}^{2} \tag{8}\]  
\[\text{MAPE}=\frac{1}{n}\sum_{i=1}^{n}\left|\frac{Q_{i}-Q_{i}^{\prime}}{Q_{i}} \right|\times 100\% \tag{9}\]  
where \(n\) is the number of test samples and \(\overline{Q}_{i}\) is the average value of the measured flow. Figure 4:0 Error distributions of traditional water measurement methods, the BP model, the GA-BP model, and the PSO-BP model under different flow patterns: (**a**) free outflow with gate control; (**b**) submerged outflow with gate control; (**c**) weir flow; and (**d**) combined flow patterns. From the perspective of the regression effect, the \(R^{2}\) of the GA-BP and PSO-BP models is higher than that of the BP model under different flow patterns.