Prediction method and system for dissolved oxygen in river water and medium
Through the random forest model sorting, STL algorithm decomposition and LSTM prediction sub-model combined with the sparrow search algorithm optimization, the problem of poor accuracy of dissolved oxygen prediction in river water bodies is solved, and high-precision and low-cost dissolved oxygen prediction effect is achieved.
Patent Information
- Application Number
- CN202411083846.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-11-26
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prediction accuracy of dissolved oxygen in river water bodies is poor. Traditional physical models rely on a large number of water quality parameters and are complex, and statistical models are difficult to capture nonlinear and non-stationary changes.
Random forest model is used to sort the importance of input variables, combine the STL algorithm to decompose the dissolved oxygen time series, use the LSTM prediction sub-model, and optimize the hyperparameters through the sparrow search algorithm to achieve fully automatic and accurate prediction of dissolved oxygen concentration.
The dissolved oxygen prediction of river water bodies with small data required, high prediction accuracy and low modeling cost is achieved, and the change trend and seasonal characteristics of dissolved oxygen are accurately captured.
Smart Images

Figure CN119026077A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of water quality prediction, and in particular to a method, system and medium for predicting dissolved oxygen in river water. Background Art
[0002] Dissolved oxygen (DO) is one of the most important water quality indicators for evaluating river pollution, and it can directly indicate the status of aquatic ecosystems. Appropriate DO content is a prerequisite for ensuring the normal growth and development of aquatic plants and animals. Low DO levels can lead to hypoxia, which endangers the safety of aquatic organisms. For example, fish will grow slowly or even die; high concentrations of dissolved oxygen can cause excessive growth of organisms, thereby destroying the balance of the ecosystem. Therefore, accurate prediction of DO concentration is helpful for the management and protection of water resources, and can provide strong technical support for decision makers to formulate effective water resources management and pollution control strategies.
[0003] Currently, physical models and statistical models are the mainstream tools for predicting dissolved oxygen. However, physical models, such as Vollenweider and Kirchner-Dillon, require a large number of other water quality parameters to calibrate the model. Due to the availability of data and the over-simplification of complex biochemical reactions within the model, it is still challenging to achieve accurate prediction. Statistical models, such as ARMA and time series analysis models, require the series to follow steady-state changes. However, under the influence of climate change and human activities, the DO content in river water shows strong nonlinearity and non-stationarity, and it is difficult for statistical models to capture its changing process. In summary, the existing technology has poor prediction accuracy for dissolved oxygen in river water. Summary of the invention
[0004] To solve the above problems, the present invention provides a method for predicting dissolved oxygen in river water. This method breaks through the problems of traditional models' reliance on big data and poor prediction accuracy, and provides a fully automatic prediction method with little required data and high prediction accuracy, which can accurately predict the DO concentration in river water.
[0005] To achieve the above object, the present invention provides the following technical solutions.
[0006] A method for predicting dissolved oxygen in a river water body comprises the following steps:
[0007] The meteorology, hydrology and water quality of the river water body are obtained as input variables, and the random forest model is used to rank the input variables in terms of importance to determine the optimal input variables;
[0008] The STL algorithm is used to decompose the dissolved oxygen time series into trend term, seasonal term and residual term, and the LSTM prediction sub-models of dissolved oxygen trend term, seasonal term and residual term are constructed respectively using the optimal input variables.
[0009] The hyperparameters of the LSTM prediction sub-models for dissolved oxygen trend items, seasonal items, and residual items are automatically optimized by using the sparrow search algorithm to obtain the optimized LSTM prediction sub-models for dissolved oxygen trend items, seasonal items, and residual items.
[0010] The dissolved oxygen concentration is predicted by the optimized LSTM prediction sub-model of dissolved oxygen trend term, seasonal term and residual term, and the prediction result of each LSTM prediction sub-model is summed to obtain the prediction result of dissolved oxygen concentration.
[0011] Preferably, it also includes: obtaining the meteorology, hydrology and water quality of the river water body as input variables to construct a candidate input variable library; the candidate input variable library includes daily precipitation, daily average temperature, daily maximum temperature, daily minimum temperature, daily atmospheric pressure, daily evaporation, daily average runoff, daily average flow rate, daily average pH, daily average water temperature, conductivity, turbidity, ammonia nitrogen and permanganate index.
[0012] Preferably, the use of a random forest model to sort the input variables by importance to determine the optimal input variables comprises the following steps:
[0013] All input variables in the candidate input variable library are used as inputs of the random forest to fit the dissolved oxygen concentration;
[0014] The importance of each candidate input variable is calculated using the following formula:
[0015]
[0016]
[0017]
[0018] Among them, MSE m is the mean square error of node m; MSE left and MSE right are the mean square errors of the left and right child nodes respectively; N m is the sample size on node m; N left and N right are the number of samples of the left child node and the right child node respectively; Imp j (t) represents the importance of feature j on a single tree; Imp j Represents the importance of feature j in the random forest;
[0019] Sort by the importance of the input variables. j >10*Imp j +1, then select Imp jThe largest input variable is taken as the optimal input variable; j represents the input variable, and j+1 represents the input variable adjacent to the j variable after being sorted by importance.
[0020] Preferably, the STL algorithm is used to decompose the dissolved oxygen time series into a trend term, a seasonal term and a residual term, as shown in the following formula:
[0021] DO t =ST t +S t +R t
[0022] Among them, DO t represents the dissolved oxygen observation sequence in the river; ST t represents the trend item; S t represents the seasonal term; R t Represents the residual term.
[0023] Preferably, the method of using the optimal input variables to construct LSTM prediction sub-models for dissolved oxygen trend term, seasonal term and residual term respectively comprises the following steps:
[0024] According to the determined optimal input variables, LSTM prediction sub-models for dissolved oxygen trend term, seasonal term and residual term are constructed respectively; wherein the calculation formula of the LSTM prediction sub-model is shown as follows:
[0025] f t =σ(W f ·[h t-1 ,x t ]+b f )
[0026] i t =σ(W i ·[h t-1 ,x t ]+b i )
[0027]
[0028]
[0029] O t =σ(W o ·[h t-1 ,x t ]+b o )
[0030] h t =O t ×tanh(C t )
[0031] Among them, h tRepresents the output of the current cell unit, h t-1 represents the output of the previous cell, x t Represents the input of the current cell, W f , W i , W C , W o 、b f 、b i 、b c and b o is the trainable hyperparameter of the LSTM model, which is continuously updated during the training process. σ and tanh are the activation functions of the model; f t 、i t and O t are the calculation formulas for the forget gate, input gate, and output gate of the LSTM prediction sub-model respectively; C t The cell state.
[0032] Preferably, the automatic optimization of the hyperparameters of the LSTM prediction sub-model of the dissolved oxygen trend term, the seasonal term and the residual term by the sparrow search algorithm comprises the following steps:
[0033] Determine the hyperparameters of the LSTM prediction submodel to be optimized, and define the upper and lower bounds of each hyperparameter value;
[0034] Set the number of sparrows and initialize the sparrow population;
[0035] Define the fitness function to evaluate the performance of each set of hyperparameters on the LSTM prediction sub-model. The fitness calculation formula is as follows:
[0036]
[0037] Where:
[0038] params = (hyperparameter 1, hyperparameter 2, hyperparameter 3 ... hyperparameter n)
[0039] Among them, Y obs Indicates the measured value of dissolved oxygen; Y pre represents the predicted value of the LSTM prediction sub-model; n represents the sample size of dissolved oxygen;
[0040] Determine the optimal solution under the current conditions, and the calculation formula is as follows:
[0041] Best_fitness=min{fitnes_value}
[0042] Best_params=argmin{fitnes_value}
[0043] fitnes value=f(params)
[0044] Among them, min represents the minimum value of fitnes_value of all sparrow groups under the current conditions, and argmin represents the position corresponding to the minimum value, that is, the corresponding sparrow;
[0045] The discoverer is the individual with the best fitness in the group and is responsible for leading the group to find new food sources. The update strategy formula of the discoverer in the optimization process is as follows:
[0046] New_Pos leader =leader+α*rand*(leader-sparrow rand )
[0047] Among them, α is a parameter that controls the update step size; leader is the current optimal finder; sparrow rand Represents a random sparrow in the group; rand is a random number between 0 and 1;
[0048] The follower updates its own position based on the discoverer's position. The update formula is as follows:
[0049] New_Pos fellower =follower+β*rand*(sparrow rand -follower)
[0050] Among them, β is the parameter that controls the update step size; follower represents the current follower; sparrow rand Represents a random sparrow in the population; rand is a random number between 0 and 1.
[0051] The vigilant avoids falling into the local optimum by randomly jumping. The vigilant update formula is as follows:
[0052] New_Pos alert =lower bound +(upper bound -lower bound )*rand
[0053] Among them, upper bound and lower bound Represents the upper and lower bounds of each hyperparameter search space; rand is a random number between 0 and 1;
[0054] The search is repeated until the maximum number of iterations is reached or the difference in fitness values between two adjacent iterations is less than 0.01. The entire optimization process ends and the hyperparameters with the best fitness value are used as the final parameters of the LSTM prediction sub-model.
[0055] A system for predicting dissolved oxygen in a river water body, the system comprising:
[0056] processor;
[0057] a memory having stored thereon a computer program executable on the processor;
[0058] Wherein, when the computer program is executed by the processor, the steps of the method for predicting dissolved oxygen in river water are implemented.
[0059] A computer-readable storage medium stores a data processing program, and when the data processing program is executed by a processor, the steps of the method for predicting dissolved oxygen in a river water body are implemented.
[0060] Beneficial effects of the present invention:
[0061] The present invention proposes a method for predicting dissolved oxygen in river water, which breaks through the problems of many water quality parameters required by traditional methods, large workload of parameter adjustment and poor prediction accuracy, and instead uses some easily available data, and combines input variable selection, time series decomposition, optimization ideas and deep learning models to achieve accurate prediction of DO in river water. The invention has the advantages of less required data, high prediction accuracy and low modeling cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 is a flow chart of a method for predicting dissolved oxygen in a river water body according to an embodiment of the present invention;
[0063] Figure 2 It is a decomposition diagram based on an STL algorithm of a method for predicting dissolved oxygen in a river water body according to an embodiment of the present invention;
[0064] Figure 3 This is a diagram showing the actual effect of predicting dissolved oxygen in river water using a method for predicting dissolved oxygen in river water according to an embodiment of the present invention. DETAILED DESCRIPTION
[0065] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0066] Example 1
[0067] The present invention provides a method for predicting dissolved oxygen in river water, the specific process is as follows: Figure 1 As shown, the following steps are included:
[0068] S1: Obtain the meteorology, hydrology and water quality of the river water body as input variables, and use the random forest model to rank the input variables in order to determine the optimal input variables.
[0069] S2: The STL algorithm is used to decompose the dissolved oxygen time series into trend term, seasonal term and residual term, and the optimal input variables are used to construct LSTM prediction sub-models for the dissolved oxygen trend term, seasonal term and residual term respectively.
[0070] S3: The hyperparameters of the LSTM prediction sub-models for dissolved oxygen trend terms, seasonal terms, and residual terms are automatically optimized through the sparrow search algorithm to obtain the optimized LSTM prediction sub-models for dissolved oxygen trend terms, seasonal terms, and residual terms.
[0071] S4: The dissolved oxygen concentration is predicted by the optimized LSTM prediction sub-models of dissolved oxygen trend term, seasonal term and residual term, and the prediction results of each LSTM prediction sub-model are summed to obtain the prediction result of dissolved oxygen concentration.
[0072] Specific:
[0073] S1: Obtain the meteorology, hydrology and water quality of the river water body as input variables, and use the random forest model to rank the input variables by importance to determine the optimal input variables, including:
[0074] S1.1: Collect some easily accessible data to construct a candidate input variable library. The present invention selects daily precipitation, daily average temperature, daily maximum temperature, daily minimum temperature, daily atmospheric pressure, daily evaporation, daily average river runoff, daily average flow rate, daily average pH, daily average water temperature, conductivity, turbidity, ammonia nitrogen, and permanganate index in the basin as candidate input variables.
[0075] S1.2: Random forest RF was used to screen the variables in the candidate input variable library, and the optimal characteristic variables were finally determined to be runoff, air temperature and pH.
[0076] Among them, the random forest model is a comprehensive algorithm composed of decision trees. Its basic unit is the decision tree DT. The decision tree can be divided into classification tree CT and regression tree RT, which respectively handle classification and regression problems. The Bootstrap method is used to extract multiple samples from the original sample for DT modeling, and then these decision trees are combined, and the average of all DT results is taken as the final regression result. Its mathematical expression is:
[0077]
[0078] Wherein, F(x) represents the target variable, and the target variable in the present invention is dissolved oxygen. i represents a single decision tree, n represents n-dimensional input data of independent variables, and the independent variables in the present invention are all variables in the candidate input variable library.
[0079] Random forest can be used to analyze the explanatory effect of multiple independent variables on the target variable F(x), and can calculate the importance of each variable. The present invention aims to use random forest to determine the main factors affecting the DO content in river water and rank their importance, and then use Imp j >10*Imp j +1 This judgment basis, choose Imp j The largest input variable is considered the optimal input variable.
[0080] The importance of each candidate input variable is calculated using the following formula:
[0081]
[0082]
[0083]
[0084] Among them, MSE m is the mean square error of node m; MSE left and MSE right are the mean square errors of the left and right child nodes respectively; N m is the sample size on node m; N left and N right are the number of samples of the left child node and the right child node respectively; Imp j (t) represents the importance of feature j on a single tree; Imp j Represents the importance of feature j in the random forest;
[0085] Sort by the importance of the input variables. j >10*Imp j +1, then select Imp j The largest input variable is taken as the optimal input variable; j represents the input variable, and j+1 represents the input variable adjacent to the j variable after being sorted by importance.
[0086] S2: The STL algorithm is used to decompose the dissolved oxygen time series into trend term, seasonal term and residual term, and the optimal input variables are used to construct LSTM prediction sub-models for the dissolved oxygen trend term, seasonal term and residual term respectively.
[0087] Among them, STL is a decomposition method widely used in various time series. It can robustly decompose time series into three parts: trend term ST t , Seasonal ItemS t and the residual term R t , the decomposition result can be expressed as: DO t =ST t +S t +R t Compared with other traditional seasonal decompositions (X-12, SEATS), STL has a strong adaptability to outliers in time series and will not affect the algorithm's estimation of trend and seasonal factors due to outliers. The actual decomposition effect of STL is shown in the figure below: Figure 2 shown.
[0088] The construction of LSTM model, such as Figure 3 As shown in Figure 1, in order to overcome the problems of gradient explosion and vanishing that often occur in traditional recurrent neural networks (RNNs), Hochreiter and Schmidhuber (1997) proposed a special structure of neural recurrent neural network - long short-term memory model (LSTM). Different from the traditional recurrent neural network structure (input layer, hidden layer and output layer), LSTM adds special gating devices, input gate, output gate and forget gate, making it particularly suitable for processing and predicting events with a large time span in time series. The model consists of many cell units, each of which stores information at the current time t. The cell unit includes three gating devices, namely the forget gate, input gate and output gate, which control the information flow between cell units. The purpose of the forget gate is to determine which information from the previous block needs to be forgotten. The input gate determines which new information needs to be updated, including that from the forget gate and the current input. The output gate is used to determine which information is finally output. The corresponding formula for the cell update process is as follows:
[0089] f t =σ(W f ·[h t-1 ,x t ]+b f )
[0090] i t =σ(W i ·[h t-1 ,x t ]+b i )
[0091]
[0092]
[0093] O t =σ(W o·[h t-1 ,x t ]+b o )
[0094] h t =O t ×tanh(C t )
[0095] Among them, h t Represents the output of the current cell, ht -1 represents the output of the previous cell, x t Represents the input of the current cell, W f , W i , W C , W o , b f , b i , b c and b o is the trainable hyperparameter of the LSTM model, which is continuously updated during the training process. σ and tanh are the activation functions of the model; f t 、i t and O t are the calculation formulas for the forget gate, input gate, and output gate of the LSTM prediction sub-model; C t The cell state.
[0096] S3: The hyperparameters of the LSTM prediction sub-models for dissolved oxygen trend terms, seasonal terms, and residual terms are automatically optimized through the sparrow search algorithm to obtain the optimized LSTM prediction sub-models for dissolved oxygen trend terms, seasonal terms, and residual terms.
[0097] The Sparrow Search Algorithm (SSA) is a swarm intelligence optimization algorithm that simulates the social behavior of sparrows to achieve global optimization of complex problems. Its advantage is that it can effectively jump out of the local optimum and find the global optimal solution. It also has strong robustness and adaptability. In order to improve the prediction accuracy of the LSTM model and reduce the huge workload brought by the parameter adjustment process, the SSA algorithm is used to automatically optimize the hyperparameters of the LSTM. The SSA algorithm consists of three types of roles: discoverer, follower, and sentinel. Sparrows of different roles have different ways of updating their positions. The search paths of sparrows of different roles are dynamically adjusted in an intelligent heuristic way to find the optimal solution of the objective function, thereby achieving automatic optimization of the LSTM hyperparameters.
[0098] The formula for how the discoverer updates the location is as follows:
[0099]
[0100] in, Represents the position information of the i-th sparrow in the j-th dimension at the t+1 iteration; is the location information of the sparrow in the previous iteration (tth time), M max The maximum number of iterations; α is between 0 and 1; R2 and T s Warning value and safety value; R2 value is between 0 and 1; T s The value is between 0.5 and 1; Q is also a random value; L is a unit row vector of length d.
[0101] The formula for how the follower updates its position is as follows:
[0102]
[0103] in, The best position found by the follower for the next iteration; A is a random matrix with values ranging from -1 to 1; is the worst position of the follower in the global scope; N is the number of sparrows in the population.
[0104] The formula for how the sentinel updates its position is as follows:
[0105]
[0106] in, represents the position with the best fitness in the sparrow population in the current iteration; K is the flight trajectory of the sparrow; f i represents the fitness value of the i-th sparrow; f g and f w They represent the optimal and worst fitness values in the global scope respectively; ε is a constant.
[0107] In each round of iteration, the fitness values of all sparrow individuals are calculated, and they are sorted according to the size of the fitness values to obtain the current global optimal fitness position, and then updated according to the position update strategy of different types of sparrows until the end of the cycle, and the best fitness value in the last round of iteration is taken as the global optimal solution.
[0108] The calculation formula of sparrow population fitness value is:
[0109]
[0110] Where: f(params) represents the function of fitness value; Y obs Indicates the measured value of dissolved oxygen; Y pre Represents the predicted value of the LSTM model; n represents the sample size of dissolved oxygen.
[0111] S3 specifically includes the following steps:
[0112] S3.1: Determine the hyperparameters of the LSTM prediction submodel to be optimized and define the upper and lower bounds of each hyperparameter value.
[0113] S3.2: Set the number of sparrows and initialize the sparrow population.
[0114] S3.3: Define the fitness function to evaluate the performance of each set of hyperparameters on the LSTM prediction sub-model. The fitness calculation formula is as follows:
[0115]
[0116] Where:
[0117] params = (hyperparameter 1, hyperparameter 2, hyperparameter 3 ... hyperparameter n)
[0118] Among them, Y obs Indicates the measured value of dissolved oxygen; Y pre Represents the predicted value of the LSTM prediction sub-model; n represents the sample size of dissolved oxygen.
[0119] S3.4: Determine the optimal solution under the current conditions. The calculation formula is as follows:
[0120] Best_fitness=min{fitnes_value}
[0121] Best_params=argmin{fitnes_value}
[0122] fitnes value =f(params)
[0123] Among them, min represents the minimum value of fitnes_value of all sparrow groups under the current conditions, and argmin represents the position corresponding to the minimum value, that is, the corresponding sparrow.
[0124] S3.5: The discoverer is the individual with the best fitness in the group and is responsible for leading the group to find new food sources. The update strategy formula of the discoverer in the optimization process is as follows:
[0125] New_Pos leader =leader+α*rand*(leader-sparrow rand )
[0126] Among them, α is a parameter that controls the update step size; leader is the current optimal finder; sparrow rand Represents a random sparrow in the population; rand is a random number between 0 and 1.
[0127] S3.6: The follower updates its own position based on the discoverer's position. The update formula is as follows:
[0128] New_Pos fellower =follower+β*rand*(sparrow rand -follower)
[0129] Among them, β is the parameter that controls the update step size; follower represents the current follower; sparrow rand Represents a random sparrow in the population; rand is a random number between 0 and 1.
[0130] S3.7: The sentinel avoids falling into the local optimum by randomly jumping. The sentinel update formula is as follows:
[0131] New_Position=lower bound +(upper bound -lower bound )*rand
[0132] Among them, upper bound and lower bound Represents the upper and lower bounds of each hyperparameter search space; rand is a random number between 0 and 1.
[0133] S3.8: Repeat S3.3 to S3.7 until the maximum number of iterations is reached or the difference in fitness values between two adjacent iterations is less than 0.01. The entire optimization process ends and the hyperparameters with the best fitness values are used as the final parameters of the LSTM prediction sub-model.
[0134] In this embodiment, Figure 3 As shown, in order to evaluate the effectiveness of the present invention in predicting dissolved oxygen in river water, the dissolved oxygen in the river water of the Dahei River, a first-level tributary of the Yellow River, was selected for verification, and the simulation results are as follows:
[0135] The model proposed by the present invention can well capture the changing trend of actual dissolved oxygen, and the predicted value and the measured value have a good fit, especially in some areas where dissolved oxygen has peaks and valleys, the model can also well capture these detailed changes. The NASH coefficient and R2 in the model prediction stage are 0.89 and 0.85 respectively. Figure 3 In general, the method provided by the present invention can well predict the change of dissolved oxygen in river water using very little easily accessible data.
[0136] The above is a method for predicting dissolved oxygen in river water provided by one or more embodiments of this embodiment. Based on the same idea, this embodiment also provides a corresponding system for predicting dissolved oxygen in river water. The specific definition of the system for predicting dissolved oxygen in river water can refer to the definition of the method for predicting dissolved oxygen in river water above, which will not be repeated here. Each module in the above-mentioned system for predicting dissolved oxygen in river water can be implemented in whole or in part through software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above-mentioned modules.
[0137] This embodiment also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 1 A method for predicting dissolved oxygen in river water is provided.
[0138] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0139] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for predicting dissolved oxygen in river water, characterized in that: The following steps are involved: The meteorology, hydrology and water quality of the river water body are obtained as input variables, and the random forest model is used to rank the input variables in terms of importance to determine the optimal input variables; The STL algorithm is used to decompose the dissolved oxygen time series into trend term, seasonal term and residual term, and the LSTM prediction sub-models of dissolved oxygen trend term, seasonal term and residual term are constructed respectively using the optimal input variables. The hyperparameters of the LSTM prediction sub-models for dissolved oxygen trend items, seasonal items, and residual items are automatically optimized by using the sparrow search algorithm to obtain the optimized LSTM prediction sub-models for dissolved oxygen trend items, seasonal items, and residual items. The dissolved oxygen concentration is predicted by the optimized LSTM prediction sub-model of dissolved oxygen trend term, seasonal term and residual term, and the prediction result of each LSTM prediction sub-model is summed to obtain the prediction result of dissolved oxygen concentration.
2. The method for predicting dissolved oxygen in river water according to claim 1, characterized in that: Also includes: The meteorology, hydrology and water quality of the river water body are obtained as input variables to construct a candidate input variable library; the candidate input variable library includes daily precipitation, daily average temperature, daily maximum temperature, daily minimum temperature, daily atmospheric pressure, daily evaporation, daily average runoff, daily average flow velocity, daily average pH, daily average water temperature, conductivity, turbidity, ammonia nitrogen and permanganate index.
3. The method for predicting dissolved oxygen in river water according to claim 2, characterized in that: The random forest model is used to sort the importance of the input variables to determine the optimal input variables, including the following steps: All input variables in the candidate input variable library are used as inputs of the random forest to fit the dissolved oxygen concentration; The importance of each candidate input variable is calculated using the following formula: Among them, MSE m is the mean square error of node m; MSE left and MSE right are the mean square errors of the left and right child nodes respectively; N m is the sample size on node m; N left and N right are the number of samples of the left child node and the right child node respectively; Imp j (t) represents the importance of feature j on a single tree; Imp j Represents the importance of feature j in the random forest; Sort by the importance of the input variables. j >10*Imp j +1, then select Imp j The largest input variable is taken as the optimal input variable; j represents the input variable, and j+1 represents the input variable adjacent to the j variable after being sorted by importance.
4. The method for predicting dissolved oxygen in river water according to claim 1, characterized in that: The STL algorithm is used to decompose the dissolved oxygen time series into trend terms, seasonal terms and residual terms, as shown in the following formula: DO t =ST t +S t +R t Among them, DO t represents the dissolved oxygen observation sequence in the river; ST t represents the trend item; S t represents the seasonal term; R t Represents the residual term.
5. The method for predicting dissolved oxygen in river water according to claim 4, characterized in that: The method of using the optimal input variables to construct LSTM prediction sub-models for dissolved oxygen trend term, seasonal term and residual term respectively includes the following steps: According to the determined optimal input variables, LSTM prediction sub-models for dissolved oxygen trend term, seasonal term and residual term are constructed respectively; wherein the calculation formula of the LSTM prediction sub-model is shown as follows: f t =σ(W f ·[h t-1 ,x t ]+b f ) i t =σ(W i ·[h t-1 ,x t ]+b i ) The t =σ(W o ·[h t-1 ,x t ]+b o ) h t =O t ×tanh(C t ) Among them, h t Represents the output of the current cell unit, h t-1 represents the output of the previous cell, x t Represents the input of the current cell, W f , W i , W C , W o , b f , b i , b c and b o is the trainable hyperparameter of the LSTM model, which is continuously updated during the training process. σ and tanh are the activation functions of the model; f t 、i t and O t are the calculation formulas for the forget gate, input gate, and output gate of the LSTM prediction sub-model; C t The cell state.
6. The method for predicting dissolved oxygen in river water according to claim 5, characterized in that: The method of automatically optimizing the hyperparameters of the LSTM prediction sub-model of the dissolved oxygen trend term, the seasonal term and the residual term by using the sparrow search algorithm comprises the following steps: Determine the hyperparameters of the LSTM prediction submodel to be optimized, and define the upper and lower bounds of each hyperparameter value; Set the number of sparrows and initialize the sparrow population; Define the fitness function to evaluate the performance of each set of hyperparameters on the LSTM prediction sub-model. The fitness calculation formula is as follows: Where params is hyperparameter 1, hyperparameter 2, hyperparameter 3…hyperparameter n; Among them, Y obs Indicates the measured value of dissolved oxygen; Y pre represents the predicted value of the LSTM prediction sub-model; n represents the sample size of dissolved oxygen; Determine the optimal solution under the current conditions. The calculation formula is as follows: Best_fintness=min{fitnes_value} Best_params=argmin{fitnes_value} fitness value =f(params) Among them, min represents the minimum value of fitnes_value of all sparrow groups under the current conditions, and argmin represents the position corresponding to the minimum value, that is, the corresponding sparrow; The discoverer is the individual with the best fitness in the group and is responsible for leading the group to find new food sources. The update strategy formula of the discoverer in the optimization process is as follows: New_Pos leader =leader+α*rand*(leader-sparrow rand ) Among them, α is a parameter that controls the update step size; leader is the current optimal finder; sparrow rand Represents a random sparrow in the group; rand is a random number between 0 and 1; The follower updates its own position based on the discoverer's position. The update formula is as follows: New_Pos fellower =follower+β*rand*(sparrow rand -follower) Among them, β is the parameter that controls the update step size; follower represents the current follower; sparrow rand Represents a random sparrow in the group; rand is a random number between 0 and 1; The vigilant avoids falling into the local optimum by randomly jumping. The vigilant update formula is as follows: New_Pos alert =lower bound +(upper bound -lower bound )*rand Among them, upper bound and lower bound Represents the upper and lower bounds of each hyperparameter search space; rand is a random number between 0 and 1; The search is repeated until the maximum number of iterations is reached or the difference in fitness values between two adjacent iterations is less than 0.
01. The entire optimization process ends and the hyperparameters with the best fitness value are used as the final parameters of the LSTM prediction sub-model.
7. A system for predicting dissolved oxygen in river water, characterized in that: The system comprises: processor; a memory having stored thereon a computer program executable on the processor; Wherein, when the computer program is executed by the processor, the steps of the method for predicting dissolved oxygen in river water as described in any one of claims 1 to 6 are implemented.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a data processing program, and when the data processing program is executed by a processor, the steps of the method for predicting dissolved oxygen in a river water body according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Dissolved oxygen estimation method and device, equipment and storage medium
CN113504348A
Real-time prediction method for nitrogen oxide concentration of flue gas system of thermal power plant based on random forest
CN116227663A
Network flow prediction system based on time sequence decomposition
CN116992986A
Water body dissolved oxygen content prediction method, related device and storage medium
CN118072856A
Correlation recurrent unit for improving prediction performance of time-series data and correlation recurrent neural network
US20230267304A1
