A water quality prediction method, system and device based on deep learning

By employing a deep learning-based water quality prediction method, this paper utilizes the cubic spline interpolation method and the moving average filtering method to process water quality data. By combining LSTM network and support vector machine, it solves the problem of insufficient integration of multiple water quality data in existing technologies and achieves high-precision water quality prediction.

CN116364203BActive Publication Date: 2026-03-24INNER MONGOLIA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-31
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

Existing water quality prediction models lack effective integration of various water quality data, resulting in low prediction accuracy. Furthermore, traditional deep learning algorithms require a large amount of data and are difficult to accurately reflect water quality change trends.

Method used

A water quality prediction method based on deep learning is adopted. Missing data is imputed by cubic spline interpolation, noise is removed by moving average filtering, and features are extracted by combining LSTM network and support vector machine, using partial least squares method to construct water quality prediction model and retain the correlation between various types of data.

Benefits of technology

It improves the accuracy and efficiency of water quality prediction, can more accurately reflect the impact of various types of data, optimizes the calculation process, and is applicable to the prediction of multiple types of water quality data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116364203B_ABST
    Figure CN116364203B_ABST
Patent Text Reader

Abstract

The present application relates to a kind of water quality prediction method, system and device based on deep learning.The water quality prediction method includes the following steps:S1: water quality data is collected.S2: water quality data is preprocessed.S3: water quality prediction model based on LSTM network is established.Water quality prediction model is trained, and model parameter meeting test accuracy is retained.Prediction data is output by water quality prediction model.S4: water quality data and prediction result are displayed in real time in the form of number or figure.The water quality prediction method of the present application can simultaneously analyze multiple types of data, train water quality prediction model using multiple types of water quality data, retain the correlation between various types of data to the greatest extent, eliminate redundant information, so that the final water quality prediction result can more clearly reflect the influence of various types of data, improve prediction accuracy, simplify the operation process and improve the real-time performance of prediction.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to a water quality prediction method based on deep learning, a water quality prediction system based on deep learning and a water quality prediction device based on deep learning. BACKGROUND

[0002] In the field of water quality monitoring, a real-time water quality prediction system is established through a wireless sensor network, environmental data from the official website of the meteorological department is incorporated into the real-time prediction system, a centralized topology structure is adopted to automatically and remotely collect data continuously, and the sensed data is transmitted to a database through a general packet radio service connection, a prediction model is established in a sliding window manner, and meteorological data is fused to realize prediction of hydrological data.

[0003] Traditional statistical water quality prediction algorithms use mathematical principles to model, and mainstream models use, for example, autoregressive moving average models (ARIMA), vector autoregressive models (VAR), etc., which require time series to be stationary. Traditional deep learning algorithms are widely used in data analysis and prediction, but they have a great requirement for data volume. Existing water quality prediction models only train models for a single water quality variable, lack analysis and prediction using the inherent correlation of water body data, and the predicted results cannot accurately represent the trend of water quality changes. SUMMARY

[0004] Therefore, it is necessary to provide a water quality prediction method, system and device based on deep learning to solve the problem of low prediction accuracy due to insufficient analysis of water quality data and ineffective combination of multiple water quality data in the existing water quality prediction method.

[0005] The present application is implemented by the following technical solutions: a water quality prediction method based on deep learning comprises the following steps:

[0006] S1: collecting water quality data. The water quality data includes PH value, ammonia nitrogen content, dissolved oxygen content, phosphorus content and permanganate index.

[0007] S2: dividing the water quality data into PH value data set, ammonia nitrogen content data set, dissolved oxygen content data set, phosphorus content data set and permanganate index data set according to the properties. The water quality data in each data set is preprocessed respectively. The preprocessing method is as follows:

[0008] S21: using a cubic spline interpolation method to interpolate the missing data in the water quality data.

[0009] S22: filtering the water quality data by using a moving average filtering method to obtain corresponding filtered data.

[0010] S3: Establish a water quality prediction model based on an LSTM network. Divide the filtered data into a training set and a test set. The water quality data in the training set is used as input to train the water quality prediction model. The water quality data in the test set is used as input to verify the water quality prediction model, and the model parameters that meet the test accuracy are retained. The filtered data is input into the water quality prediction model to obtain the corresponding prediction data. The construction method of the water quality prediction model is as follows:

[0011] S31: Feature extraction is performed on the filtered data using a partial least squares method to obtain corresponding feature data Y={(x1, y1), (x2, y2), (x3, y3), …, (x N , y N )}.

[0012] S32: Construct a support vector machine.

[0013] S33: Optimize the parameters of the support vector machine using an LSTM network.

[0014] S34: Add a residual network to the water quality prediction model to perform skip-layer linking on the LSTM network and output the final prediction result.

[0015] S4: Display the water quality data and the prediction result in a digital or graphical manner in real time.

[0016] The above water quality prediction method can simultaneously perform in-depth analysis on multiple types of data, interpolate missing water quality data using the cubic spline difference method, remove noise data using moving average filtering, use more effective water quality data for prediction, train the water quality prediction model using multiple types of water quality data, and maximize the correlation between various types of data to make the final water quality prediction result more clearly reflect the influence of various types of data, and improve the prediction accuracy. At the same time, the partial least squares method is used to extract the features of the water quality data, which not only retains important information in the data, but also simplifies the input data as a whole while maintaining the prediction accuracy, optimizes the operation process, and improves the efficiency of water quality prediction.

[0017] In one embodiment, the steps of the cubic spline difference method are as follows:

[0018] S211: Establish a plane coordinate system with time as the horizontal axis and water quality data value as the vertical axis, and map the water quality data in the data set to form multiple coordinate points in the plane coordinate system.

[0019] S212: Divide the multiple coordinate points into multiple consecutive intervals along the horizontal axis direction, and the two endpoints of each interval fall on the coordinate points.

[0020] S213: A cubic equation curve is constructed on each interval, the cubic equation curve passes through all coordinate points in the corresponding interval, and adjacent cubic equation curves smoothly connect.

[0021] S214: The time information of each missing data is input into the corresponding cubic equation curve to obtain the corresponding water quality data value, and the interpolation of all missing data is realized.

[0022] In one embodiment, the filter length is set to L, each water quality data is weighted according to the time sequence, and the weighted average operation of the first L water quality data is performed to obtain the filtered data.

[0023] In one embodiment, the specific steps of the partial least squares method are as follows:

[0024] S311: The filtered data is taken as the input set X, and the corresponding features are taken as the output set Y. The input set X and the output set Y are respectively subjected to data standardization processing.

[0025] S312: The principal component t1 of the input set and the principal component u1 of the output set are respectively extracted, and the covariance of t1 and u1 is maximized.

[0026] S313: The regression equation of X with respect to t1 and the regression equation of Y with respect to u1 are respectively established. The principal component t i of the input set and the principal component u i of the output set are respectively extracted by using the residual matrix of the two regression equations, and the corresponding regression equation is established.

[0027] S314: The principal component t k of the input set and the principal component u k of the output set are respectively extracted by using the residual matrix of the two regression equations, and the corresponding regression equation is established.

[0028] S315: When the extracted principal components meet the accuracy requirement, the regression equation between the input set X and the principal component t k and the regression equation between the output set Y and the principal component u k are established. The multiple regression equations are converted into the final regression equation between the input set X and the output set Y.

[0029] In one embodiment, the construction method of the support vector machine is as follows:

[0030] S321: The objective function is set. The objective function is expressed as:

[0031]

[0032] s.t. |y i -(ω T x i+b)|≤ε, i=1,2,3,…,N

[0033] In the formula, ω is the normal vector of the regression hyperplane, b is the displacement, ε is the maximum value of the minimum distance from the sample point to the hyperplane, and N is the number of sample points.

[0034] S322: By adding slack variables to the objective function, the objective function is transformed into an optimization problem. The optimization problem is expressed as:

[0035]

[0036] st-ε-ξ i ∨ ≤y i -(ω T x i +b)≤ε+ξ i ∧ ξ i ∨ ξ i ∧ ≥0

[0037] In the formula, C is the penalty term, ξ i ∨ ξ i ∧ These are the slack variables for the upper and lower bounds, respectively.

[0038] S323: The optimization problem is transformed into a dual problem using the Lagrangian function. The dual problem is expressed as:

[0039]

[0040]

[0041] In the formula, α = (α1, α2, α3,..., α N ,) are Lagrange multipliers, and α i ≥0.

[0042] S324: A kernel function is used to map the input feature dataset to a high-dimensional space, and then the corresponding classification decision function is calculated based on the optimal solution. The classification decision function is expressed as:

[0043]

[0044] In the formula, α * For the optimal solution to the dual problem, b * Let x be the optimal solution of the original objective function, x be the test point, and Φ represent the mapping.

[0045] In one embodiment, a Gaussian kernel function is used to transform the classification decision function into the final classification decision function:

[0046]

[0047] In the formula, τ is a hyperparameter.

[0048] In one embodiment, the LSTM network includes a forget gate, an input gate, and an output gate. The input to the forget gate is the state vector h from the previous time step. t-1 Compared with the input x at the current time t The output is a vector f with the same size as the transmission band state vector, and each element is between 0 and 1. t Vector f t Expressed as:

[0049] f t =σ(W f [h t-1 x t ]+b f )

[0050] In the formula, σ is the Sigmoid activation function, and W f Let b be the parameter matrix. f This is a bias term.

[0051] The input gate is used to generate new information that needs updating and to produce new candidate values. New information i t and candidate values They are expressed as follows:

[0052] i t =σ(W i [h t-1 x t ]+b i )

[0053]

[0054] In the formula, tanh is the tanh activation function, and W c W i Let b be the parameter matrix. i b c This is a bias term.

[0055] The output gate determines the final output result. Output result h t Expressed as:

[0056] h t =o t *tanh(C t )

[0057] o t =σ(W o [h t-1 xt ]+b o )

[0058] In the formula, W o is a parameter matrix, and b o is a bias term.

[0059] In one embodiment, the operation of the forgetting gate is combined with that of the input gate to obtain a new state vector C t The operation formula of C

[0060]

[0061] In the formula, C t-1 is the state vector of the previous moment.

[0062] The application further provides a water quality prediction system based on deep learning, which comprises a collection module, a preprocessing module and a water quality prediction model.

[0063] The collection module is used for collecting water quality data. The preprocessing module comprises a missing data processing module and a filtering processing module. The missing data processing module uses a cubic spline interpolation method to interpolate missing data in the water quality data. The filtering processing module uses a moving average filtering method to filter the water quality data to obtain corresponding filtered data. The water quality prediction model comprises a feature extraction module, a support vector machine, an LSTM network and a residual module. The feature extraction module uses a partial least squares method to extract feature data of the filtered data. The support vector machine is used for outputting corresponding prediction data according to the input feature data. The LSTM network is used for optimizing the parameters of the support vector machine. The residual module is used for solving the gradient vanishing problem of the LSTM network and optimizing the fluency of forward and backward propagation of the LSTM network.

[0064] The application further provides a water quality prediction device based on deep learning, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor. Each functional module in the water quality prediction device is deployed in the manner of the water quality prediction system based on deep learning. When the processor executes the computer program, the steps of the water quality prediction method based on deep learning are implemented, and the accurate prediction of the water quality of a to-be-tested water source is realized.

[0065] Compared with the prior art, the application has the following beneficial effects:

[0066] 1. The water quality prediction method of this invention can simultaneously perform in-depth analysis of multiple types of data. It interpolates missing water quality data using cubic spline interpolation and removes noise data using moving average filtering, making the predicted water quality data more effective. The water quality prediction model is trained using multiple types of water quality data to maximize the preservation of correlations between different data types, ensuring that the final water quality prediction result clearly reflects the influence of each type of data, resulting in higher prediction accuracy. Simultaneously, it employs partial least squares to extract features from the water quality data, not only preserving important information in the data but also simplifying the overall input data and optimizing the computation process while maintaining prediction accuracy, thus improving the efficiency of water quality prediction. Attached Figure Description

[0067] Figure 1 This is a flowchart illustrating the steps of the deep learning-based water quality prediction method in Embodiment 1 of the present invention.

[0068] Figure 2 for Figure 1 Flowchart of the water quality prediction model;

[0069] Figure 3 for Figure 1 A schematic diagram of the structure of an LSTM network;

[0070] Figure 4 For application Figure 1 A schematic diagram of the structure of a water quality prediction device based on a deep learning-based water quality prediction method. Detailed Implementation

[0071] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0072] It should be noted that when a component is said to be "installed on" another component, it can be directly on the other component or it may be in a component that is centered on it. When a component is said to be "set on" another component, it can be directly set on the other component or it may also be in a component that is centered on it. When a component is said to be "fixed to" another component, it can be directly fixed to the other component or it may also be in a component that is centered on it.

[0073] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the description herein is for describing particular embodiments only and is not intended to be limiting of the application. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.

[0074] Embodiment 1

[0075] Please refer to Figure 1 and Figure 2 , Figure 1 is a step diagram of the deep learning-based water quality prediction method of Embodiment 1 of the present application; Figure 2 is Figure 1 a prediction flowchart of the water quality prediction model. The deep learning-based water quality prediction method comprises the following steps:

[0076] S1: Collect water quality data. In this embodiment, the water quality data includes PH value, ammonia nitrogen content, dissolved oxygen content, phosphorus content and permanganate index. The method of collecting water quality data is as follows: a plurality of sensors for detecting water quality signals are placed in the water source to be detected, real-time water quality signals detected by each sensor are received, and the water quality signals are converted into digital water quality data. The PH value and the dissolved oxygen content are detected by an electrode type sensor, and the monitoring probe of the sensor can be directly placed in the water. The RS485 standard transmission protocol is used, and the address, baud rate, calibration and other indicators can be modified by software to ensure matching with the data transmission network. The permanganate index, phosphorus content and ammonia nitrogen content are detected by an integrated sensor, and a communication transmission module is embedded in the integrated sensor. The communication transmission interface can be directly connected to the data prediction network. The data collection period of each sensor is set to two hours to realize real-time updating of water quality data.

[0077] S2: Preprocess the water quality data and divide the water quality data into a training set and a test set. The preprocessing method is as follows:

[0078] S21: Use the cubic spline interpolation method to interpolate the missing data in the water quality data. According to the type of water quality data, the water quality data is divided into a plurality of data sets, such as PH value data set, ammonia nitrogen content data set, dissolved oxygen content data set, phosphorus content data set and permanganate index data set. The water quality data in each data set is processed for missing data. The method for processing missing data is as follows:

[0079] S211: Establish a plane coordinate system with time as the horizontal axis and water quality data value as the vertical axis, map the water quality data in the data set to the plane coordinate system to form a plurality of coordinate points. Let the collection period of water quality data be T, and the collected water quality data be P1, P2, P3, …, Pn in turn. The missing data in the water quality data is interpolated by the cubic spline interpolation method, and the interpolated water quality data is P1', P2', P3', …, Pn'.n The corresponding time is recorded as T1, T2, T3,..., Tn in turn. n The water quality data set can be recorded as X = {x1, x2, x3,..., xn}, wherein x = (T, P), i = 1, 2, 3,..., n. P p1 p2 p3 pn pi i i

[0080] S212: Divide the plurality of coordinate points along the horizontal axis direction into a plurality of continuous intervals, and the two endpoints of each interval fall on the coordinate points. For example, if the water quality data set is divided into m intervals, the first interval is recorded as [x1, x2], the second interval is recorded as [x2, x3], and the mth interval is recorded as [xn-1, xn], wherein 1 < A < B <... < j < n. p1 pA pA pB pj pn

[0081] S213: Construct a cubic equation curve on each interval, and the cubic equation curve passes through all the coordinate points in the corresponding interval, and the adjacent cubic equation curves are smoothly connected. Wherein, the smooth connection means that the values of the cubic equation curves of the adjacent two intervals are the same at the connection, and the first derivative and the second derivative of the two cubic equation curves are also the same.

[0082] S214: Input the time information of each missing data into the corresponding cubic equation curve to obtain the corresponding water quality data value, and realize the interpolation of all missing data. In the collected water quality data, due to the abnormal situation in the collection process, the water quality data is missing, and when the water quality data is mapped into coordinate points, it also becomes a missing coordinate point. At this time, the time of the missing data is substituted into the cubic equation curve of the corresponding interval, and the corresponding data value can be calculated. In this way, the calculated data value can be inserted into the corresponding position in the data set to form the interpolation of the water quality data.

[0083] S22: Smooth the noise data in the water quality data by using the moving average filtering method. The moving average filtering is based on the statistical law, and the continuous sampling data is regarded as a queue with a fixed length L. After a new measurement, the first data of the previous queue is removed, the remaining L-1 data is moved in turn, and the new sampling data is inserted as the tail of the new queue. Then, the average operation is performed on the new queue, and the result is taken as the result of this measurement.

[0084] ​​​​​​​​​​​​​​In this embodiment, the water quality data is processed by using weighted moving average filtering because the water quality data at different times has different influence on the predicted value. Specifically, the filtering length L is set, that is, L (L is an odd number) water quality data participates in operation each time, which are denoted as S1, S2, S3, …, S L , each water quality data is set with a weight according to time sequence, which are denoted as w1, w2, w3, …, w L , and the sum of all weights is 1. The corresponding filtered data can be denoted as S (L-1) / 2 = (S1w1 + S2w2 + S3w3 + … + S L w L ) / L. After obtaining one water quality data, the first water quality data is deleted. The weighted average operation is performed on all water quality data within the previous time length T to obtain the filtered data. If the water quality data S L+1 is continuously obtained, the water quality data participating in operation is converted to S2, S3, …, S L , S L+1 , and the corresponding filtered data is denoted as S (L+1) / 2 = (S2w1 + S3w2 + … + S L w L-1 + S L+1 w L ) / L.

[0085] S3: A water quality prediction model based on an LSTM network is established, the water quality data in the training set is taken as input to train the water quality prediction model, the water quality data in the test set is taken as input to verify the water quality prediction model, and the model parameters meeting the test accuracy are reserved. The filtered data is input into the water quality prediction model to obtain the corresponding predicted data. The training method of the water quality prediction model is as follows:

[0086] S31: The partial least squares method is used to extract features of the water quality data. The specific steps of the partial least squares method are as follows:

[0087] S311: The filtered data is taken as an input set X = {S1, S2, S3, …, S P}, and the corresponding features are taken as an output set Y. P water quality data (independent variables) are included in the input set X, and q feature data (dependent variables) are included in the output set Y. The data standardization processing is performed on the input set X and the output set Y to obtain corresponding data matrices E0 and F0.

[0088] S312: Extract the principal component t1 of the input set and the principal component u1 of the output set respectively, and maximize the covariance of t1 and u1. In probability theory and statistics, covariance is used to measure the overall error of two variables. If the change trend of two variables is consistent, that is, if one is greater than its own expectation, the other is also greater than its own expectation, then the covariance between the two variables is positive. If the change trend of two variables is opposite, that is, if one variable is greater than its own expectation, the other is less than its own expectation, then the covariance between the two variables is negative. The covariance of t1 and u1 is maximized, and the change trend of the two is closer.

[0089] S313: Establish the regression equation of X with respect to t1 and the regression equation of Y with respect to u1 respectively.

[0090]

[0091] In the formula, E1, F1 are residual matrices, p1, r1 are regression coefficient vectors, and:

[0092]

[0093] S314: Continue to extract the principal component t k of the input set and the principal component u k of the output set using the residual matrix of the two regression equations respectively, and establish the corresponding regression equation. The regression equation is expressed as:

[0094]

[0095] In the formula, E k-1 , Ek i , F k-1 , F k are residual matrices of the regression equation, k=2,3,4, …, p, p k , r k are regression coefficient vectors, which can be expressed as:

[0096]

[0097] S315: When the extracted principal components meet the accuracy requirement, establish the regression equation between the input set X and the output set Y with respect to the principal component t k and the principal component u k . Convert multiple regression equations into a regression equation between the input set X and the output set Y. Assuming that the Mth regression equation just meets the prediction accuracy, then integrate the first M regression equations to obtain the final regression equation:

[0098]

[0099] where M is the rank of X, w M is the Mth eigenvector.

[0100] S32: Constructing a support vector machine, inputting the feature data into the support vector machine for global optimal solution, and then obtaining a water quality prediction model.

[0101] S321: Setting the objective function. First, assuming that the input feature data set Y = {(x1, y1), (x2, y2), (x3, y3), …, (x N , y N )} is linearly separable, a hyperplane can be set to divide the feature data set, and the hyperplane is expressed as: ω T x i +b = 0. Maximizing the interval between the sample points and the hyperplane, that is, solving the convex quadratic programming problem, and the objective function is:

[0102]

[0103] s.t. |y i -(ψ T x i +b)|≤ε, i = 1, 2, 3, …, N

[0104] where ω is the normal vector of the regression hyperplane, b is the displacement, ε is the maximum value of the minimum distance of the sample points to the hyperplane, and N is the number of sample points.

[0105] S322: Adding a slack variable to the objective function to describe the degree of deviation of the sample points from the hyperplane, and then the objective function can be converted into an optimization problem form:

[0106]

[0107] s.t. -ε-ξ i ∨ ≤y i -(ω T x i +b)≤ε+ξ i ∧ , ξ i ∨ , ξ i ∧ ≥0

[0108] where C is the penalty term, ξ i ∨ , ξ i ∧ are the upper and lower bound slack variables, respectively.

[0109] S323: The above optimization problem is converted into a dual problem by using Lagrange function. First, define the Lagrange function of convex quadratic programming as:

[0110]

[0111] In the formula, α=(α1, α2, α3, …, αn) is the Lagrange multiplier, and α≥0. N i

[0112] The dual problem is expressed as:

[0113]

[0114]

[0115] The optimal solution of the above dual problem is calculated as:

[0116] α * =(α1 * ,α2 * ,α3 * ,……,α N * ) T

[0117] The optimal solution of the original objective function is calculated as:

[0118]

[0119]

[0120]

[0121] S324: The input feature data set is mapped to high-dimensional space by using the kernel function, and then the corresponding hyperplane and classification decision function are calculated according to the optimal solution. Since the feature data set has nonlinearity, it cannot be divided in two-dimensional space, so the sample points in the feature data set need to be mapped to three-dimensional space by using the kernel function. The original classification decision function:

[0122]

[0123] is mapped to:

[0124]

[0125] In the formula, Φ represents mapping.

[0126] The Gaussian kernel function is used in this embodiment, and the corresponding final classification decision function is:

[0127] ​​

[0128] In the formula, τ is a hyperparameter.

[0129] S33: LSTM networks are used to optimize the parameters of the support vector machine. During the construction of the support vector machine, penalty terms, slack variables, and hyperparameters directly affect the final prediction results. Deep learning algorithms are used to optimize these parameters to improve the final prediction accuracy.

[0130] Please combine Figure 3 , it is Figure 1 A schematic diagram of the LSTM network structure. An LSTM network (Long Short-Term Memory) includes a forget gate, an input gate, and an output gate. The forget gate contains a sigmoid operation and an elementwise multiplication operation (multiplying corresponding elements of two matrices of the same size to obtain a new matrix of the same size), used to forget less important information. The input to the forget gate is the state vector h from the previous time step. t-1 Compared with the input x at the current time t The output is a vector f with the same size as the transmission band state vector, and each element is between 0 and 1. t Vector f t This can be expressed as:

[0131] f t =σ(W f [h t-1 x t ]+b f )

[0132] In the formula, σ is the Sigmoid activation function, and W f Let b be the parameter matrix. f This is a bias term.

[0133] The input gate is used to generate the new information that needs to be updated. First, the state vector h from the previous time step is... t-1 Compared with the input x at the current time t The data is concatenated, and a sigmoid layer determines which values ​​are used for updating (i.e., generating new information), while a tanh layer generates new candidate values. Specifically, new information i t and candidate values This can be expressed as:

[0134] i t =σ(W i [h t-1 x t ]+b i )

[0135]

[0136] wherein tanh is a tanh activation function, W c , W i is a parameter matrix, and b i , b c is a bias term.

[0137] The operation of the forget gate and the input gate are combined to obtain a new state vector C t The operation formula of C

[0138]

[0139] wherein C t-1 is a state vector of the previous moment.

[0140] The output gate determines the final output result. First, an initial output o t is obtained through a sigmoid layer, and then the Ct value is scaled to -1 to 1 through a tanh layer, and multiplied with the output of the sigmoid layer pair by pair to obtain the final output. The final output result h t is expressed as:

[0141] h t = o t *tanh(C t )

[0142] o t = s(W o [h t-1 , x t ]+b o )

[0143] wherein W o is a parameter matrix, and b o is a bias term.

[0144] The LSTM network is a special RNN model, which mainly solves the problems of gradient disappearance and gradient explosion in long sequence training process. Compared with the ordinary RNN model, the LSTM can have better performance in long sequence.

[0145] S34: residual analysis is performed on the predicted data to obtain the final prediction result. With the increase of the number of layers of the LSTM network, the objective function is more and more likely to fall into a local optimal solution, and at the same time, with the increase of the number of layers, the gradient disappearance problem is more serious, so that the network parameters of the principle output layer cannot be effectively learned. The residual network includes multiple residual units. The residual unit can be realized in the form of skip-layer connection, that is, the input of the unit is directly added to the unit output, and then activated. The residual analysis solves the problems of gradient disappearance or gradient explosion of the LSTM neural network, so that the information forward and backward propagation is more smooth.

[0146] S4: Real-time display of the prediction result in digital or image form with the water quality data. Specifically, the collected water quality data and the prediction result can be converted into digital form and then plotted into a water quality change curve to visually show the water quality change trend of the water source to be measured. The historical data of the water quality can also be viewed in real time. In other embodiments, the water quality data and the prediction result can also be displayed in real time in digital or table form.

[0147] The embodiment obtains relevant water quality data by real-time detection of the water source to be measured, performs interpolation on missing water quality data by the cubic spline difference method, removes noise data by moving average filtering, and uses the water quality data for prediction more effectively. Subsequently, the characteristics of the water quality data are extracted by the partial least squares method, which not only retains important information in the data and maintains the accuracy of the prediction result, but also simplifies the input data as a whole, optimizes the operation process, and improves the efficiency of water quality prediction. By constructing a support vector machine and using an LSTM network to optimize the parameters of the support vector machine, high-precision water quality prediction is achieved under the premise of a small amount of water quality data samples. Water quality data includes multiple types, and these different types of water quality data influence each other. It is difficult to achieve actual prediction accuracy by analyzing and predicting from a single water quality variable.

[0148] The embodiment can simultaneously perform in-depth analysis on multiple types of data, train the water quality prediction model using multiple types of water quality data, and maximize the correlation between each type of data to make the final water quality prediction result more clearly reflect the influence of each type of data and have higher prediction accuracy. The water quality prediction method of the embodiment constructs an ecological environment monitoring network integrating the earth and the sky, and through multi-source data fusion and intelligent analysis, it can improve the big data assisted social governance mechanism and provide decision-making basis for high-quality development of watershed ecological construction.

[0149] Please refer to Figure 4 , which is a structural schematic diagram of a water quality prediction device based on the water quality prediction method of the application. Figure 1 In order to realize the above-mentioned water quality prediction method based on deep learning and apply it to existing water quality detection equipment, the embodiment further provides a water quality prediction system based on deep learning, which comprises a collection module, a preprocessing module, a water quality prediction model and a display module.

[0150] The acquisition module is configured to acquire water quality data. The water quality data includes PH value, ammonia nitrogen content, dissolved oxygen content, phosphorus content, and permanganate index, etc. The PH value and the dissolved oxygen content can be detected by using an electrode sensor, and the monitoring probe of the sensor can be directly placed in water. The permanganate index, the phosphorus content, and the ammonia nitrogen content are detected by using an integrated sensor, and the integrated sensor is embedded with a communication transmission module, and the communication transmission interface can be directly connected with the preprocessing module.

[0151] The preprocessing module includes a missing data processing module and a filtering processing module. The missing data processing module is configured to interpolate missing data in the water quality data by using a cubic spline interpolation method. The steps of the cubic spline interpolation method are as follows: 1. mapping the water quality data into coordinate points in a plane coordinate system; 2. dividing the coordinate points into a plurality of continuous intervals, and the endpoints of each interval fall on the corresponding coordinate points; 3. constructing a cubic curve passing through all the coordinate points in each interval. The connected curves are smoothly connected, i.e., the first derivative and the second derivative are the same. 4. For the actual data, the corresponding value is calculated in the corresponding cubic curve according to the time information, and the water quality data is interpolated.

[0152] The filtering processing module is configured to filter the water quality data by using a moving average filtering method to obtain corresponding filtered data. The steps of the moving average filtering method are as follows: 1. setting a filtering length L, i.e., the number of water quality data participating in operation each time. The current water quality data and the previous L-1 continuous water quality data are taken as a queue. 2. performing weighted average operation on the L water quality data in the current queue, i.e., according to the front and back order of the data, assigning a weight to each water quality data, multiplying each water quality data by the corresponding weight, and finally calculating the mean value as the output of the current filtered data. Each time new water quality data is obtained, the first data in the previous sequence is deleted, and the new water quality data is added as the last data, and then the weight of each water quality data in the current sequence is re-assigned in order, and the corresponding filtered data is calculated.

[0153] The water quality prediction model comprises a feature extraction module, a support vector machine and an LSTM network. The feature extraction module extracts feature data of filtered data by using a partial least squares method. The steps of the partial least squares method are as follows: 1. The filtered data are taken as an input set, and the feature data to be extracted are taken as an output set. The input set and the output set are standardized respectively. 2. The principal components of the input set and the output set are extracted respectively, and the covariance of the principal components is maximized. The principal components carry important information of the input set and the output set as much as possible. 3. The regression equation of the input set and the output set with respect to the corresponding principal components is established. If the regression equation of the first principal component meets the accuracy requirement, the regression equation is directly converted into the final regression equation between the input set and the output set. Otherwise, the residual matrix of the regression equation is used to continue extracting the principal components of the input set and the output set, and the corresponding regression equation is established until the regression equation meets the accuracy requirement. All the established regression equations are integrated to convert into the final regression equation between the input set and the output set.

[0154] The support vector machine is used to output corresponding prediction data according to the input feature data. The construction method of the support vector machine is as follows: 1. The feature data set is mapped into a plane coordinate system to obtain a plurality of sample points. The data are uniformly divided into two regions by constructing a hyperplane. The interval between the sample points and the hyperplane is maximized to obtain a corresponding objective function. 2. A slack variable is added to the objective function to convert the objective function into the form of an optimization problem, and then the Lagrange function is used to convert the optimization problem into a dual problem. The dual problem is optimally solved, and then the original objective function is further optimally solved according to the result of the optimal solution. 3. The sample points are mapped into a three-dimensional space by using a kernel function to obtain a final classification function, that is, a support vector machine model.

[0155] The LSTM network is used for parameter optimization processing of the support vector machine. The LSTM network comprises a forgetting gate, an input gate and an output gate. The forgetting gate is used to forget unimportant information, and outputs a corresponding vector according to a previous state vector and a current input. The input gate is used to generate updated information, including new information and a candidate value. The output gate is used to output a final prediction result, that is, a more optimal support vector machine parameter.

[0156] The residual module is used to solve the gradient disappearance problem of the LSTM network and optimize the fluency of forward and backward propagation of the LSTM network.

[0157] The display module is used to display the prediction result and the water quality data in a digital form or an image form in real time, so that people can more intuitively understand the water quality change of the relevant water area, and then make corresponding measures according to the water quality change trend.

[0158] In order to realize the above-mentioned water quality prediction method based on deep learning, and apply it to the existing water quality detection equipment, so as to realize real-time processing of water quality data and more accurately predict the trend of water quality change, the embodiment further provides a water quality prediction device based on deep learning. The water quality prediction device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above-mentioned water quality prediction method based on deep learning are realized, and then the water quality prediction of the water source to be measured is realized, and the accuracy of water quality prediction and the processing speed of water quality data are improved.

[0159] The computer device can be a smartphone, a tablet computer, a notebook computer, a desktop computer, a rack server, a blade server, a tower server or a cabinet server (including a single server or a server cluster composed of multiple servers), etc. which can execute programs. The computer device of the embodiment at least includes but is not limited to a memory and a processor which can be connected to each other for communication through a system bus.

[0160] In the embodiment, the memory (i.e. a readable storage medium) includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g. an SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory can be an internal storage unit of the computer device, such as a hard disk or a memory of the computer device. In other embodiments, the memory can also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Of course, the memory can also include both the internal storage unit and the external storage device of the computer device. In the embodiment, the memory is usually used to store the operating system and various application software installed on the computer device, etc. In addition, the memory can also be used to temporarily store various data that have been output or will be output.

[0161] The processor in some embodiments can be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor is usually used to control the overall operation of the computer device. In the embodiment, the processor is used to run the program code or process data stored in the memory, so as to realize the steps of the above-mentioned water quality prediction method based on deep learning, and then realize the water quality prediction of the water source to be measured, improve the accuracy of water quality prediction and the processing speed of water quality data.

[0162] The technical features of the above-described embodiments can be combined in any manner. For the sake of brevity, not all possible combinations of the technical features in the above-described embodiments are described, however, as long as the combinations of the technical features do not result in contradictions, they shall be considered as falling within the scope of the present disclosure.

[0163] The above-described embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it shall not be understood as a limitation on the scope of the patent right of the present application. It shall be pointed out that, for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present application, and these shall fall within the protection scope of the present application. Therefore, the protection scope of the patent right of the present application shall be subject to the appended claims.

Claims

1. A water quality prediction method based on deep learning, characterized in that, It includes the following steps: S1: Collect water quality data; the water quality data includes pH value, ammonia nitrogen content, dissolved oxygen content, phosphorus content, and permanganate index; S2: The water quality data is divided into pH value dataset, ammonia nitrogen content dataset, dissolved oxygen content dataset, phosphorus content dataset, and permanganate index dataset according to their properties; the water quality data in each dataset is preprocessed separately; the specific preprocessing method is as follows: S21: The missing data in the water quality data is imputed using the cubic spline interpolation method; S22: The water quality data is filtered using the moving average filtering method to obtain the corresponding filtered data; S3: Establish a water quality prediction model based on an LSTM network; divide the filtered data into a training set and a test set, using the water quality data in the training set as input to train the water quality prediction model; use the water quality data in the test set as input to validate the water quality prediction model, retaining model parameters that meet the test accuracy; input the filtered data into the water quality prediction model to obtain the corresponding prediction data; the specific method for constructing the water quality prediction model is as follows: S31: Partial least squares method is used to extract features from the filtered data to obtain the corresponding feature data Y = {(x1, y1), (x2, y2), (x3, y3), ..., (x...} N y N )}; S32: Construct a support vector machine; S33: The parameters of the support vector machine are optimized using an LSTM network; S34: Add a residual network to the water quality prediction model, perform skip connections on the LSTM network, and output the final prediction result; the residual network is used to solve the gradient vanishing problem of the LSTM network and optimize the smoothness of the forward and backward propagation of the LSTM network. S4: Display the water quality data and the prediction results in real time in a digital or graphical format.

2. The water quality prediction method based on deep learning according to claim 1, characterized in that, In step S21, the specific steps of the cubic spline interpolation method are as follows: S211: Establish a planar coordinate system with time as the horizontal axis and water quality data value as the vertical axis, and map the water quality data in the dataset to the planar coordinate system to form multiple coordinate points; S212: Divide the multiple coordinate points into multiple consecutive intervals along the horizontal axis, with both endpoints of each interval falling on the coordinate points; S213: Construct a cubic equation curve in each interval, the cubic equation curve passing through all coordinate points in the corresponding interval, and adjacent cubic equation curves are smoothly connected. S214: Input the time information of each missing data into the corresponding cubic equation curve to obtain the corresponding water quality data value, thereby realizing the interpolation of all missing data.

3. The water quality prediction method based on deep learning according to claim 1, characterized in that, In step S22, the filter length is set to L, and a weight is set for each water quality data according to the time sequence. The first L water quality data are then weighted and averaged to obtain the filtered data.

4. The water quality prediction method based on deep learning according to claim 1, characterized in that, In step S31, the specific steps of the partial least squares method are as follows: S311: Take the filtered data as the input set X and the corresponding features as the output set Y; perform data standardization processing on the input set X and the output set Y respectively; S312: Extract the principal components t1 of the input set and u1 of the output set respectively, and maximize the covariance of t1 and u1; S313: Establish the regression equations for X with respect to t1 and Y with respect to u1, respectively; The principal components t of the input set are further extracted using the residual matrices of the two regression equations. i and the principal component u of the output set i And establish the corresponding regression equation; S314: Utilize the residual matrices of the two regression equations to further extract the principal components t of the input set. k and the principal component u of the output set k And establish the corresponding regression equation; S315: When the extracted principal components meet the accuracy requirements, establish input set X and output set Y with respect to principal component t. k and principal component u k The regression equations between the input set X and the output set Y are transformed into a final regression equation between the input set X and the output set Y.

5. The water quality prediction method based on deep learning according to claim 1, characterized in that, In step S32, the method for constructing the support vector machine is as follows: S321: Set the objective function; the objective function is expressed as: s.t.|y i -(ω T x i +b)|≤ε,i=1,2,3,……,N In the formula, ω is the normal vector of the regression hyperplane, b is the displacement, ε is the maximum value of the minimum distance from the sample point to the hyperplane, and N is the number of sample points; S322: Add slack variables to the objective function, thereby transforming the objective function into an optimization problem; the optimization problem is expressed as: st-e-x i ∨ ≤y i -(oh T x i +b)≤ε+ξ i ∧ ,x i ∨ ,x i ∧ ≥0 In the formula, C is the penalty term, ξ i ∨ ξ i ∧ represents the slack variables for the upper and lower bounds, respectively; S323: The optimization problem is transformed into a dual problem using the Lagrangian function; the dual problem is expressed as: In the formula, α = (α1, α2, α3,..., α N ,) are Lagrange multipliers, and α i ≥0; S324: A kernel function is used to map the input feature dataset to a high-dimensional space, and then the corresponding classification decision function is calculated based on the optimal solution; the classification decision function is expressed as: In the formula, α * For the optimal solution to the dual problem, b * Let x be the optimal solution of the original objective function, x be the test point, and Φ represent the mapping.

6. The water quality prediction method based on deep learning according to claim 5, characterized in that, In step S324, the kernel function is a Gaussian kernel function, which transforms the classification decision function into the final classification decision function: In the formula, τ is a hyperparameter.

7. The water quality prediction method based on deep learning according to claim 1, characterized in that, In step S33, the LSTM network includes a forget gate, an input gate, and an output gate; The input to the forget gate is the state vector h from the previous time step. t-1 Compared with the current input x t The output is a vector f with the same size as the transmission band state vector, and each element is between 0 and 1. t The vector f t Expressed as: f t =σ(W f [h t-1 ,x t ]+b f ) In the formula, σ is the Sigmoid activation function, and W f Let b be the parameter matrix. f For bias terms; The input gate is used to generate new information that needs to be updated and to generate new candidate values; the new information i t and the candidate values They are expressed as follows: i t =σ(W i [h t-1 ,x t ]+b i ) In the formula, tanh is the tanh activation function, and W c W i Let b be the parameter matrix. i b c For bias terms; The output gate is used to determine the final output result; the output result h t Expressed as: h t = no t *fish(C) t ) the t =σ(W o [h t-1 ,x t ]+b o ) In the formula, W o Let b be the parameter matrix. o For bias terms; o t Indicates the initial output; C t This represents the state vector at the current moment.

8. The water quality prediction method based on deep learning according to claim 7, characterized in that, In step S33, the operations of the forget gate and the input gate are combined to obtain a new state vector C. t The calculation formula is: In the formula, C t-1 This is the state vector from the previous time step.

9. A water quality prediction system based on deep learning, which employs the water quality prediction method based on deep learning as described in any one of claims 1 to 8, characterized in that, The water quality prediction system includes: The data acquisition module is used to collect water quality data; The preprocessing module includes a missing data processing module and a filtering module; the missing data processing module uses the cubic spline interpolation method to interpolate missing data in the water quality data; the filtering module uses the moving average filtering method to filter the water quality data to obtain corresponding filtered data. A water quality prediction model includes a feature extraction module, a support vector machine (SVM), an LSTM network, and a residual module. The feature extraction module uses partial least squares (PLS) to extract feature data from the filtered data. The SVM outputs corresponding prediction data based on the input feature data. The LSTM network optimizes the parameters of the SVM. The residual module addresses the vanishing gradient problem in the LSTM network and optimizes the smoothness of its forward and backward propagation.

10. A water quality prediction device based on deep learning, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor. The feature is that each functional module in the water quality prediction device is deployed in the manner described in claim 9 as a water quality prediction system based on deep learning. When the processor executes the computer program, it implements the steps of the water quality prediction method based on deep learning as described in any one of claims 1 to 8, thereby achieving accurate prediction of the water quality of the water source to be tested.