Water quality prediction method and device, computer equipment, storage medium and program product
By combining the sliding window method, gray prediction model and long-term memory network model, the existing water quality prediction methods are solved, and high-precision and continuous water quality prediction are achieved, which can effectively deal with sudden water pollution.
Patent Information
- Application Number
- CN202510003283.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-05-13
AI Technical Summary
The existing water quality prediction methods have the problem of insufficient adaptability to water quality prediction results that cannot meet the continuity requirements, the prediction accuracy is low, and the problem is insufficient in adaptability to sudden water pollution.
By obtaining lake water quality sample data, dividing it into training sets and test sets, data processing is performed using sliding window method and gray prediction model, prediction is performed by combining long and short-term memory network models, and the prediction results of the two models are fused through weighted summing.
It improves the accuracy and continuity of the water quality prediction results, enhances the model's adaptability and generalization ability to different water quality conditions, improves the adaptability to sudden water pollution, and can adjust the weights in real time to adapt to the detection standards of different water areas.
Smart Images

Figure CN119993306A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of water quality prediction, and in particular to a water quality prediction method, device, computer equipment, storage medium and program product. Background Art
[0002] Water quality prediction is the basis of water environment management. In the existing technology, water environment conditions are complicated and water quality prediction is difficult.
[0003] For example, when the stability of water quality sample data does not meet the requirements, the changing characteristics of water quality cannot be captured, resulting in the problem that the water quality prediction results cannot meet the continuity requirements and the prediction accuracy is low. Alternatively, when the water quality sample data does not change significantly for a long time or the noise is large, the changing characteristics of water quality cannot be effectively captured, resulting in insufficient adaptability to sudden water pollution.
[0004] With respect to the above-mentioned related technologies, the inventors have found that the existing water quality prediction methods have the problems that the water quality prediction results cannot meet the continuity requirements, the prediction accuracy is low, and the adaptability to sudden water pollution is insufficient. Summary of the invention
[0005] In order to make the water quality prediction results meet the continuity requirements, improve the accuracy of water quality prediction results and solve the problem of insufficient adaptability to sudden water pollution, the present application provides a water quality prediction method, device, computer equipment, storage medium and program product.
[0006] In a first aspect, the present application provides a water quality prediction method.
[0007] This application is achieved through the following technical solutions:
[0008] A water quality prediction method comprises the following steps:
[0009] Obtain lake water quality sample data;
[0010] Dividing the lake water quality sample data into a training set and a test set;
[0011] According to a preset time interval, the training set is processed and accumulated by a sliding window method to obtain first training data, so as to construct a grey prediction model for predicting lake water quality data at a future moment;
[0012] Performing differential processing on the training set, converting it into supervised learning data and scaling it to obtain second training data, so as to train a pre-built long short-term memory network model for predicting lake water quality data at a future moment;
[0013] Based on the same time point, the lake water quality data at the future moment predicted by the grey prediction model and the lake water quality data at the future moment predicted by the long short-term memory network model are weightedly summed according to different preset weight values to obtain the target water quality data at the future moment.
[0014] In a preferred example, the present application may be further configured as follows: the step of processing the training set and accumulating the training set by a sliding window method at a preset time interval to obtain the first training data includes:
[0015] Divide the target data in the training set according to preset time intervals to obtain an original time series data set;
[0016] The non-negative elements in the original time series data set are accumulated in sequence to obtain a target time series data set as the first training data.
[0017] In a preferred example, the present application can be further configured as follows: the step of constructing the grey prediction model includes:
[0018] Substituting the first training data into a preset grey differential equation to solve a first parameter and a second parameter in the grey differential equation;
[0019] Substituting the first parameter and the second parameter into the grey differential equation to obtain an independent variable of the grey differential equation;
[0020] De-accumulating the independent variable to obtain an initial moment prediction value expression of the lake water quality sample data;
[0021] The grey prediction model is obtained by using the initial moment prediction value expression in combination with the preset initial conditions and the first training data.
[0022] In a preferred example, the present application can be further configured as follows: the long short-term memory network model includes:
[0023] An input gate is used to receive lake water quality sample data at a certain moment, determine its update part and new candidate value part in the unit state, and obtain a first result;
[0024] A forget gate, used for receiving the water quality prediction data at the previous moment, determining the degree of retention or forgetting thereof in the unit state, and obtaining a second result;
[0025] The output gate calculates the water quality prediction result according to the first result and the second result, combined with the lake water quality sample data at a certain moment of input, as the state of the long short-term memory network model after training the lake water quality sample data at a certain moment of input, and updates the unit state.
[0026] In a preferred example, the present application can be further configured as follows: the steps of training a pre-built long short-term memory network model for predicting lake water quality data at future moments include:
[0027] Initializing weights and bias terms in the long short-term memory network model;
[0028] Inputting the second training data into the long short-term memory network model for forward propagation, and calculating the hidden state and output of each step;
[0029] Defining a loss function of the long short-term memory network model, and calculating the gradient through a back-propagation algorithm to update the weights and bias items in the long short-term memory network model;
[0030] Using a preset optimizer to train the long short-term memory network model and adjust hyperparameters;
[0031] The long short-term memory network model is verified by using the test set until the mean square error of the long short-term memory network model reaches a preset requirement, and the long short-term memory network model is output.
[0032] In a preferred example, the present application can be further configured as follows: the sampling step of the lake water quality sample data includes:
[0033] Sampling sensors are set within a preset underwater position of the lake water, wherein the sampling sensors include a turbidity sensor, a conductivity sensor and an ammonia nitrogen sensor to obtain water turbidity, conductivity and ammonia nitrogen concentration respectively;
[0034] The lake water quality sample data collected by the sampling sensor is extracted at preset time intervals to obtain a time series water quality sample data set as the lake water quality sample data, wherein any element of the time series water quality sample data set includes a set consisting of water turbidity, conductivity and ammonia nitrogen concentration.
[0035] In a second aspect, the present application provides a water quality prediction device.
[0036] This application is achieved through the following technical solutions:
[0037] A water quality prediction device, comprising:
[0038] Data sample module, used to obtain lake water quality sample data;
[0039] A data partitioning module, used for partitioning the lake water quality sample data into a training set and a test set;
[0040] A grey prediction model module is used to process the training set and accumulate it by a sliding window method at preset time intervals to obtain first training data, so as to construct a grey prediction model for predicting lake water quality data at future moments;
[0041] A long short-term memory network model module is used to perform differential processing on the training set, convert it into supervised learning data and scale it to obtain second training data, so as to train a pre-built long short-term memory network model for predicting lake water quality data at future moments;
[0042] The water quality prediction module is used to perform weighted summation of the lake water quality data at the future moment predicted by the grey prediction model and the lake water quality data at the future moment predicted by the long short-term memory network model based on the same time point according to different preset weight values to obtain the target water quality data at the future moment.
[0043] In a third aspect, the present application provides a computer device.
[0044] This application is achieved through the following technical solutions:
[0045] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the above-mentioned water quality prediction methods when executing the computer program.
[0046] In a fourth aspect, the present application provides a computer-readable storage medium.
[0047] This application is achieved through the following technical solutions:
[0048] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any one of the above-mentioned water quality prediction methods are implemented.
[0049] In a fifth aspect, the present application provides a computer program product.
[0050] This application is achieved through the following technical solutions:
[0051] A computer program product comprises a computer program, wherein when the computer program is executed by a processor, the steps of any one of the above-mentioned water quality prediction methods are implemented.
[0052] In summary, compared with the prior art, the technical solution provided by this application has at least the following beneficial effects:
[0053] Acquire lake water quality sample data as the training data basis for subsequent models and the data basis for water quality prediction; divide the lake water quality sample data into a training set and a test set; process the training set through a sliding window method and accumulate it at preset time intervals to weaken the randomness of the collected water quality data and make the water quality data more regular, thereby obtaining the first training data to construct a gray prediction model for predicting lake water quality data at future moments, which is conducive to capturing the changing characteristics of water quality data and is suitable for predicting lake water quality data with a small amount of data and containing uncertain information; perform differential processing on the training set to stabilize the collected water quality data to a certain extent, and then convert it into supervised learning data and scale it to obtain the second training data to train the pre-constructed long short-term memory network model for predicting lake water quality data at future moments , which can effectively capture the nonlinear relationship and long-term dependence in time series data; finally, based on the same time point, the lake water quality data at the future moment predicted by the grey prediction model and the lake water quality data at the future moment predicted by the long short-term memory network model are weighted and summed according to the preset different weight values to obtain the target water quality data at the future moment, so as to utilize the grey prediction model and the long short-term memory network model to complement each other and improve the accuracy of water quality prediction results. By integrating the prediction results of the two models, the adaptability of the model to different water quality conditions is enhanced, and the generalization ability of the model is improved. The weights are adjusted in real time according to the prediction results. The water quality prediction accuracy is higher and can adapt to different detection standards in different waters, which improves the problem of insufficient adaptability in the face of sudden water pollution. At the same time, the water quality prediction results can meet the continuity requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 A schematic diagram of the overall process of a water quality prediction method provided for an exemplary embodiment of the present application.
[0055] Figure 2 A structural block diagram of a long short-term memory network model of a water quality prediction method provided as an exemplary embodiment of the present application.
[0056] Figure 3 A comparison chart of prediction results of a grey prediction model and a long short-term memory network model for a water quality prediction method provided as an exemplary embodiment of the present application.
[0057] Figure 4 A structural block diagram of a water quality prediction device provided as an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0058] This specific embodiment is merely an explanation of the present application and is not a limitation of the present application. After reading this specification, those skilled in the art may make modifications to the present embodiment without any creative contribution as needed, but such modifications are protected by the patent law as long as they are within the scope of the claims of the present application.
[0059] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0060] In addition, the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article, unless otherwise specified, generally means that the associated objects before and after are in an "or" relationship.
[0061] In the existing technology, when using the SARIMA model to predict river water quality, there are certain requirements for the stability of water quality data. It is necessary to determine whether the time series of water quality data is a stable series. It is easy to fail to capture the changing characteristics of water quality due to the stability problem of water quality data, and thus fail to obtain continuous and accurate water quality prediction results. At the same time, when SARIMA is combined with deep learning, it will use more computing resources, and the prediction technology will be complex and costly.
[0062] Furthermore, there are situations in the water quality sampling data where the data does not change significantly in a long sequence and the sample noise is large, which reduces the predictive performance of the model and causes the model to be unable to capture the changing characteristics of the water quality data. Furthermore, in the real-time sampling and prediction of water quality data, faced with sudden parameter changes, the prediction model that captures medium and long periods cannot effectively capture the changing characteristics of the water quality data and predict the changes, resulting in insufficient adaptability to sudden water pollution.
[0063] In order to solve the problems that it is difficult to capture the changing characteristics of water quality values due to the long cycle of water quality data changes, the large sample noise makes it difficult to capture the characteristics of water quality parameters, and the time series of water quality data with nonlinear and non-stationary relationships are difficult to predict, and to reduce the complexity and cost of prediction technology, this application combines the grey prediction model and the long short-term memory network LSTM model to predict the lake water quality data at future times. Based on the same time point, the prediction results of the two are weighted and summed according to different preset weight values to obtain the target water quality data at future times, so that the water quality prediction results meet the continuity requirements, improve the accuracy of the water quality prediction results and the problem of insufficient adaptability to sudden water pollution.
[0064] The embodiments of the present application are further described in detail below in conjunction with the drawings in the specification.
[0065] Reference Figure 1 , an embodiment of the present application provides a water quality prediction method, and the main steps of the method are described as follows.
[0066] S1: Obtain lake water quality sample data;
[0067] S2: Dividing the lake water quality sample data into a training set and a test set;
[0068] S3: According to a preset time interval, the training set is processed and accumulated by a sliding window method to obtain first training data, so as to construct a grey prediction model for predicting lake water quality data at a future moment;
[0069] S4: performing differential processing on the training set, converting it into supervised learning data and scaling it to obtain second training data, so as to train a pre-built long short-term memory network model for predicting lake water quality data at future moments;
[0070] S5: Based on the same time point, the lake water quality data at the future moment predicted by the grey prediction model and the lake water quality data at the future moment predicted by the long short-term memory network model are weightedly summed according to different preset weight values to obtain the target water quality data at the future moment.
[0071] Specifically, the sampling steps for lake water quality sample data include:
[0072] Sampling sensors are set within a preset underwater position of the lake water, wherein the sampling sensors include a turbidity sensor, a conductivity sensor and an ammonia nitrogen sensor to obtain water turbidity, conductivity and ammonia nitrogen concentration respectively;
[0073] The lake water quality sample data collected by the sampling sensor is extracted at preset time intervals to obtain a time series water quality sample data set as the lake water quality sample data, wherein any element of the time series water quality sample data set includes a set consisting of water turbidity, conductivity and ammonia nitrogen concentration.
[0074] For example, the sampling position of the sampling sensor can be set at 1-2m underwater, and the turbidity sensor, conductivity sensor and ammonia nitrogen sensor can be set at the same height and staggered. By sampling the lake water quality in real time, the sampling process cannot be interrupted, and the original water quality data in sequence every minute is obtained. The water quality data is extracted at intervals of 20 minutes to obtain a time series water quality sample data set, that is, the lake water quality sample data.
[0075] The lake water quality sample data is divided into a training set and a test set, for example, the ratio of 8:2. The training set is used for model construction and training, and the test set is used for model performance testing. The test set is actually the time extension of the training set.
[0076] Then, the training set is processed and accumulated through the sliding window method at preset time intervals, including first dividing the water quality data in the training set into original data at specified time intervals through the sliding window method, then accumulating the original data, and accumulating the historical data to obtain the first training data, so as to construct a gray prediction model for predicting the lake water quality data at future times.
[0077] In one embodiment, the step of processing the training set by a sliding window method and accumulating the training set at a preset time interval to obtain the first training data includes:
[0078] Divide the target data in the training set according to preset time intervals to obtain an original time series data set;
[0079] The non-negative elements in the original time series data set are accumulated in sequence to obtain a target time series data set as the first training data, which can meet the data requirements of the grey prediction model.
[0080] The target data is turbidity water quality data, which is helpful to improve the model's insufficient adaptability to sudden water pollution.
[0081] The accumulation principle is: the nth accumulated data = the nth original data + the n-1th accumulated data.
[0082] For example, the original data: [
[338] ,
[338] ,
[338] ,
[337] ,
[337] ], there are no negative numbers in the original data; the first training data: [
[338] ,
[676] ,
[1014] ,
[1351] ,
[1688] ].
[0083] Furthermore, the training set is differentially processed, converted into supervised learning data and scaled to obtain second training data, so as to train a pre-built long short-term memory network model for predicting lake water quality data at future moments.
[0084] The training set is differentially processed using a differential function to convert the water quality data time series into supervised learning data, which is then scaled using a scaling function to obtain the second training data. The LSTM model of the long short-term memory network includes an LSTM layer and a fully connected layer.
[0085] In one embodiment, before the step of dividing the target data in the training set according to preset time intervals to obtain the original time series data set, the step further includes:
[0086] Data preprocessing is performed on the divided turbidity water quality data, including data cleaning, normalization and filling missing values, to improve the validity of the target data in the training set, increase the quantity, and thus help improve the generalization ability of the model.
[0087] Finally, based on the same time point, the lake water quality data at future moments predicted by the grey prediction model and the lake water quality data at future moments predicted by the long short-term memory network model are weightedly summed according to different preset weight values to obtain the target water quality data at future moments.
[0088] By using the gray prediction model and the LSTM model, the water quality at the same time point is predicted, and the prediction results are weighted and summed according to different weights. The weights are adjusted in real time according to the prediction results. Different weights are assigned to different models according to the prediction performance of the model (such as the size of the error), and the water quality prediction accuracy is higher.
[0089] For example, the target water quality data at the future moment = the predicted value of the LSTM model × 7 / 10 + the predicted value of the gray prediction model × 3 / 10. "7 / 10" and "3 / 10" represent the different weights of the two models.
[0090] In one embodiment, the step of constructing the grey prediction model includes:
[0091] Substituting the first training data into a preset grey differential equation to solve a first parameter and a second parameter in the grey differential equation;
[0092] Substituting the first parameter and the second parameter into the grey differential equation to obtain an independent variable of the grey differential equation;
[0093] De-accumulating the independent variable to obtain an initial moment prediction value expression of the lake water quality sample data;
[0094] The grey prediction model is obtained by using the initial moment prediction value expression in combination with the preset initial conditions and the first training data.
[0095] Specifically, before constructing the grey prediction model GM(1,1), the original non-negative data sequence is first accumulated to weaken the randomness of the data and obtain a new regular data sequence. Suppose the original data sequence is:
[0096] X (0) =[X (0) (1),X (0) (2),…,X (0) (n)]
[0097] Accumulate it once to get the new generated data (AGO):
[0098] X (1) =[X (1) (1),X (1) (2),…,X (1) (n)],
[0099] in:
[0100]
[0101] Next, the model is built based on the accumulated data sequence, assuming that it satisfies the following grey differential equation:
[0102]
[0103] Among them, a and b are the parameters that need to be solved, and t is the time variable.
[0104] By using the least squares method, we can get the estimated values of parameters a and b.
[0105] The solution process involves constructing the following matrix equation:
[0106]
[0107] By solving this matrix equation, we can get the values of a and b.
[0108] Furthermore, through the a and b parameters, the solution of the grey differential equation is obtained:
[0109]
[0110] The original data X can be obtained by inverse accumulation (IAGO, Inverse Accumulated Generating Operation) (0) Predicted value of (t):
[0111] X (0) (t) = X (1) (t)-X (1) (t-1)
[0112] Finally, using the above formula, by giving the initial conditions and the accumulated generated sequence, solving the grey prediction model, we can get the water quality prediction result at a certain moment in the future, and predict the water quality value at the future moment, including:
[0113] According to the solution of grey differential equation X (1) (t), predict and accumulate generated data:
[0114]
[0115] According to the solution of grey differential equation X (1) (t), calculate X (0) The predicted value of (t), that is, the predicted value of the original data:
[0116] X (0) (t) = X (1) (t)-X (1) (t-1)
[0117] The prediction formula of the grey prediction model GM (1,1) is to use the solution of the grey differential equation and the inverse cumulative generation formula to reverse the cumulative generation sequence to deduce the future value of the original data sequence. The final grey prediction model formula is as follows:
[0118]
[0119] The grey prediction model GM (1,1) model is used to predict water quality data containing uncertain information.
[0120] The prediction accuracy of the grey prediction model is evaluated by calculating the average value, variance, residual variance, posterior difference ratio and small error probability of historical data. For example, when the posterior difference ratio of the grey prediction model is less than 0.35 and the small error probability is greater than 0.95, it is determined that the accuracy of the constructed grey prediction model meets the requirements, and the prediction result of the grey prediction model is output.
[0121] In one embodiment, the long short-term memory network model includes:
[0122] An input gate is used to receive lake water quality sample data at a certain moment, determine its update part and new candidate value part in the unit state, and obtain a first result;
[0123] A forget gate, used for receiving the water quality prediction data at the previous moment, determining the degree of retention or forgetting thereof in the unit state, and obtaining a second result;
[0124] The output gate calculates the water quality prediction result according to the first result and the second result, combined with the lake water quality sample data at a certain moment of input, as the state of the long short-term memory network model after training the lake water quality sample data at a certain moment of input, and updates the unit state.
[0125] Specifically, refer to Figure 2 , the LSTM model includes: input gate, forget gate and output gate. Xt represents the water quality data at a certain moment, which is processed in the input gate (in the blue box) after being input into the model. ht-1 is equal to the predicted data yt-1 at the previous moment, which is processed in the forget gate (in the yellow box) after being input into the model. Ct-1 represents the state of LSTM after each training of water quality input data, combined with the output results of the forget gate and input gate, and calculated in the output gate (in the green box) combined with the current input water quality data to obtain the predicted result yt.
[0126] Among them, the forget gate determines which information should be discarded from the cell state. It uses a sigmoid activation function to output a value between 0 and 1, indicating the degree to which each element in the cell state is retained or forgotten.
[0127] ft=σ(Wf·[ht-1,xt]+bf)ft=σ(Wf·[ht-1,xt]+bf)
[0128] Where ft is the output of the forget gate at the tth time step, Wf is the weight of the forget gate, ht-1 is the hidden state of the previous time step, xt is the input of the current time step, bf is the bias term, and σ is the sigmoid function.
[0129] The input gate determines which new information will be stored in the cell state. It consists of two parts: a sigmoid layer that determines which values will be updated and a tanh layer that provides values for new candidate values. The specific formula is as follows:
[0130] it=σ(Wi·[ht-1,xt]+bi)it
[0131] =σ(Wi·[ht-1,xt]+bi)C~t
[0132] =tanh(WC·[ht-1,xt]+bC)C~t
[0133] =tanh(WC · [ht-1, xt] + bC)
[0134] Among them, it is the output of the input gate, C~t is the candidate unit state, Wi and WC are the preset weights, and bi and bC are bias terms.
[0135] The cell state is the core of LSTM, which carries information about the input sequence across time steps. The update of the cell state combines the information of the forget gate and the input gate.
[0136] Ct=ft*Ct-1+it*C~t Ct=ft*Ct-1+it*C~t
[0137] Among them, Ct is the cell state at the current time step, and Ct-1 is the cell state at the previous time step.
[0138] The output gate determines what information should be output based on the hidden state calculated based on the cell state. It uses a sigmoid layer to decide each part of the hidden state to output, and then uses a tanh layer to weight the cell state to calculate the final output, including:
[0139] ot=σ(Wo·[ht-1,xt]+bo)ot
[0140] =σ(Wo·[ht-1,xt]+bo)ht
[0141] =ot*tanh(Ct)ht
[0142] =ot*tanh(Ct)
[0143] Among them, ot is the output of the output gate, ht is the hidden state of the current time step, Wo is the weight, and bo is the bias term.
[0144] In one embodiment, the step of training a pre-built long short-term memory network model for predicting lake water quality data at a future time includes:
[0145] Initializing weights and bias terms in the long short-term memory network model;
[0146] Inputting the second training data into the long short-term memory network model for forward propagation, and calculating the hidden state and output of each step;
[0147] Defining a loss function of the long short-term memory network model, and calculating the gradient through a back-propagation algorithm to update the weights and bias items in the long short-term memory network model;
[0148] Using a preset optimizer to train the long short-term memory network model and adjust hyperparameters;
[0149] The long short-term memory network model is verified by using the test set until the mean square error of the long short-term memory network model reaches a preset requirement, and the long short-term memory network model is output.
[0150] By creating an LSTM model class and defining related parameters, the weights and bias items in the LSTM network are randomly initialized and adjusted through the backpropagation algorithm during the training process.
[0151] The second training data is input into the initialized long short-term memory network model for forward propagation (Forward Pass). Given the input sequence, forward propagation is performed through the LSTM network to calculate the hidden state and output of each step.
[0152] Also, define the loss function of the long short-term memory network model, such as using the cross entropy loss function, and calculate the gradient through the back propagation algorithm to update the long short-term memory network parameters.
[0153] Use preset optimizers to train the long short-term memory network model, such as SGD, Adam, etc., and adjust hyperparameters to optimize the performance of the LSTM network.
[0154] Finally, the test set is used to verify the long short-term memory network model until the mean square error of the long short-term memory network model reaches the preset requirements, the training is completed, and the long short-term memory network model is output.
[0155] By defining the loss function and optimizer, the training set data is input into the LSTM model for training, and the performance of the model is evaluated on the test set, such as using MSE as an indicator, so that the trained LSTM model can effectively process water quality sequence data and capture its long-term dependencies. It can also perform well in tasks such as language models, time series prediction, and natural language processing.
[0156] Reference Figure 3 ,The comparison of the prediction results of the grey prediction model and the ,long short-term memory network model is shown in the figure.
[0157] In summary, a water quality prediction method obtains lake water quality sample data as the training data basis of subsequent models and the data basis for water quality prediction; divides the lake water quality sample data into a training set and a test set; processes the training set through a sliding window method and accumulates it according to a preset time interval, weakens the randomness of the collected water quality data, and makes the water quality data more regular, thereby obtaining the first training data to construct a gray prediction model for predicting the lake water quality data at future moments, which is conducive to capturing the changing characteristics of water quality data and is suitable for predicting lake water quality data with a small amount of data and containing uncertain information; performs differential processing on the training set to make the collected water quality data stable to a certain extent, and then converts it into supervised learning data and scales it to obtain the second training data to train the pre-constructed long short-term memory network model for predicting the future moments. The lake water quality data at each moment can effectively capture the nonlinear relationship and long-term dependence in time series data; finally, based on the same time point, the lake water quality data at the future moment predicted by the grey prediction model and the lake water quality data at the future moment predicted by the long short-term memory network model are weighted and summed according to the preset different weight values to obtain the target water quality data at the future moment, so as to utilize the grey prediction model and the long short-term memory network model to complement each other and improve the accuracy of water quality prediction results. By integrating the prediction results of the two models, the adaptability of the model to different water quality conditions is enhanced, and the generalization ability of the model is improved. The weights are adjusted in real time according to the prediction results, which can adapt to different detection standards in different waters. The water quality prediction accuracy is higher, which improves the problem of insufficient adaptability to sudden water pollution. At the same time, the water quality prediction results can meet the continuity requirements.
[0158] A water quality prediction method can quickly adjust model parameters through a real-time feedback mechanism to adapt to different detection standards in different waters. When faced with sudden changes in water quality parameters, it can effectively capture and predict short-term changes in water quality, thereby improving the model's adaptability to sudden water pollution and improving the problem of insufficient adaptability to sudden water pollution.
[0159] A water quality prediction method optimizes the parameter adjustment and model training process, reduces the computational requirements for large-scale data sets, shortens training time, and improves the efficiency of model training.
[0160] Compared with traditional data governance technologies, a water quality prediction method simplifies the data processing process and reduces dependence on multiple fields and tools, thereby reducing the complexity and cost of technology implementation.
[0161] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0162] Reference Figure 4 The present application also provides a water quality prediction device, which corresponds one-to-one to a water quality prediction method in the above embodiment. The water quality prediction device includes:
[0163] Data sample module, used to obtain lake water quality sample data;
[0164] A data partitioning module, used for partitioning the lake water quality sample data into a training set and a test set;
[0165] A grey prediction model module is used to process the training set and accumulate it by a sliding window method at preset time intervals to obtain first training data, so as to construct a grey prediction model for predicting lake water quality data at future moments;
[0166] A long short-term memory network model module is used to perform differential processing on the training set, convert it into supervised learning data and scale it to obtain second training data, so as to train a pre-built long short-term memory network model for predicting lake water quality data at future moments;
[0167] The water quality prediction module is used to perform weighted summation of the lake water quality data at the future moment predicted by the grey prediction model and the lake water quality data at the future moment predicted by the long short-term memory network model based on the same time point according to different preset weight values to obtain the target water quality data at the future moment.
[0168] For the specific definition of a water quality prediction device, please refer to the definition of a water quality prediction method above, which will not be repeated here.
[0169] Each module in the above-mentioned water quality prediction device can be implemented in whole or in part by software, hardware and a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.
[0170] In one embodiment, a computer device is provided, which may be a server. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, any of the above-mentioned water quality prediction methods is implemented.
[0171] In one embodiment, a computer-readable storage medium is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, any one of the above-mentioned water quality prediction methods is implemented.
[0172] In one embodiment, a computer program product is provided, which includes a computer program, and when the computer program is executed by a processor, any one of the above-mentioned water quality prediction methods is implemented.
[0173] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments 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, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. When the computer program is executed, it may 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 the present application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0174] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above.
Claims
1. A water quality prediction method, characterized in that: The following steps are included: Obtain lake water quality sample data; Dividing the lake water quality sample data into a training set and a test set; According to a preset time interval, the training set is processed and accumulated by a sliding window method to obtain first training data, so as to construct a grey prediction model for predicting lake water quality data at a future moment; Performing differential processing on the training set, converting it into supervised learning data and scaling it to obtain second training data, so as to train a pre-built long short-term memory network model for predicting lake water quality data at a future moment; Based on the same time point, the lake water quality data at the future moment predicted by the grey prediction model and the lake water quality data at the future moment predicted by the long short-term memory network model are weightedly summed according to different preset weight values to obtain the target water quality data at the future moment.
2. The water quality prediction method according to claim 1, characterized in that: The step of processing the training set by a sliding window method and accumulating the training set at a preset time interval to obtain the first training data includes: Divide the target data in the training set according to preset time intervals to obtain an original time series data set; The non-negative elements in the original time series data set are accumulated in sequence to obtain a target time series data set as the first training data.
3. The water quality prediction method according to claim 1, characterized in that: The steps of constructing the grey prediction model include: Substituting the first training data into a preset grey differential equation to solve a first parameter and a second parameter in the grey differential equation; Substituting the first parameter and the second parameter into the grey differential equation to obtain an independent variable of the grey differential equation; De-accumulating the independent variable to obtain an initial moment prediction value expression of the lake water quality sample data; The grey prediction model is obtained by using the initial moment prediction value expression in combination with the preset initial conditions and the first training data.
4. The water quality prediction method according to claim 1, characterized in that: The long short-term memory network model includes: An input gate is used to receive lake water quality sample data at a certain moment, determine its update part and new candidate value part in the unit state, and obtain a first result; A forget gate, used for receiving the water quality prediction data at the previous moment, determining the degree of retention or forgetting thereof in the unit state, and obtaining a second result; The output gate calculates the water quality prediction result according to the first result and the second result, combined with the lake water quality sample data at a certain moment of input, as the state of the long short-term memory network model after training the lake water quality sample data at a certain moment of input, and updates the unit state.
5. The water quality prediction method according to claim 1, characterized in that: The steps of training a pre-built LSTM network model to predict lake water quality data at future moments include: Initializing weights and bias terms in the long short-term memory network model; Inputting the second training data into the long short-term memory network model for forward propagation, and calculating the hidden state and output of each step; Defining a loss function of the long short-term memory network model, and calculating the gradient through a back-propagation algorithm to update the weights and bias items in the long short-term memory network model; Using a preset optimizer to train the long short-term memory network model and adjust hyperparameters; The long short-term memory network model is verified by using the test set until the mean square error of the long short-term memory network model reaches a preset requirement, and the long short-term memory network model is output.
6. The water quality prediction method according to any one of claims 1 to 5, characterized in that: The sampling steps of the lake water quality sample data include: Sampling sensors are set within a preset underwater position of the lake water, wherein the sampling sensors include a turbidity sensor, a conductivity sensor and an ammonia nitrogen sensor to obtain water turbidity, conductivity and ammonia nitrogen concentration respectively; The lake water quality sample data collected by the sampling sensor is extracted at preset time intervals to obtain a time series water quality sample data set as the lake water quality sample data, wherein any element of the time series water quality sample data set includes a set consisting of water turbidity, conductivity and ammonia nitrogen concentration.
7. A water quality prediction device, characterized in that: include, Data sample module, used to obtain lake water quality sample data; A data partitioning module, used for partitioning the lake water quality sample data into a training set and a test set; A grey prediction model module is used to process the training set and accumulate it at preset time intervals by a sliding window method to obtain first training data, so as to construct a grey prediction model for predicting lake water quality data at future moments; A long short-term memory network model module is used to perform differential processing on the training set, convert it into supervised learning data and scale it to obtain second training data, so as to train a pre-built long short-term memory network model for predicting lake water quality data at future moments; The water quality prediction module is used to perform weighted summation of the lake water quality data at the future moment predicted by the grey prediction model and the lake water quality data at the future moment predicted by the long short-term memory network model based on the same time point according to different preset weight values to obtain the target water quality data at the future moment.
8. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The invention comprises a computer program, which implements the steps of the method according to any one of claims 1 to 6 when being executed by a processor.
Citation Information
Cited By
Method, device, equipment and medium for predicting concentration of NOx at outlet of SCR (Selective Catalytic Reduction) denitration system
CN121919584A