ABSTRACT
Meteorological conditions play an important role in China's national production, and the accurate prediction of precipitation is of great significance for social production, flood prevention, and the protection of people's lives and property. A coupled model for monthly rainfall prediction is constructed based on the convolutional neural network (CNN) and the bi-directional long- and short-term memory network (BILSTM) combined with a sparrow optimization algorithm incorporating positive cosine and Cauchy variants (SCSSA). The model combines the SCSSA optimization algorithm with the CNN-BILSTM model, capturing data features in data space as well as temporal dependencies through CNN-BILSTM to predict the relationship. Additionally, the model combines SCSSA's excellent global search capability and convergence speed to further improve the accuracy of model prediction. Based on the measured monthly rainfall data of Xi'an City from 1996 to 2020, the SCSSA-CNN-BILSTM model was compared with the SSA-CNN-BILSTM, SCSSA-BILSTM, and CNN-BILSTM models. The results show that all the evaluation indicators of the SCSSA-CNN-BILSTM model are optimal and the prediction accuracy is the highest. This shows that the proposed SCSSA-CNN-BILSTM model has high accuracy in monthly rainfall prediction and provides a new method for hydrological rainfall model predictions.
HIGHLIGHT
SCSSA-CNN-BILSTM model, rainfall prediction, BILSTM neural network.
INTRODUCTION
As a relatively common hydrological phenomenon in nature, rainfall has an important impact on the industrial and agricultural production and life of human society, the drainage arrangement of cities, and the prevention of flood disasters. With the continuous development of neural networks, the prediction of hydrometeorological models has been a hot topic in recent years, and many excellent hydrological models have emerged after continuous exploration by scholars. Shourian et al. combined the particle swarm optimization (PSO) algorithm with the No-Fit Polygon (NFP)-based watershed simulation model that can better handle water resource optimization problems (Shourian & Mousavi 2017). Li and others combined the extreme learning machine with PSO, which enables an accurate simulation of the problem of the release history of pollution sources (Li et al. 2020). Wang et al. combined the intrinsic mode function with the long- and short-term memory network (LSTM) and PSO, and this coupled model has high accuracy and stability in hydrological forecasting (Wang et al. 2021). The variational modal decomposition (VMD)-LSTM-transformer model, constructed by Guo et al., was applied to the runoff analysis of reservoirs and achieved better results (Guo et al. 2023). Wei et al. combined completely noise-assisted aggregate empirical modal decomposition, LSTM and Informer techniques, and VMD to predict monthly runoff data (Wei et al. 2023). Deng et al. explored the potential relationship between hydrological mechanisms and runoff forecasting by combining a convolutional neural network (CNN) with LSTM (Deng et al. 2022). Fang and other authors used wavelet transform to decompose the runoff data and built a relevant vector machine model in each subsequence for the hydrological prediction of monthly runoff volume and achieved good results (Ruiming 2019). Sha et al. combined the minimum divergence Schaake shuffle with CNN and proposed a combined AnEn-CNN model that combines traditional statistical post-processing and neural networks (Sha et al. 2022). Asanjan combined the LSTM network and Precipitation Estimation from Remote Sensing Information with Artificial Neural Networks (Akbari Asanjan et al. 2018). Zhang and others used VMD to decompose the raw data and then used a sparrow search algorithm (SSA) combined with bi-directional long- and short-term memory network (BILSTM) for optimization and prediction, which achieved better results in monthly runoff prediction (Zhang et al. 2023a,b). Hu et al. used the CNN-BILSTM model combined with the Dragonfly algorithm (DA) difference analysis method to achieve high accuracy in both water level warning and flood warning prediction, proving the scientific validity and practicality of the model (Hu et al. 2023). Wu et al. combined the VMD and CNN-BILSTM model and introduced the attention mechanism with Bayesian optimization to enhance the prediction accuracy of the CNN-BILSTM model, which is highly adaptable in different hydrological environments (Wu et al. 2023). Jiao et al. decomposed the rainfall sequence into multiple subsequences containing training and test sets and achieved good prediction accuracy by using variational pattern decomposition and bi-directional long- and short-term memory neural networks combined with improved particle swarm optimization for rainfall data simulation (Jiao & He 2024). Burgan et al. used ANN algorithms such as Generalized Regression Neural Networks and Radial Basis Function Neural Networks along with multiple linear regression (MLR) for the prediction of daily runoff in the Kokasu River to compare the prediction performance of algorithms such as ANN and MLR (Burgan 2022). Marjani et al. used a CNN-BILSTM model for wildfire spread prediction using elements such as topography, land cover, and wind information to train the model, which is a new approach to neural network prediction (Marjani et al. 2024).
Since the LSTM algorithm was proposed in 1997, a large number of rainfall prediction models have emerged, and the mainstream model in recent years is to combine convolutional neural networks, recurrent neural networks, and Backpropagation algorithm (BP) neural networks with each other to obtain better prediction performance; however, the common CNN-BILSTM model suffers from the difficulty of parameter tuning and data dependence, and the performance of the SSA-BILSTM model is limited by the optimized implementation of SSA. In order to address the above problems, this paper proposes a new rainfall prediction model based on the CNN and the BILSTM combined with the sparrow optimization algorithm (SCSSA). The model can extract local spatial features using the CNN model. BILSTM combines past and future sequence information to analyze the rainfall data (Zhang et al. 2023a,b). Additionally, it optimizes the parameter data such as the learning rate and regularization parameter using SCSSA. Compared with the SSA model, it can quickly iterate the optimal parameters, solving the problems of parameter processing complexity and long training time in CNN-BILSTM.
THEORY AND METHODOLOGY
Sparrow optimization algorithm integrating sine-cosine and Cauchy mutation
SSA is a new optimization algorithm for simulating sparrows for predation and anti-predation proposed by Xue & Shen (2020), which possesses the advantages of simple algorithm structure and higher solution accuracy (Le et al. 2021). Compared to most optimization algorithms, SSA has a greater advantage in problem optimization but still suffers from low convergence accuracy and local crashes into the extreme value space.
is the overall optimal position, is the step correction coefficient obeying the standard normal distribution, is the fitness of the sparrow at this time, denotes the worst fitness, denotes the optimal fitness with this time; k is the random number between (0, 1), and is taken as 10E − 50 (Li et al. 2022a,b).
The specific algorithmic flow of SCSSA is as follows (Zhou et al. 2022):
Step 1 Set the population size, maximum number of iterations, discoverer and scout ratio, alert threshold, safety threshold, etc.
Step 2 Initialize the sparrow population setting by formula (1).
Step 3 Calculate the fitness of each sparrow and list the optimal fitness and worst fitness sparrows.
Step 4 Update the finder position according to Equation (3).
Step 5 Update the follower position according to Equation (4).
Step 6 Update the vigilant position according to Equation (5).
Step 7 Determine whether the number of iterations reaches the end of iteration criterion, and repeat from step 3 if the criterion is not reached.
Step 8 The program ends and outputs the optimal adaptation and the best position.
Convolutional neural networks
Bi-directional long- and short-term memory
SCSSA-CNN-BILSTM model prediction process
The model flowchart of SCSSA-CNN-BILSTM is shown in Figure 3, and the steps of model prediction are as follows:
Step 1 Import rainfall data and set the training set, validation set, and simulation step size.
Step 2 Construct the CNN-BILSTM model, set parameters such as regularization parameter λ and initial learning rate η, and set parameters such as population size S and iteration number M of the SCSSA algorithm to simulate the training set data.
Step 3 Output the predicted data and record each individual adaptation and the global optimal solution in the optimization algorithm.
Step 4 Determine whether the optimization reaches the stopping condition; if the stopping condition is not reached, optimize the parameters by the SCSSA algorithm. If the stopping condition is reached, use the global optimal solution as the optimal weights and bias parameters of the neural network.
Step 5 Use the updated parameters of the SCSSA-CNN-BILSTM model to predict the test set data.
STUDY APPLICATION
Overview of the study area
The study area was selected from Xi'an City, Shaanxi Province, which is located in the Guanzhong Plain in the central part of the Yellow River Basin between longitude 107°40′–109°49′ E and latitude 33°42′–34°45′ N.
The city of Xi'an has distinguished geomorphological features. The Wei River Plain is formed in the north by the long-term alluvial deposition of the Wei River, and the Qinling Mountains are formed in the south by the dramatic undulation of the mountains and the folding of the terrain, with the terrain being low in the north and high in the south.
The river network in Xi'an is dense, containing 54 rivers such as Wei River, Jing River, Hei River, Ba River, etc. The rivers in the south are steep due to the mountainous terrain of the Qinling Mountain Range. With a larger specific drop and a faster flow rate, the gradient of the middle reaches of the rivers decreases. The sand-carrying capacity of the rivers is weakened, and the accumulation of the riverbed is obvious. Downstream, the rivers significantly swing, presenting as a wandering-shaped river channel.
The spatial distribution of rainfall within the city of Xi'an has significant differences, with the rainfall in the southern Qinling Mountains region significantly greater than that in the northern Weihe Plain, and most concentrated in the region of 1,000–1,400 meters above sea level, with an annual precipitation of nearly 1,000 mm.
Data accuracy is the basis of the effectiveness of the prediction model, and the quality of the data directly affects the prediction results. In rainfall prediction, the selection of appropriate features is crucial to improve the accuracy of the prediction model. By choosing rainfall data with certain features, the complexity of the model can be reduced and the prediction efficiency can be improved, but at the same time, it should be ensured that the data have a certain degree of authenticity.
From the monthly rainfall curve graph, it can be seen that the rainfall has a strong cyclical nature, and most of the annual rainfall peaks occur between the middle and the end of the year, the monthly rainfall peaks are usually located around 100 mm, and the rainfall in individual months will be more than 170 mm, which is a strong authenticity. The boxplot takes 12 months of the year as the statistical period for the rainfall data, and it can be clearly seen that the 25–75% interval of the dataset shows a wavy cycle, which enables the algorithm to capture the characteristics of the data more accurately and make the simulation results more accurate. The mean value of monthly rainfall in the box-and-line plot for each year is distributed around 50 mm, with outliers in a few years due to irregular storm events, reflecting the real rainfall statistical information.
Parameter setting
The initial regularization parameter λ of the CNN-BILSTM model is 0.002, the initial learning rate η is 0.01, and the initial values of the number of neurons in the three hidden layers H1, H2, and H3 are selected as 100, 20, and 20, respectively. The CNN-BILSTM model has two convolutional layers, and the convolutional layer uses the ReLU function as the activation function to keep the nonlinearity of the output and correct the gradient problem. The BN layer is added to speed up the training process and prevent the problem of exploding or vanishing gradients, and the pooling layer has a pooling window size of 3 by 3 and a step size of 1.
Predicted results
As can be seen in Figure 8, the predicted rainfall results of the SCSSA-CNN-BILSTM model basically coincide with the measured rainfall, and the trends of the predicted and measured values remain consistent, with the main errors reflected in the peak rainfall and the location of the very small values. The overall prediction accuracy is high, and the model has a high reliability.
Comparative model analysis
In Figure 9, it can be clearly seen that the accuracy of the three-algorithm coupled model of SCSSA-CNN-BILSTM and SSA-CNN-BILSTM is significantly better than that of the two-algorithm coupled model of SSA-BILSTM and CNN-BILSTM, but all four algorithms have a certain degree of accuracy and can accurately capture the regularity characteristics of the rainfall data. As shown in Figure 10, the absolute error lines of the predicted and true values for the four models maintain a similar trend. Among them, the SSA-CNN-BILSTM has the lowest absolute error, generally located below 15 mm. There are a small number of error lines that exceed the absolute error surface of 15 mm, which corresponds to the peak rainfall.
Figures 9 and 10 illustrate that all four coupled models have good accuracy for rainfall prediction, but the optimization effect of SCSSA is slightly better than that of SSA. Additionally, the accuracy of the optimized CNN-BILSTM model is significantly better than that of the optimized BILSTM model and the unoptimized BILSTM model. This improvement is due to the incorporation of the positive cosine and the Cosi variation strategies in SCSSA. When solving complex optimization problems, the SCSSA algorithm significantly enhances in global search and local development capabilities compared to the SSA algorithm. As a result, the search efficiency and convergence speed are significantly enhanced. Although both the SSA-BILSTM model and the CNN-BILSTM model can accurately predict the approximate trend of rainfall changes, the fluctuations of their predicted values are always in a small range. The reason is that the model complexity is not enough and may not be able to adequately fit the fluctuation characteristics in the data when dealing with nonlinear or periodic fluctuation data with sudden peak points, which leads to the prediction results floating in a small range.
The correlation coefficient R2, the root mean square error (RMSE), and the mean absolute error (MAE) are used as the evaluation indexes, and the statistical table of the evaluation indexes of the four models and the prediction scatter plot is made to further evaluate the simulation effect of each model. The statistics of the indicators of each model are shown in Table 1.
. | . | SCSSA-CNN-BILSTM . | SSA-CNN-BILSTM . | SCSSA-BILSTM . | CNN-BILSTM . |
---|---|---|---|---|---|
Training period | R2 | 0.9483 | 0.8942 | 0.7412 | 0.6623 |
RMSE | 14.6048 | 18.8998 | 25.9001 | 31.6051 | |
MAE | 9.1897 | 12.5056 | 18.2611 | 22.6101 | |
Forecast period | R2 | 0.9528 | 0.9073 | 0.7628 | 0.6791 |
RMSE | 12.0113 | 16.5935 | 22.3063 | 27.5938 | |
MAE | 7.4132 | 10.0351 | 14.7320 | 18.9636 |
. | . | SCSSA-CNN-BILSTM . | SSA-CNN-BILSTM . | SCSSA-BILSTM . | CNN-BILSTM . |
---|---|---|---|---|---|
Training period | R2 | 0.9483 | 0.8942 | 0.7412 | 0.6623 |
RMSE | 14.6048 | 18.8998 | 25.9001 | 31.6051 | |
MAE | 9.1897 | 12.5056 | 18.2611 | 22.6101 | |
Forecast period | R2 | 0.9528 | 0.9073 | 0.7628 | 0.6791 |
RMSE | 12.0113 | 16.5935 | 22.3063 | 27.5938 | |
MAE | 7.4132 | 10.0351 | 14.7320 | 18.9636 |
In Table 1, the simulation performance of the model is represented by the three metrics, R2, RMSE and MAE, and the bolded represents the metrics results of the SCSSA-CNN-BILSTM model and is the best simulated model among the four compared models. From the table, it can be seen that the accuracy of the four models is SCSSA-CNN-BILSTM, SSA-CNN-BILSTM, SCSSA-BILSTM, and CNN-BILSTM in descending order. The correlation coefficient R2 of CNN-BILSTM in the prediction period is 0.6791, which is 0.0837 lower than the correlation coefficient of the SCSSA-BILSTM model and 0.2282 lower than the correlation coefficient of the SSA-CNN-BILSTM model. This indicates that the accuracy of the BILSTM model with CNN-extracted features is lower than that of the optimized BILSTM model with SCSSA and that the SCSSA optimization algorithm can greatly improve the accuracy of the CNN-BILSTM algorithm. The correlation coefficient R2 of the SSA-CNN-BILSTM model is 0.9073, and the correlation coefficient R2 of the SCSSA-CNN-BILSTM model is 0.9528, which indicates that the SCSSA optimization algorithm is still significantly improved compared to the SSA algorithm, and the SCSSA algorithm reduces the probability of late premature convergence based on the SSA algorithm and reduces the algorithm crashing into the probability of local extremes. It can better balance local development and global exploration, side by side confirming the superiority and effectiveness of the SCSSA algorithm. Figure 11 further shows that the prediction accuracy of SCSSA-CNN-BILSTM is better than that of SSA-CNN-BILSTM, SCSSA-BILSTM, and CNN-BILSTM models and is closer to the measured values.
The high accuracy of SCSSA-CNN-BILSTM comes from the stability and convergence speed of the SCSSA algorithm, the CNN algorithm's ability to capture local and global features of the data, and the BILSTM's ability to capture the correlation information between the past and the future, which are long-term dependencies. Combining the advantages of the three algorithms has resulted in the excellent performance of this model in this rainfall time series prediction.
CONCLUSION
In this paper, we used a predictive coupled model with CNN and BILSTM jointly extracting features and innovatively combined with the SCSSA optimization algorithm to improve the prediction accuracy of the CNN-BILSTM model. We compared it with three models, namely, SSA-CNN-BILSTM, CNN-BILSTM, and SCSSA-BILSTM. The SCSSA-CNN-BILSTM model demonstrates a high level of accuracy and obtains the following conclusions:
1. The SCSSA-CNN-BILSTM model proposed in this paper shows good superiority and high accuracy in the comparison of rainfall prediction models, which fully reflects the excellent feature extraction ability of the CNN-BILSTM model in processing time series. Local spatial features are extracted by the CNN model, BILSTM combines past and future sequence information to analyze the rainfall data, and the SCSSA algorithm is used to optimize the parameter data such as the learning rate and regularization parameter, which solves the problems of CNN-BILSTM in terms of the complexity of parameter processing and the long training time. The reliability of the SCSSA-CNN-BILSTM model prediction was verified through the comparison of the four models, which provides a new idea for hydrological prediction using neural network models.
2. Compared with the CNN-BILSTM model, the optimization treatment by the SSA algorithm can significantly improve the model's prediction accuracy. In the SCSSA-CNN-BILSTM model proposed in this paper, the SCSSA optimization algorithm is a modification of the SSA, which can improve the parameter iteration accuracy and speed, reduce the probability of late premature convergence and the algorithm crashing into the local extremes, and show a good fit with the CNN-BILSTM model, which can further improve the accuracy of the CNN-BILSTM model.
3. The SCSSA-CNN-BILSTM model can cope well with the algorithm convergence problem and the problem of feature extraction. However, the noise problem of the data signal still needs to be further dealt with. In the subsequent research, one can consider introducing the time-frequency analysis method to decompose the original data. This will improve the algorithm's iterative accuracy and increase the model's adaptability to predict different kinds of data.
AUTHOR CONTRIBUTION
All authors contributed to the study conception and design. X.Z. and Y.Y. wrote and edited the manuscript. J.L., Y.Z., and Y.Z. collected the preliminary data. All authors read and approved the final manuscript.
FUNDING
This study was supported by the Support Program for Scientific and Technological Innovation Teams in Universities of Henan Province (24IRTSTHN012) and the National Natural Science Foundation of China, 51779093.
DATA AVAILABILITY STATEMENT
Data cannot be made publicly available; readers should contact the corresponding author for details.
CONFLICT OF INTEREST
The authors declare there is no conflict.