A method, device, equipment and medium for predicting water quality in a basin
The multi-indicator water quality prediction model addresses the challenges of non-linear relationships and data missing values by integrating feature and time extraction modules, enhancing prediction accuracy and efficiency.
Patent Information
- Application Number
- CN202510379380.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-28
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2045-03-28
AI Technical Summary
The existing water quality prediction model has limitations in dealing with complex nonlinear relationships, capturing the mutual influence between water quality indicators and long-term dependence. In particular, there are still challenges in the joint modeling of multi-dimensional data. The missing value processing and spatiotemporal dependence capture in the water quality data are not effective enough, resulting in insufficient prediction accuracy and efficiency.
The multi-index water quality prediction model is adopted, and information fusion is carried out in the time dimension and channel dimension through the water quality feature extraction module, time information is added to each time step by combining the time feature extraction module, and missing values are interpolated using chain equations, and data processing is performed using multi-layer perception units and fully connected modules.
It improves the accuracy and efficiency of water quality prediction, effectively captures the fluctuation trends of water quality monitoring data and the potential interaction between different water quality indicators, and enhances the performance of the model.
Smart Images

Figure CN119884672B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of water area detection, and in particular to a method, device, equipment and medium for predicting water quality in a river basin. Background Art
[0002] At present, the research on water quality prediction mainly relies on the modeling and analysis of historical water quality data. Although traditional water quality prediction methods such as statistical regression models and time series analysis models can achieve water quality prediction to a certain extent, they have certain limitations in dealing with complex nonlinear relationships and capturing the mutual influence and long-term dependence between water quality indicators. With the rapid development of deep learning technology, prediction models based on neural networks have gradually become an important research direction in the field of water quality prediction. These models can automatically capture the development trend of water quality data and show higher prediction accuracy and application potential than traditional methods. However, in practical applications, water quality data usually involves multiple pollutant indicators, which often have complex spatial and temporal correlations. Although some existing water quality prediction models can capture the dependencies of some time dimensions, there are still certain challenges in the joint modeling of multi-dimensional data, especially in the modeling of time dependence and the interaction between multiple water quality indicators. Therefore, how to deal with missing values in water quality data, capture multi-dimensional spatiotemporal dependencies, and improve the prediction accuracy and computational efficiency of the model are still key issues that need to be solved in the field of water quality prediction. Summary of the invention
[0003] The present invention provides a method, device, equipment and medium for predicting water quality in a river basin, the purpose of which is to improve the accuracy of water quality prediction.
[0004] In order to achieve the above object, the present invention provides a method for predicting water quality in a river basin, comprising:
[0005] Step 1, obtaining historical water quality monitoring data of multiple water quality monitoring stations, where the historical water quality monitoring data includes water quality monitoring time and historical water quality data;
[0006] Step 2, inputting historical water quality monitoring data into the constructed multi-indicator water quality prediction model, training the multi-indicator water quality prediction model, and obtaining a trained multi-indicator water quality prediction model;
[0007] Step 3: Input the historical water quality monitoring data obtained by the target water quality monitoring station in the target watershed into the trained multi-index water quality prediction model to perform water quality prediction, and obtain the prediction results of future water quality indicators of the target watershed;
[0008] The multi-index water quality prediction model includes a water quality feature extraction module for information fusion in the time dimension and channel dimension, a time feature extraction module for adding time information to the features at each time step, and a fully connected module for fusion;
[0009] The input end of the water quality feature extraction module and the input end of the time feature extraction module are both the input end of the multi-index water quality prediction model. The output end of the water quality feature extraction module and the output end of the time feature extraction module are both connected to the input end of the fully connected module. The output end of the fully connected module is the output end of the multi-index water quality prediction model.
[0010] Furthermore, before step 2, it also includes:
[0011] Using the chained equation imputation method to impute the historical water quality monitoring data to obtain a complete water quality monitoring data set.
[0012] Furthermore, using the chained equation imputation method to impute the historical water quality monitoring data to obtain a complete water quality monitoring data set, including:
[0013] Before imputation, replace the missing values of each variable in the historical water quality monitoring data with temporary placeholders for the non-missing values of the corresponding variables;
[0014] For each variable with missing values, use other variables to impute the variable with missing values through a linear regression model to obtain a complete water quality monitoring data set.
[0015] Furthermore, the water quality feature extraction module is stacked by multiple multi-layer perceptron units;
[0016] The input end of the first multi-layer perceptron unit among the multiple multi-layer perceptron units is the input end of the water quality feature extraction module;
[0017] The output end of the last multi-layer perceptron unit among the multiple multi-layer perceptron units is connected to the input end of the fully connected module.
[0018] Furthermore, the multi-layer perceptron unit includes:
[0019] The first batch normalization layer, the first multi-layer perceptron layer, the first Dropout layer, the first residual connection layer, the second batch normalization layer, the second multi-layer perceptron layer, the second Dropout layer, the second residual connection layer;
[0020] The input end of the first batch normalization layer is the input end of the multi-layer perceptron unit and is connected to the first input end of the first residual connection layer. The output end of the first batch normalization layer is connected to the input end of the first multi-layer perceptron layer. The output end of the first multi-layer perceptron layer is connected to the input end of the first Dropout layer. The output end of the first Dropout layer is respectively connected to the second input end of the first residual connection layer. The output end of the first residual connection layer is connected to the input end of the second batch normalization layer. The output end of the second batch normalization layer is connected to the input end of the second multi-layer perceptron layer. The output end of the second multi-layer perceptron layer is connected to the input end of the Dropout layer. The output end of the Dropout layer and the output end of the first residual connection layer are both connected to the input end of the second residual connection layer. The output end of the second residual connection layer is the output end of the multi-layer perceptron unit and is connected to the input end of the fully connected module.
[0021] Furthermore, the time feature extraction module includes a first non-linear hidden layer, a second non-linear hidden layer, and a linear projection layer that are connected in sequence.
[0022] The input end of the non-linear hidden layer is the input end of the time feature extraction module.
[0023] The output end of the linear projection layer is the output end of the time feature extraction module and is connected to the input end of the fully connected module.
[0024] Furthermore, the time feature extraction module is used for:
[0025] Inputting the water quality monitoring time in the historical water quality monitoring data into the first non-linear hidden layer for mapping to obtain the first time feature , and the expression is:
[0026]
[0027] Wherein, represents the water quality monitoring time in the historical water quality monitoring data, represents the weight matrix of the first non-linear hidden layer, represents the activation function, represents the bias, represents the channel dimension, represents the dimension of the first non-linear hidden layer, represents the real number field;
[0028] Inputting the first time feature into the second non-linear hidden layer for mapping to obtain the second time feature , and the expression is:
[0029]
[0030] Wherein, denotes the weight matrix of the second non-linear hidden layer, denotes the bias, denotes the dimension of the second non-linear hidden layer;
[0031] Input the second temporal feature into the linear projection layer, map the second temporal feature to a dimension consistent with the number of feature channels to obtain the third temporal feature , the expression is:
[0032]
[0033] where, denotes the weight matrix of the linear projection layer, denotes the bias, denotes the dimension of the linear projection layer.
[0034] The present invention also provides a device for predicting the water quality of a river basin, including:
[0035] An acquisition module, configured to acquire historical water quality monitoring data of multiple water quality monitoring stations, where the historical water quality monitoring data includes water quality monitoring time and historical water quality data;
[0036] A training module, configured to input the historical water quality monitoring data into the constructed multi-index water quality prediction model, train the multi-index water quality prediction model, and obtain a trained multi-index water quality prediction model;
[0037] A prediction module, configured to input the historical water quality monitoring data obtained from the target water quality monitoring station in the target river basin into the trained multi-index water quality prediction model for water quality prediction, and obtain a predicted result of the future water quality index of the target river basin;
[0038] The multi-index water quality prediction model includes a water quality feature extraction module for fusing information in the time dimension and the channel dimension, a time feature extraction module for adding time information to the features of each time step, and a fully connected module for fusion;
[0039] The input end of the water quality feature extraction module and the input end of the time feature extraction module are both the input end of the multi-index water quality prediction model. The output end of the water quality feature extraction module and the output end of the time feature extraction module are both connected to the input end of the fully connected module, and the output end of the fully connected module is the output end of the multi-index water quality prediction model.
[0040] The present invention also provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method for predicting the water quality of a river basin.
[0041] The present invention also provides a computer-readable storage medium storing a computer program, which when executed by a processor implements the method for predicting water quality in a basin.
[0042] The above solution of the present invention has the following beneficial effects:
[0043] The present invention obtains historical water quality monitoring data of multiple water quality monitoring stations and inputs them into a constructed multi-index water quality prediction model, trains the multi-index water quality prediction model to obtain a trained multi-index water quality prediction model; inputs the historical water quality monitoring data obtained by a target water quality monitoring station in a target basin into the trained multi-index water quality prediction model for water quality prediction to obtain a prediction result of future water quality indicators in the target basin; the multi-index water quality prediction model includes a water quality feature extraction module for information fusion in the time dimension and channel dimension, a time feature extraction module for adding time information to the features of each time step, and a fully connected module for fusion; compared with the prior art, the multi-index water quality prediction model provided by the present invention uses the water quality feature extraction module to capture the fluctuation trend of water quality monitoring data and the potential interaction influence information between different water quality indicators in the time dimension and channel dimension respectively; after encoding the timestamps of historical water quality monitoring data by adding the time feature extraction module, time factors are added to each predicted water quality indicator respectively to increase the model's ability to capture the time fluctuation trend of water quality monitoring data, effectively improving the performance of the water quality prediction model and thus improving the accuracy of water quality prediction.
[0044] Other beneficial effects of the present invention will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 It is a schematic flowchart of an embodiment of the present invention;
[0046] Figure 2 It is a schematic structural diagram of a multi-index water quality prediction model in an embodiment of the present invention;
[0047] Figure 3 It is a schematic structural diagram of a multi-layer perception unit in an embodiment of the present invention;
[0048] Figure 4 It is a schematic structural diagram of a device for predicting water quality in a basin in an embodiment of the present invention;
[0049] Figure 5 It is a schematic structural diagram of a terminal device in an embodiment of the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0050] To make the technical problems, technical solutions, and advantages to be solved by the present invention clearer, the following will be described in detail with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0051] In the description of the present invention, it should be noted that the terms "first", "second", and "third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0052] In the description of the present invention, it should be noted that unless otherwise clearly defined and limited, the terms "installed", "connected", and "coupled" should be understood in a broad sense. For example, it can be a locking connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, and it can be the communication inside two components. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific situations.
[0053] In addition, the technical features involved in different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0054] The present invention provides a method, device, equipment, and medium for predicting the water quality of a watershed in view of existing problems.
[0055] As Figure 1 、 Figure 2 shown, an embodiment of the present invention provides a method for predicting the water quality of a watershed, including:
[0056] Step 1: Obtain historical water quality monitoring data of multiple water quality monitoring stations. The historical water quality monitoring data includes the water quality monitoring time and historical water quality data;
[0057] Step 2: Input the historical water quality monitoring data into the constructed multi-index water quality prediction model, train the multi-index water quality prediction model, and obtain the trained multi-index water quality prediction model;
[0058] Step 3: Input the historical water quality monitoring data obtained at the target water quality monitoring station in the target watershed into the trained multi-index water quality prediction model for water quality prediction, and obtain the predicted result of the future water quality index of the target watershed;
[0059] The multi-index water quality prediction model includes a water quality feature extraction module for information fusion in the time dimension and channel dimension, a time feature extraction module for adding time information to the features of each time step, and a fully connected module for fusion;
[0060] The input ends of the water quality feature extraction module and the time feature extraction module are both the input ends of the multi-index water quality prediction model. The output ends of the water quality feature extraction module and the time feature extraction module are both connected to the input end of the fully connected module, and the output end of the fully connected module is the output end of the multi-index water quality prediction model.
[0061] Specifically, the historical water quality monitoring data includes the water quality monitoring time and the historical water quality data. Among them, the historical water quality data includes multiple types, namely the concentration data of dissolved oxygen, the permanganate index, the total phosphorus data, and the total nitrogen data. Among them, the concentration data of dissolved oxygen represents the molecular oxygen in the air dissolved in the water body, which is used to reflect the self-purification ability of the water body. The permanganate index is used to reflect the pollution of organic and inorganic oxidizable substances in the water body. The total phosphorus data is used to reflect the content of phosphorus elements in the water body. The total nitrogen data represents the total amount of various forms of organic and inorganic nitrogen in the water body, which is used to reflect the eutrophication state of the water body. The historical water quality monitoring data is expressed as:
[0062]
[0063] Among them, represents the historical water quality monitoring data, represents the historical water quality data, , represents the types of historical water quality data, represents the th time series of the th type of historical water quality data, represents the sequence length, represents the water quality monitoring time.
[0064] Due to the existence of accidental factors, the water quality monitoring data monitored by the water quality monitoring station may be missing due to non-human reasons such as power outages or sensor failures, etc., which will affect the availability of the data, and this kind of missing is continuous, that is, the water quality monitoring results are lost for a period of time.
[0065] In order to eliminate the adverse impact of data missing on the accuracy of the water quality prediction model, the embodiment of the present invention further includes before step 2:
[0066] Using the chained equation imputation method to impute the historical water quality monitoring data to obtain a complete water quality monitoring data set.
[0067] Specifically, using the chained equation imputation method to impute the historical water quality monitoring data to obtain a complete water quality monitoring data set, including:
[0068] Before imputation, replace the missing values of each variable in the historical water quality monitoring data with temporary placeholders of non-missing values of the corresponding variables;
[0069] For each variable with missing values, other variables are used to impute the variable with missing values through a linear regression model to obtain a complete water quality monitoring dataset.
[0070] In the embodiment of the present invention, the process of using other variables to impute the variable with missing values through a linear regression model will be iterated multiple times. Each round of imputation is based on the imputation result of the previous round until all missing values are filled. The specific process is as follows:
[0071] Denote as the water quality monitoring dataset without missing values, as the water quality monitoring dataset with missing values, , denote the th historical water quality data with missing values. The imputation process for needs to be carried out for a total of rounds of loops. Generally, an integer between 10 and 50 is taken. In the first round of loop, first perform a regression on and impute the missing values of according to this regression. When imputing, the principle of multiple imputation should be followed, that is, considering the random variability of model parameters and the random variability of model parameters simultaneously; then perform a regression on (including the imputed values) and and impute the missing values of according to this regression; and so on, until finally perform a regression on and impute the missing values of according to this regression. The imputation in the 2nd to the nth rounds will follow the process of the first round. The difference is that at this time each regression includes all other variables except this variable, and each round of loop should use the latest imputed values. After all rounds of loops are completed, take the imputation result of the th round as the final result to form a complete water quality monitoring dataset. In order to obtain datasets, the above rounds of loops need to be independently carried out times.
[0072] Most preferably, the water quality feature extraction module is stacked by multiple multi-layer perception units;
[0073] The input end of the first multi-layer perception unit among the multiple multi-layer perception units is the input end of the water quality feature extraction module;
[0074] The output end of the last multi-layer perceptron unit among multiple multi-layer perceptron units is connected to the input end of the fully connected module.
[0075] In the embodiment of the present invention, the water quality feature extraction module is composed of 4 stacked multi-layer perceptron units.
[0076] Most preferably, as Figure 3 shown, the multi-layer perceptron unit includes:
[0077] The first batch normalization layer, the first multi-layer perceptron layer, the first Dropout layer, the first residual connection layer, the second batch normalization layer, the second multi-layer perceptron layer, the second Dropout layer, the second residual connection layer;
[0078] The input end of the first batch normalization layer is the input end of the multi-layer perceptron unit and is connected to the first input end of the first residual connection layer. The output end of the first batch normalization layer is connected to the input end of the first multi-layer perceptron layer. The output end of the first multi-layer perceptron layer is connected to the input end of the first Dropout layer. The output end of the first Dropout layer is respectively connected to the second input end of the first residual connection layer. The output end of the first residual connection layer is connected to the input end of the second batch normalization layer. The output end of the second batch normalization layer is connected to the input end of the second multi-layer perceptron layer. The output end of the second multi-layer perceptron layer is connected to the input end of the Dropout layer. The output end of the Dropout layer and the output end of the first residual connection layer are both connected to the input end of the second residual connection layer. The output end of the second residual connection layer is the output end of the multi-layer perceptron unit and is connected to the input end of the fully connected module.
[0079] In the embodiment of the present invention, the specific implementation process of the multi-layer perceptron unit is as follows:
[0080] Input the historical water quality data in the complete water quality monitoring dataset into the first batch normalization layer, where represents the historical data time step, and represents the type of historical water quality data. First, perform batch normalization processing on the input historical water quality data along the time direction. The calculation expression is:
[0081] ;
[0082] where, represents the historical water quality data after batch normalization, represents the batch normalization operation, represents the flattening operation;
[0083] Input the historical water quality data after batch normalization into the first multi-layer perceptron layer for processing. The expression is:
[0084]
[0085] Among them, represents the initial water quality time characteristics, , represents the linear change matrix in the time dimension, represents the bias term;
[0086] Input the initial water quality time characteristics into the first Dropout layer for dropout operation, and the expression is:
[0087]
[0088] Input the historical water quality data in the complete water quality monitoring dataset and the water quality time characteristics after dropout operation into the first residual connection layer for residual connection, and the expression is:
[0089]
[0090] Among them, represents the water quality time characteristics extracted along the time dimension;
[0091] Input the water quality time characteristics extracted along the time dimension into the second batch normalization layer for batch normalization processing along the channel dimension, and the calculation expression is:
[0092] ;
[0093] Input the water quality time characteristics after batch normalization into the second multi-layer perceptron for processing, and the expression is:
[0094]
[0095] Among them, represents the linear change matrix in the time dimension, is the bias term;
[0096] Input the water quality time characteristics after being processed by the second multi-layer perceptron into the second Dropout layer for dropout operation, and the expression is:
[0097]
[0098] Input the water quality time characteristics extracted along the time dimension and the water quality time characteristics after the second dropout layer operation into the second residual connection layer for residual connection, and the expression is:
[0099]
[0100] Among them, represents the final water quality time characteristics, including the information on the changing trend of various water quality data over time and the information on the mutual relationship between various water quality indicators in the input water quality data.
[0101] Most preferably, the time feature extraction module includes a first non-linear hidden layer, a second non-linear hidden layer, and a linear projection layer connected in sequence;
[0102] The input end of the non-linear hidden layer is the input end of the time feature extraction module;
[0103] The output end of the linear projection layer is the output end of the time feature extraction module and is connected to the input end of the fully connected module.
[0104] In the embodiment of the present invention, each non-linear hidden layer projects the input data along the time feature and multiple dimensions, and the final linear projection layer completes the time feature encoding.
[0105] Specifically, the time feature extraction module is used for:
[0106] Input the water quality monitoring time in the historical water quality monitoring data into the first non-linear hidden layer for mapping to obtain the first time feature , and the expression is:
[0107]
[0108] Among them, represents the water quality monitoring time in the historical water quality monitoring data, represents the weight matrix of the first non-linear hidden layer, represents the activation function, represents the bias, represents the channel dimension, represents the dimension of the first non-linear hidden layer, represents the real number field;
[0109] Input the first time feature into the second non-linear hidden layer for mapping to obtain the second time feature , and the expression is:
[0110]
[0111] Among them, represents the weight matrix of the second non-linear hidden layer, represents the bias, represents the dimension of the second non-linear hidden layer;
[0112] Input the second time feature into the linear projection layer, map the second time feature to a dimension consistent with the number of feature channels, and obtain the third time feature , and the expression is:
[0113]
[0114] where, represents the weight matrix of the linear projection layer, represents the bias.
[0115] Specifically, the fully connected module fuses the third time feature and and maps them to the output space to obtain the water quality index prediction result, and the expression is:
[0116]
[0117]
[0118] where, represents the water quality index prediction result, represents the weight matrix of the fully connected module, represents the bias, represents the fused feature.
[0119] In the embodiment of the present invention, step 2 specifically includes:
[0120] Divide the complete water quality monitoring data into an 80% training set and a 20% validation set. The training set is used to train the multi-index water quality prediction model, and the performance of the multi-index water quality prediction model is evaluated on the validation set;
[0121] Before starting the training of the multi-index water quality prediction model, considering that the data metrics of different characteristic parameters in the water quality monitoring data are different, the data is normalized before being used as the input of the multi-index water quality prediction model. Normalized data is essentially a linear transformation of time series data, and the data is scaled to between. Such a transformation does not affect the original fluctuation information of the data sequence. The maximum-minimum normalization formula is shown as follows:
[0122]
[0123] During the training experiment, the learning rate was set to 0.001. The adaptive weight loss function was used to measure the training error of the model, and the loss function was backpropagated through the Adaptive Moment Estimation (Adam) optimizer to update the network parameters. The number of training epochs of the model was 50, and the batch size was set to 32;
[0124] Especially in the loss function, in the embodiments of the present invention, considering multiple water quality index prediction tasks, it is necessary to dynamically adjust the contribution of the prediction errors of each water quality index to the overall loss to improve the performance and prediction adaptability of the model;
[0125] The embodiments of the present invention are based on the Mean Squared Error (MSE) loss function commonly used in regression prediction tasks for improvement, and an adaptive weight loss function is designed as the loss function for model training.
[0126] The MSE loss function squares the error to assist the model in reducing the larger prediction errors of some samples during the training process. Its calculation formula is as follows:
[0127]
[0128] Among them, is the true value of the th sample, is the predicted value of the th sample, is the total number of samples.
[0129] Based on this, the calculation formula of the further constructed adaptive weight loss function is as follows:
[0130]
[0131] Among them, is the total loss of the predicted water quality index, is the MSE loss function, that is, the cumulative training error of the th feature, is the weight of the th index. The weight ratio is adjusted by the prediction error of each predicted water quality index. For samples with larger prediction errors, their weights can be increased, so that the model pays more attention to the water quality indexes with greater prediction difficulty.
[0132] During the training process, the loss function is calculated based on the prediction results output by the multi-index water quality prediction model and backpropagated. The gradient is calculated according to the backpropagation results, and the model parameters are updated based on the gradient until the training epoch ends, and the trained multi-index water quality prediction model is obtained. Using this model, multiple water quality parameter indexes can be predicted simultaneously.
[0133] In an embodiment of the present invention, the historical water quality monitoring data obtained by a target water quality monitoring site in a target basin is input into a trained multi-index water quality prediction model for water quality prediction, and a future water quality index prediction result of the target basin is obtained. The water quality index prediction result includes the dissolved oxygen concentration, permanganate index, total phosphorus content, and total nitrogen content of the target basin within a future period of time. Based on the dissolved oxygen concentration, permanganate index, total phosphorus content, and total nitrogen content of the target basin within a future period of time, the water pollution degree of the target basin within a future period of time is evaluated.
[0134] In an embodiment of the present invention, historical water quality monitoring data of multiple water quality monitoring sites is obtained and input into a constructed multi-index water quality prediction model, and the multi-index water quality prediction model is trained to obtain a trained multi-index water quality prediction model; the historical water quality monitoring data obtained by a target water quality monitoring site in a target basin is input into the trained multi-index water quality prediction model for water quality prediction, and a future water quality index prediction result of the target basin is obtained; the multi-index water quality prediction model includes a water quality feature extraction module for information fusion in the time dimension and channel dimension, a time feature extraction module for adding time information to the features of each time step, and a fully connected module for fusion; compared with the prior art, the multi-index water quality prediction model provided in the embodiment of the present invention uses the water quality feature extraction module to capture the fluctuation trend of water quality monitoring data and the potential interaction influence information between different water quality indicators in the time dimension and channel dimension respectively; after encoding the timestamps of historical water quality monitoring data by adding the time feature extraction module, time factors are added to each predicted water quality index respectively to increase the model's ability to capture the time fluctuation trend of water quality monitoring data, effectively improving the performance of the water quality prediction model and further improving the accuracy of water quality prediction.
[0135] Corresponding to the basin water quality prediction method described in the above embodiment, as Figure 4 shown, an embodiment of the present invention further provides a basin water quality prediction device 100, and the basin water quality prediction device 100 includes:
[0136] An acquisition module 101, configured to acquire historical water quality monitoring data of multiple water quality monitoring sites, where the historical water quality monitoring data includes water quality monitoring time and historical water quality data;
[0137] A training module 102, configured to input the historical water quality monitoring data into a constructed multi-index water quality prediction model, and train the multi-index water quality prediction model to obtain a trained multi-index water quality prediction model;
[0138] A prediction module 103 is configured to input historical water quality monitoring data obtained by a target water quality monitoring site in a target river basin into a trained multi-index water quality prediction model for water quality prediction, so as to obtain a future water quality index prediction result of the target river basin.
[0139] The multi-index water quality prediction model includes a water quality feature extraction module for performing information fusion in the time dimension and the channel dimension, a time feature extraction module for adding time information to the features of each time step, and a fully connected module for fusion.
[0140] The input end of the water quality feature extraction module and the input end of the time feature extraction module are both the input end of the multi-index water quality prediction model. The output end of the water quality feature extraction module and the output end of the time feature extraction module are both connected to the input end of the fully connected module. The output end of the fully connected module is the output end of the multi-index water quality prediction model.
[0141] It should be noted that for the information interaction, execution process, etc. between the above-mentioned devices / units, since they are based on the same concept as the method embodiments of the present application, their specific functions and the technical effects brought thereby can be specifically referred to the method embodiment part, and will not be elaborated here.
[0142] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the above-mentioned division of each functional unit and module is used for illustration. In actual applications, the above-mentioned functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of the present application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the foregoing method embodiments, and will not be elaborated here.
[0143] An embodiment of the present invention further provides a terminal device, as Figure 5 shown. The terminal device D10 in this embodiment includes: at least one processor D100 ( Figure 5 only one processor is shown in the figure), a memory D101, and a computer program D102 stored in the memory D101 and executable on the at least one processor D100. When the processor D100 executes the computer program D102, the above-mentioned river basin water quality prediction method is implemented.
[0144] The terminal device D10 may be a computing device such as a desktop computer, a notebook, a palm computer, a server, a server cluster, and a cloud server. The terminal device may include, but is not limited to, a processor D100 and a memory D101. Those skilled in the art can understand that Figure 5 merely examples of the terminal device D10, which do not constitute a limitation on the terminal device D10, may include more or fewer components than shown in the figure, or combine certain components, or different components. For example, it may also include input / output devices, network access devices, etc.
[0145] The so-called processor D100 may be a central processing unit (CPU), and the processor D100 may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0146] The memory D101 may be an internal storage unit of the terminal device D10 in some embodiments, such as the hard disk or memory of the terminal device D10. The memory D101 may also be an external storage device of the terminal device D10 in some other embodiments, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the terminal device D10. Further, the memory D101 may also include both the internal storage unit and the external storage device of the terminal device D10. The memory D101 is used to store an operating system, application programs, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program, etc. The memory D101 may also be used to temporarily store data that has been output or will be output.
[0147] It should be noted that the content such as information interaction and execution process between the above-mentioned devices / units, since it is based on the same concept as the method embodiment of the present application, for its specific functions and the technical effects brought, please refer to the method embodiment part specifically, and will not be elaborated here.
[0148] Those skilled in the art can clearly understand that, for the 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 allocated to different functional units and modules according to needs, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of the functional units and modules are only for the convenience of mutual distinction and do not limit the protection scope of this application. The specific working processes of the units and modules in the above system can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.
[0149] An embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the watershed water quality prediction method.
[0150] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, to implement all or part of the processes in the above-mentioned method embodiments of this application, a computer program can be used to instruct relevant hardware to complete. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, it can implement the steps of the above-mentioned method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the construction device / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electrical carrier signal, telecommunication signal, and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk, or an optical disc, etc.
[0151] The above is the preferred embodiment of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.
Claims
1. A method for predicting water quality in a basin, characterized in that, Including: Step 1: Obtain historical water quality monitoring data of multiple water quality monitoring stations, where the historical water quality monitoring data includes water quality monitoring time and historical water quality data; Step 2: Input the historical water quality monitoring data into the constructed multi-index water quality prediction model, train the multi-index water quality prediction model, and obtain the trained multi-index water quality prediction model; Step 3: Input the historical water quality monitoring data obtained from the target water quality monitoring station in the target basin into the trained multi-index water quality prediction model for water quality prediction, and obtain the prediction result of the future water quality index of the target basin; The multi-index water quality prediction model includes a water quality feature extraction module for information fusion in the time dimension and channel dimension, a time feature extraction module for adding time information to the features of each time step, and a fully connected module for fusion; The input end of the water quality feature extraction module and the input end of the time feature extraction module are both the input end of the multi-index water quality prediction model. The output end of the water quality feature extraction module and the output end of the time feature extraction module are both connected to the input end of the fully connected module, and the output end of the fully connected module is the output end of the multi-index water quality prediction model; The water quality feature extraction module is stacked by multiple multi-layer perceptron units; The input end of the first multi-layer perceptron unit among the multiple multi-layer perceptron units is the input end of the water quality feature extraction module; The output end of the last multi-layer perceptron unit among the multiple multi-layer perceptron units is connected to the input end of the fully connected module; The multi-layer perceptron unit includes: The first batch normalization layer, the first multi-layer perceptron layer, the first Dropout layer, the first residual connection layer, the second batch normalization layer, the second multi-layer perceptron layer, the second Dropout layer, and the second residual connection layer; The input end of the first batch normalization layer is the input end of the multi-layer perceptron unit and is connected to the first input end of the first residual connection layer. The output end of the first batch normalization layer is connected to the input end of the first multi-layer perceptron layer. The output end of the first multi-layer perceptron layer is connected to the input end of the first Dropout layer. The output end of the first Dropout layer is respectively connected to the second input end of the first residual connection layer. The output end of the first residual connection layer is connected to the input end of the second batch normalization layer. The output end of the second batch normalization layer is connected to the input end of the second multi-layer perceptron layer. The output end of the second multi-layer perceptron layer is connected to the input end of the Dropout layer. The output end of the Dropout layer and the output end of the first residual connection layer are both connected to the input end of the second residual connection layer. The output end of the second residual connection layer is the output end of the multi-layer perceptron unit and is connected to the input end of the fully connected module.
2. The watershed water quality prediction method according to claim 1, wherein Before the step 2, it further includes: Using the chained equation imputation method to impute the historical water quality monitoring data to obtain a complete water quality monitoring data set.
3. The watershed water quality prediction method according to claim 2, wherein Using the chained equation imputation method to impute the historical water quality monitoring data to obtain a complete water quality monitoring data set, including: Replace the missing values of each variable in the historical water quality monitoring data with temporary placeholders of non-missing values of the corresponding variables before interpolation; For each variable with missing values, use other variables to interpolate the variable with missing values through a linear regression model to obtain a complete water quality monitoring data set.
4. The watershed water quality prediction method according to claim 3, characterized in that The time feature extraction module includes a first non-linear hidden layer, a second non-linear hidden layer, and a linear projection layer connected in sequence; The input end of the non-linear hidden layer is the input end of the time feature extraction module; The output end of the linear projection layer is the output end of the time feature extraction module and is connected to the input end of the fully connected module.
5. The basin water quality prediction method according to claim 4, wherein, The time feature extraction module is used for: Input the water quality monitoring time in the historical water quality monitoring data into the first non-linear hidden layer for mapping to obtain the first time feature , and the expression is: ; Among them, represents the water quality monitoring time in the historical water quality monitoring data, represents the weight matrix of the first non-linear hidden layer, represents the activation function, represents the bias, represents the channel dimension, represents the dimension of the first non-linear hidden layer, represents the real number field; Input the first time feature into the second non-linear hidden layer for mapping to obtain the second time feature , and the expression is: ; Among them, represents the weight matrix of the second non-linear hidden layer, represents the bias, represents the dimension of the second non-linear hidden layer; Input the second temporal feature into the linear projection layer, map the second temporal feature to a dimension consistent with the number of feature channels to obtain a third temporal feature , and the expression is: ; Among them, represents the weight matrix of the linear projection layer, represents the bias, represents the dimension of the linear projection layer.
6. A device for predicting water quality in a river basin, characterized in that, Including: An acquisition module for acquiring historical water quality monitoring data of multiple water quality monitoring stations, where the historical water quality monitoring data includes water quality monitoring time and historical water quality data; A training module for inputting the historical water quality monitoring data into a constructed multi-index water quality prediction model, training the multi-index water quality prediction model, and obtaining a trained multi-index water quality prediction model; A prediction module for inputting the historical water quality monitoring data obtained from a target water quality monitoring station in a target basin into the trained multi-index water quality prediction model for water quality prediction to obtain a predicted result of future water quality indicators for the target basin; The multi-index water quality prediction model includes a water quality feature extraction module for information fusion in the time dimension and channel dimension, a time feature extraction module for adding time information to the features of each time step, and a fully connected module for fusion; The input ends of the water quality feature extraction module and the time feature extraction module are both the input end of the multi-index water quality prediction model, the output ends of the water quality feature extraction module and the time feature extraction module are both connected to the input end of the fully connected module, and the output end of the fully connected module is the output end of the multi-index water quality prediction model; The water quality feature extraction module is stacked by multiple multi-layer perceptron units; The input end of the first multi-layer perceptron unit among the multiple multi-layer perceptron units is the input end of the water quality feature extraction module; The output end of the last multi-layer perceptron unit among the multiple multi-layer perceptron units is connected to the input end of the fully connected module; The multi-layer perceptron unit includes: A first batch normalization layer, a first multi-layer perceptron layer, a first Dropout layer, a first residual connection layer, a second batch normalization layer, a second multi-layer perceptron layer, a second Dropout layer, and a second residual connection layer; The input end of the first batch normalization layer is the input end of the multi-layer perceptron unit and is connected to the first input end of the first residual connection layer. The output end of the first batch normalization layer is connected to the input end of the first multi-layer perceptron layer. The output end of the first multi-layer perceptron layer is connected to the input end of the first Dropout layer. The output end of the first Dropout layer is respectively connected to the second input end of the first residual connection layer. The output end of the first residual connection layer is connected to the input end of the second batch normalization layer. The output end of the second batch normalization layer is connected to the input end of the second multi-layer perceptron layer. The output end of the second multi-layer perceptron layer is connected to the input end of the Dropout layer. The output end of the Dropout layer and the output end of the first residual connection layer are both connected to the input end of the second residual connection layer. The output end of the second residual connection layer is the output end of the multi-layer perceptron unit and is connected to the input end of the fully connected module.
7. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the watershed water quality prediction method according to any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the watershed water quality prediction method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Basin water quality prediction method and system, electronic equipment and storage medium
CN116187203A
Time series data prediction method, device and equipment
CN117668490A