Water quality prediction method and system based on artificial neural network

Through the water quality prediction method based on artificial neural network, the problem that existing dissolved oxygen monitoring methods are difficult to achieve real-time monitoring and accurate prediction is solved, and efficient and accurate dissolved oxygen prediction is achieved, reducing the monitoring difficulty and cost.

CN119537975APending Publication Date: 2025-02-28BEIJING INSPUR CLOUD COMPUTING CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411450722.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

The existing dissolved oxygen monitoring methods have problems such as difficulty in real-time monitoring, sampling difficulties, time-consuming laboratory analysis and influenced by environmental factors, resulting in high monitoring, high cost, poor real-time and low accuracy.

Method used

Using the water quality prediction method based on artificial neural network, a multi-layer perceptron model, a long and short-term memory network model and a clustered multi-layer perceptron model are constructed by acquiring and pretreating the water quality data set, and a multi-layer perceptron model is trained and tested, and the model with the smallest root mean square error is selected to predict the dissolved oxygen content.

Benefits of technology

It realizes efficient and accurate prediction of dissolved oxygen content, reduces the difficulty and cost of water quality monitoring, and improves the real-time and reliability of monitoring.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537975A_ABST
    Figure CN119537975A_ABST
Patent Text Reader

Abstract

The invention discloses a water quality prediction method and system based on an artificial neural network, and relates to the technical field of water quality monitoring, and the method comprises the steps: obtaining a water quality data set, and carrying out the preprocessing of the water quality data set; randomly dividing the preprocessed water quality data set into a training set and a test set; constructing a multi-layer perceptron model, a long and short-term memory network model and a clustering multi-layer perceptron model; training the multilayer perceptron model, the long short-term memory network model and the clustering multilayer perceptron model by using the training set, and testing the trained multilayer perceptron model, the long short-term memory network model and the clustering multilayer perceptron model by using the test set; comparing root-mean-square errors of the multi-layer perceptron model, the long-short-term memory network model and the clustering multi-layer perceptron model on the test set, and selecting the model with the minimum root-mean-square error as the optimal model. According to the invention, through real-time online monitoring of water quality data, accurate prediction of the dissolved oxygen content is realized, so that the reliability of water quality monitoring is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of water quality monitoring, in particular to a water quality prediction method and system based on an artificial neural network. Background Art

[0002] Dissolved oxygen (DO) is a key parameter in water environment. It can be used as one of the symbols of water quality for the following reasons:

[0003] (1) Necessary for the survival of aquatic organisms. Dissolved oxygen is essential for the respiration process of aquatic organisms and is vital for the survival of fish, plankton and other aquatic organisms. The dissolved oxygen content in water directly affects the survival rate of these organisms and the health of the ecosystem.

[0004] (2) An indicator of water self-purification capacity. The dissolved oxygen content can reflect the degradation rate of organic matter and the activity level of microorganisms in the water. A high dissolved oxygen content usually means that the water has a strong self-purification capacity and can effectively degrade pollutants.

[0005] (3) Indication of pollution level. When water is polluted by organic matter, microorganisms consume dissolved oxygen in the process of decomposing these organic matter. Therefore, low dissolved oxygen content is often a sign of organic pollution in water.

[0006] (4) Sensitive indicator of water quality changes. Dissolved oxygen content is very sensitive to changes in environmental factors such as water temperature, pH value, and salinity. Therefore, it can be used as an important indicator to monitor changes in water quality.

[0007] At present, the monitoring of dissolved oxygen is inconvenient for the following reasons:

[0008] (1) Real-time requirement: The dissolved oxygen content will change with time and environmental conditions, so frequent sampling and testing are required to ensure the real-time and accuracy of the data.

[0009] (2) Sampling difficulty: Sampling of dissolved oxygen requires special equipment and techniques to ensure that the sample is not affected by external oxygen during collection, transportation and testing, which increases the difficulty and cost of sampling.

[0010] (3) Limitations of laboratory analysis: Traditional dissolved oxygen testing usually needs to be performed in a laboratory, which is time-consuming and cannot provide real-time data.

[0011] (4) Influence of environmental factors: The dissolved oxygen content is affected by many factors such as water temperature, light, and water flow rate. Changes in these factors make the collection and analysis of dissolved oxygen more complicated.

[0012] Based on this, this paper considers using artificial neural networks to predict dissolved oxygen, thereby reducing the difficulty and cost of water quality monitoring. Summary of the invention

[0013] In response to the needs and shortcomings of current technological development, the present invention provides a water quality prediction method and system based on an artificial neural network, aiming to efficiently and accurately predict the dissolved oxygen content in water bodies, while providing a scientific basis for water quality management, and solving the problems of traditional dissolved oxygen monitoring methods such as difficulty, high cost, poor real-time performance, and low accuracy.

[0014] In the first aspect, the present invention provides a water quality prediction method based on an artificial neural network, and the technical solution adopted to solve the above technical problems is as follows:

[0015] A water quality prediction method based on artificial neural network comprises the following steps:

[0016] Acquire a water quality data set and preprocess the water quality data set;

[0017] The preprocessed water quality dataset is randomly divided into training set and test set;

[0018] Construct multi-layer perceptron models, long short-term memory network models, and clustered multi-layer perceptron models;

[0019] Using the training set to train the multilayer perceptron model, the long short-term memory network model and the clustered multilayer perceptron model, and using the test set to test the trained multilayer perceptron model, the long short-term memory network model and the clustered multilayer perceptron model;

[0020] The root mean square errors of the multilayer perceptron model, long short-term memory network model and clustered multilayer perceptron model on the test set are compared, and the model with the smallest root mean square error is selected as the best model.

[0021] Optionally, the water quality dataset involved contains M rows and N columns, wherein the rows represent samples and the columns represent sample features;

[0022] The water quality dataset is preprocessed by deleting features or samples, removing duplicate samples, marking samples, removing missing values, and normalizing them, including:

[0023] Count the number of non-null values ​​in each column and delete the columns whose number of non-null values ​​exceeds the set threshold;

[0024] Delete the rows with abnormal station status in the water quality dataset;

[0025] Delete the rows with exactly the same data in the water quality dataset;

[0026] Mark the dissolved oxygen content of each row in the water quality data set after TI time, after T2 time, and after T3 time as the target value predicted by the model;

[0027] Remove rows with missing values ​​from the water quality dataset;

[0028] The water quality dataset is normalized using MinMaxScaler.

[0029] Further optionally, the water quality data set involved is a set of continuous sequence data monitored every t hours, wherein TI, T2, and T3 are integer multiples of t;

[0030] Based on the dissolved oxygen content of each row in the labeled water quality data set after TI time, T2 time and T3 time, three multi-layer perceptron models, a long short-term memory network model and a clustered multi-layer perceptron model were constructed respectively.

[0031] Optionally, the preprocessed water quality dataset is randomly divided into a training set and a test set in a ratio of 3:1.

[0032] Optionally, the multilayer perceptron model, long short-term memory network model and clustered multilayer perceptron model involved are respectively composed of an input layer, an output layer and at least one hidden layer, wherein the number of nodes in the input layer is equal to the number of features contained in the preprocessed water quality dataset, and the number of nodes in the output layer is 1.

[0033] In a second aspect, the present invention provides a water quality prediction system based on an artificial neural network, and the technical solution adopted to solve the above technical problems is as follows:

[0034] A water quality prediction system based on artificial neural network, comprising:

[0035] An acquisition preprocessing module is used to acquire a water quality data set and preprocess the water quality data set;

[0036] A data partitioning module is used to randomly divide the preprocessed water quality data set into a training set and a test set;

[0037] Model building module, used to build multi-layer perceptron model, long short-term memory network model and clustering multi-layer perceptron model respectively;

[0038] A model training module is used to train a multi-layer perceptron model, a long short-term memory network model, and a clustered multi-layer perceptron model using a training set;

[0039] The model testing module is used to test the trained multi-layer perceptron model, long short-term memory network model and clustering multi-layer perceptron model using the test set;

[0040] The model evaluation module is used to compare the root mean square errors of the multilayer perceptron model, the long short-term memory network model and the clustered multilayer perceptron model on the test set, and select the model with the smallest root mean square error as the best model.

[0041] Optionally, the water quality dataset involved contains M rows and N columns, wherein the rows represent samples and the columns represent sample features;

[0042] The preprocessing module is used to perform feature or sample deletion, sample deduplication, sample labeling, missing value removal, and normalization preprocessing operations on the water quality dataset, including:

[0043] Count the number of non-null values ​​in each column and delete the columns whose number of non-null values ​​exceeds the set threshold;

[0044] Delete the rows with abnormal station status in the water quality dataset;

[0045] Delete the rows with exactly the same data in the water quality dataset;

[0046] Mark the dissolved oxygen content of each row in the water quality data set after TI time, after T2 time, and after T3 time as the target value predicted by the model;

[0047] Remove rows with missing values ​​from the water quality dataset;

[0048] The water quality dataset is normalized using MinMaxScaler.

[0049] Further optionally, the water quality data set involved is a set of continuous sequence data monitored every t hours, wherein TI, T2, and T3 are integer multiples of t;

[0050] Based on the dissolved oxygen content of each row in the labeled water quality data set after TI time, T2 time and T3 time, three multi-layer perceptron models, a long short-term memory network model and a clustered multi-layer perceptron model are constructed respectively through the model building module.

[0051] Optionally, the preprocessed water quality data set is randomly divided into a training set and a test set in a ratio of 3:1 through a data partitioning module.

[0052] Optionally, the multilayer perceptron model, long short-term memory network model and clustering multilayer perceptron model constructed by the model building module involved are respectively composed of an input layer, an output layer and at least one hidden layer, wherein the number of nodes in the input layer is equal to the number of features contained in the preprocessed water quality data set, and the number of nodes in the output layer is 1.

[0053] The water quality prediction method and system based on artificial neural network of the present invention have the following beneficial effects compared with the prior art:

[0054] The present invention significantly improves the speed and efficiency of data acquisition by real-time online monitoring of water quality data, thereby overcoming the limitations of traditional monitoring methods; by adopting advanced neural network models, such as a multi-layer perceptron model, a long short-term memory network model, and a clustered multi-layer perceptron model, accurate prediction of dissolved oxygen content is achieved, thereby improving the reliability of water quality monitoring. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Attached Figure 1 is a flow chart of a method according to Embodiment 1 of the present invention;

[0056] Attached Figure 2 This is a module connection block diagram of the second embodiment of the present invention. DETAILED DESCRIPTION

[0057] In order to make the technical solution, the technical problem solved and the technical effect of the present invention more clearly understood, the technical solution of the present invention is clearly and completely described below in conjunction with specific embodiments.

[0058] Embodiment 1:

[0059] Combined with Figure 1 This embodiment proposes a water quality prediction method based on an artificial neural network, which includes the following steps:

[0060] S1. Obtain a water quality data set and preprocess the water quality data set.

[0061] The water quality dataset involved in this example is monitored and provided by the National Surface Water Quality Automatic Monitoring Station that has been built and officially put into operation by the China National Environmental Monitoring Center (CNEMC). The data contains water samples collected from three sections of the Yangtze River in Jiangsu Province, China, namely the Qiqiaoweng section, Xiaowan section, and Sanjiangying section in Nanjing, Wuxi, and Yangzhou. From January 2021 to June 2022, sampling and monitoring were carried out every four hours in these three sections.

[0062] The water quality data set obtained in this embodiment contains 9428 rows and 13 columns, where rows represent samples and columns represent sample features. The 13 sample features are monitoring time (Time), water temperature (Temp), pH value, dissolved oxygen (DO), potassium permanganate index (PP), ammonia nitrogen (NN), total phosphorus (TP), total nitrogen (TN), conductivity (Cond), turbidity (Turb), chlorophyll (Chl-a), algae density and site status.

[0063] The water quality dataset is preprocessed by deleting features or samples, removing duplicate samples, marking samples, removing missing values, and normalizing them, including:

[0064] S1.1. Count the number of non-null values ​​in each column and delete the columns whose number of non-null values ​​exceeds the set threshold. This step specifically deletes the columns corresponding to the two features of chlorophyll and algae density.

[0065] S1.2. Delete the rows with abnormal station status in the water quality data set. Since the station status may be abnormal, only the samples monitored under normal station conditions are retained, and the samples monitored under abnormal station conditions are deleted.

[0066] S1.3. Delete the rows with exactly the same data in the water quality dataset, that is, delete the samples with exactly the same sample characteristics.

[0067] S1.4. Mark the dissolved oxygen content of each row in the water quality dataset after 12 hours, 1 day, and 1 week as the target value predicted by the model.

[0068] S1.5. Remove rows with missing values ​​in the water quality dataset.

[0069] It should be added that: considering that the water quality dataset in the current step contains 10 features, namely: monitoring time (Time), water temperature (Temp), pH value, dissolved oxygen (DO), potassium permanganate index (PP), ammonia nitrogen (NN), total phosphorus (TP), total nitrogen (TN), conductivity (Cond) and turbidity (Turb). Except for the monitoring time (Time) feature, the data types of the remaining 9 features are all floating point numbers. Therefore, the monitoring time (Time) feature is formatted to make its type datetime, and then the subsequent steps are performed on the 9 features of water temperature (Temp), pH value, dissolved oxygen (DO), potassium permanganate index (PP), ammonia nitrogen (NN), total phosphorus (TP), total nitrogen (TN), conductivity (Cond) and turbidity (Turb).

[0070] S1.6. Use MinMaxScaler to normalize the water quality dataset. MinMaxScaler converts the minimum value to 0, the maximum value to 1, and all the values ​​in between to decimals between 0 and 1. The formula involved is as follows:

[0071]

[0072] In the formula, x represents the sample eigenvalue, x norm Represents the normalized sample feature value.

[0073] The normalized data can be used for training and evaluating machine learning models.

[0074] S2. Randomly divide the preprocessed water quality dataset into training set and test set.

[0075] In this embodiment, the preprocessed water quality data set is randomly divided into a training set and a test set in a ratio of 3:1.

[0076] S3. Construct a multilayer perceptron model (MLP), a long short-term memory network model (LSTM) and a clustering multilayer perceptron model (K-Means-MLP) based on artificial neural networks with different architectures.

[0077] The multilayer perceptron model (MLP), long short-term memory network model (LSTM) and clustered multilayer perceptron model (K-Means-MLP) are composed of an input layer, an output layer and at least one hidden layer, respectively. The number of nodes in the input layer is equal to the number of features contained in the preprocessed water quality dataset, that is, 9, and the number of nodes in the output layer is 1.

[0078] It should be added that the multilayer perceptron model (MLP) is a feedforward neural network composed of multiple neuron layers, usually including an input layer, one or more hidden layers, and an output layer. Each layer consists of multiple neurons, of which there can be multiple hidden layers. Each neuron is connected to all neurons in the previous layer, and information is transmitted and processed through weights and activation functions. The main feature of the multilayer perceptron model (MLP) is its full connectivity, that is, each neuron is connected to all neurons in the previous layer. This structure enables MLP to handle complex nonlinear problems. During the training process, the multilayer perceptron model (MLP) usually uses a backpropagation algorithm to update weights and biases to minimize the error between the predicted results and the true labels.

[0079] The Long Short-Term Memory (LSTM) network model is a special recurrent neural network (RNN) that solves the gradient vanishing / exploding problem of traditional RNN by introducing a "gate" structure. The memory unit of the Long Short-Term Memory (LSTM) network model can effectively retain previous information while also responding effectively to new inputs, which makes LSTM particularly suitable for processing sequential data such as time series, speech, and natural language.

[0080] The K-Means-MLP model combines the features of the K-means clustering algorithm and the MLP. First, the K-means algorithm is used to divide the data set into several groups, and then the MLP model is applied to each group for training. This method can improve the training efficiency and generalization ability of the model while maintaining the original characteristics of the data.

[0081] Simply put, the multilayer perceptron model (MLP) is suitable for processing complex nonlinear problems, the long short-term memory network model (LSTM) is suitable for processing sequential data, and the clustering multilayer perceptron model (K-Means-MLP) combines the advantages of clustering and neural networks and is suitable for classification tasks of large-scale data sets.

[0082] S4. Use the training set to train the multilayer perceptron model (MLP), long short-term memory network model (LSTM) and clustered multilayer perceptron model (K-Means-MLP), and use the test set to test the trained multilayer perceptron model (MLP), long short-term memory network model (LSTM) and clustered multilayer perceptron model (K-Means-MLP).

[0083] During the training process, since the dissolved oxygen content of each row in the water quality data set after 12 hours, 1 day and 1 week is marked as the target value predicted by the model, three multi-layer perceptron models (MLP) are constructed, with the nine sample features contained in the training set as input and the dissolved oxygen content of each row (i.e. each sample) in the marked water quality data set after 12 hours, 1 day and 1 week as output, and the three multi-layer perceptron models (MLP) are trained. After the training is completed, the three multi-layer perceptron models (MLP) are tested using the test set, and then the performance indicators of each model (such as accuracy, recall rate, F1 score, etc.) are calculated based on the test results, and these indicators are compared to determine which model has the best prediction effect, and finally the multi-layer perceptron model (MLP) with the best prediction effect is output.

[0084] Similarly, three long short-term memory network models (LSTM) and clustered multilayer perceptron models (K-Means-MLP) are constructed respectively, and the model training, testing and performance evaluation are carried out according to the above process, and the long short-term memory network model (LSTM) and clustered multilayer perceptron model (K-Means-MLP) with the best prediction effect are output.

[0085] S5. Since the models output above are the best performing multilayer perceptron model (MLP), long short-term memory network model (LSTM) and clustered multilayer perceptron model (K-Means-MLP), the root mean square error RMSE of the output multilayer perceptron model (MLP), long short-term memory network model (LSTM) and clustered multilayer perceptron model (K-Means-MLP) on the test set is then compared. Finally, the model with the smallest root mean square error RMSE is selected from the multilayer perceptron model (MLP), long short-term memory network model (LSTM) and clustered multilayer perceptron model (K-Means-MLP) as the best model for subsequent water quality prediction.

[0086] Embodiment 2:

[0087] Combined with Figure 2 This embodiment proposes a water quality prediction system based on an artificial neural network, which includes:

[0088] An acquisition preprocessing module is used to acquire a water quality data set and preprocess the water quality data set;

[0089] A data partitioning module is used to randomly divide the preprocessed water quality data set into a training set and a test set;

[0090] Model building module, used to build multi-layer perceptron model (MLP), long short-term memory network model (LSTM) and clustering multi-layer perceptron model (K-Means-MLP) respectively;

[0091] The model training module is used to train the multi-layer perceptron model (MLP), the long short-term memory network model (LSTM) and the clustering multi-layer perceptron model (K-Means-MLP) using the training set;

[0092] The model testing module is used to test the trained multi-layer perceptron model (MLP), long short-term memory network model (LSTM) and clustering multi-layer perceptron model (K-Means-MLP) using the test set;

[0093] The model evaluation module is used to compare the root mean square error (RMSE) of the multilayer perceptron model (MLP), the long short-term memory network model (LSTM) and the clustered multilayer perceptron model (K-Means-MLP) on the test set, and select the model with the smallest root mean square error (RMSE) as the best model.

[0094] In this example, the water quality data set involved is monitored and provided by the National Surface Water Quality Automatic Monitoring Station that has been built and officially put into operation by the China National Environmental Monitoring Center (CNEMC). The data contains water samples collected from three sections of the Yangtze River Basin in Jiangsu Province, China, namely the Qiqiaoweng section, Xiaowan section, and Sanjiangying section in Nanjing, Wuxi, and Yangzhou. From January 2021 to June 2022, sampling and monitoring were carried out every four hours in these three sections.

[0095] The water quality data set obtained in this embodiment contains 9428 rows and 13 columns, where rows represent samples and columns represent sample features. The 13 sample features are monitoring time (Time), water temperature (Temp), pH value, dissolved oxygen (DO), potassium permanganate index (PP), ammonia nitrogen (NN), total phosphorus (TP), total nitrogen (TN), conductivity (Cond), turbidity (Turb), chlorophyll (Chl-a), algae density and site status.

[0096] This embodiment performs preprocessing operations on the water quality data set by obtaining a preprocessing module to delete features or samples, remove sample duplication, mark samples, remove missing values, and normalize, specifically including:

[0097] (1) Count the number of non-null values ​​in each column and delete the columns whose number of non-null values ​​exceeds the set threshold. In this step, the columns corresponding to the two features of chlorophyll and algae density are deleted.

[0098] (2) Delete the rows with abnormal station status in the water quality data set. Since the station status may be abnormal, only the samples monitored under normal station conditions are retained, and the samples monitored under abnormal station conditions are deleted.

[0099] (3) Delete the rows with exactly the same data in the water quality dataset, that is, delete the samples with exactly the same sample features.

[0100] (4) Mark the dissolved oxygen content of each row in the water quality dataset after 12 hours, 1 day, and 1 week as the target value predicted by the model.

[0101] (5) Remove rows containing missing values ​​in the water quality dataset.

[0102] It should be added that: considering that the water quality dataset in the current step contains 10 features, namely: monitoring time (Time), water temperature (Temp), pH value, dissolved oxygen (DO), potassium permanganate index (PP), ammonia nitrogen (NN), total phosphorus (TP), total nitrogen (TN), conductivity (Cond) and turbidity (Turb). Except for the monitoring time (Time) feature, the data types of the remaining 9 features are all floating point numbers. Therefore, the monitoring time (Time) feature is formatted to make its type datetime, and then the subsequent steps are performed on the 9 features of water temperature (Temp), pH value, dissolved oxygen (DO), potassium permanganate index (PP), ammonia nitrogen (NN), total phosphorus (TP), total nitrogen (TN), conductivity (Cond) and turbidity (Turb).

[0103] (6) Use MinMaxScaler to normalize the water quality dataset. MinMaxScaler converts the minimum value to 0, the maximum value to 1, and all the values ​​in between to decimals between 0 and 1. The formula involved is as follows:

[0104]

[0105] In the formula, x represents the sample eigenvalue, x norm Represents the normalized sample feature value.

[0106] The normalized data can be used for training and evaluating machine learning models.

[0107] In this embodiment, the preprocessed water quality data set is randomly divided into a training set and a test set in a ratio of 3:1 through a data partitioning module.

[0108] In this embodiment, the model building module involved builds a multi-layer perceptron model (MLP), a long short-term memory network model (LSTM) and a clustered multi-layer perceptron model (K-Means-MLP) based on artificial neural networks with different architectures.

[0109] The multilayer perceptron model (MLP), long short-term memory network model (LSTM) and clustered multilayer perceptron model (K-Means-MLP) are composed of an input layer, an output layer and at least one hidden layer, respectively. The number of nodes in the input layer is equal to the number of features contained in the preprocessed water quality dataset, that is, 9, and the number of nodes in the output layer is 1.

[0110] It should be added that the multilayer perceptron model (MLP) is a feedforward neural network composed of multiple neuron layers, usually including an input layer, one or more hidden layers, and an output layer. Each layer consists of multiple neurons, of which there can be multiple hidden layers. Each neuron is connected to all neurons in the previous layer, and information is transmitted and processed through weights and activation functions. The main feature of the multilayer perceptron model (MLP) is its full connectivity, that is, each neuron is connected to all neurons in the previous layer. This structure enables MLP to handle complex nonlinear problems. During the training process, the multilayer perceptron model (MLP) usually uses a backpropagation algorithm to update weights and biases to minimize the error between the predicted results and the true labels.

[0111] The Long Short-Term Memory (LSTM) network model is a special recurrent neural network (RNN) that solves the gradient vanishing / exploding problem of traditional RNN by introducing a "gate" structure. The memory unit of the Long Short-Term Memory (LSTM) network model can effectively retain previous information while also responding effectively to new inputs, which makes LSTM particularly suitable for processing sequential data such as time series, speech, and natural language.

[0112] The K-Means-MLP model combines the features of the K-means clustering algorithm and the MLP. First, the K-means algorithm is used to divide the data set into several groups, and then the MLP model is applied to each group for training. This method can improve the training efficiency and generalization ability of the model while maintaining the original characteristics of the data.

[0113] Simply put, the multilayer perceptron model (MLP) is suitable for processing complex nonlinear problems, the long short-term memory network model (LSTM) is suitable for processing sequential data, and the clustering multilayer perceptron model (K-Means-MLP) combines the advantages of clustering and neural networks and is suitable for classification tasks of large-scale data sets.

[0114] In this embodiment, the model training module involved uses the training set to train the multi-layer perceptron model (MLP), the long short-term memory network model (LSTM) and the clustered multi-layer perceptron model (K-Means-MLP), and the model testing module uses the test set to test the trained multi-layer perceptron model (MLP), the long short-term memory network model (LSTM) and the clustered multi-layer perceptron model (K-Means-MLP).

[0115] During the training process, since the dissolved oxygen content of each row in the water quality data set after 12 hours, 1 day and 1 week is marked as the target value predicted by the model, three multilayer perceptron models (MLP) are constructed through the model building module, with the nine sample features contained in the training set as input and the dissolved oxygen content of each row (i.e. each sample) in the marked water quality data set after 12 hours, 1 day and 1 week as output to train these three multilayer perceptron models (MLP). After the training is completed, the three multilayer perceptron models (MLP) are tested using the test set, and then the performance indicators of each model (such as accuracy, recall rate, F1 score, etc.) are calculated based on the test results, and these indicators are compared to determine which model has the best prediction effect, and finally the multilayer perceptron model (MLP) with the best prediction effect is output.

[0116] Similarly, three long short-term memory network models (LSTM) and clustered multilayer perceptron models (K-Means-MLP) are constructed through the model building module, and the model training, testing and performance evaluation are carried out according to the above process to output the long short-term memory network model (LSTM) and clustered multilayer perceptron model (K-Means-MLP) with the best prediction effect.

[0117] Since the aforementioned output models are the best performing multilayer perceptron model (MLP), long short-term memory network model (LSTM) and clustered multilayer perceptron model (K-Means-MLP), the model evaluation module involved in this embodiment compares the root mean square error RMSE of the output multilayer perceptron model (MLP), long short-term memory network model (LSTM) and clustered multilayer perceptron model (K-Means-MLP) on the test set, and finally, the model with the smallest root mean square error RMSE is selected from the multilayer perceptron model (MLP), long short-term memory network model (LSTM) and clustered multilayer perceptron model (K-Means-MLP) as the best model for subsequent water quality prediction.

[0118] It should be added that the water quality prediction system described in this embodiment was developed in a Python environment. During the development process, the pandas library and the scikit-learn library were imported for data preprocessing, and the pyplot sub-library of the matplotlib library was used for data visualization. The keras sub-library of tensorflow was used for model development and training.

[0119] For the best performing multilayer perceptron model (MLP), long short-term memory network model (LSTM), and clustered multilayer perceptron model (K-Means-MLP) output by the first and second embodiments, in addition to selecting the root mean square error RMSE to evaluate the model performance, the mean absolute percentage error MAPE can also be used to evaluate the model performance. The specific evaluation results are shown in the following table.

[0120] Table 1 RMSE and MAPE of multilayer perceptron model (MLP)

[0121] 12 hours 1 day 1 week RMSE 0.5764 0.5779 0.7146 MAPE 5.0167 5.0789 6.8782

[0122] Table 2 RMSE and MAPE of long short-term memory network model (LSTM)

[0123] 12 hours 1 day 1 week RMSE 0.5321 0.4838 0.4952 MAPE 4.5687 4.3547 4.1086

[0124] Table 3 RMSE and MAPE of the clustering multilayer perceptron model (K-Means-MLP)

[0125] 12 hours 1 day 1 week RMSE 0.5487 0.5434 0.5667 MAPE 4.6838 4.7089 5.2747

[0126] In summary, the water quality prediction method and system based on artificial neural network of the present invention uses dissolved oxygen (DO) as a symbol of water quality and predicts it in real time, aiming to timely identify signs of water resource deterioration so that relevant environmental management departments can refer to and investigate.

[0127] The above specific examples are used to explain the principles and implementation methods of the present invention in detail. These examples are only used to help understand the core technical content of the present invention. Based on the above specific embodiments of the present invention, any improvements and modifications made by technicians in this technical field without departing from the principles of the present invention should fall within the scope of patent protection of the present invention.

Claims

1. A water quality prediction method based on artificial neural network, characterized in that: The steps include: Acquire a water quality data set and preprocess the water quality data set; The preprocessed water quality dataset is randomly divided into training set and test set; Construct multi-layer perceptron models, long short-term memory network models, and clustered multi-layer perceptron models; Using the training set to train the multilayer perceptron model, the long short-term memory network model and the clustered multilayer perceptron model, and using the test set to test the trained multilayer perceptron model, the long short-term memory network model and the clustered multilayer perceptron model; The root mean square errors of the multilayer perceptron model, long short-term memory network model and clustered multilayer perceptron model on the test set are compared, and the model with the smallest root mean square error is selected as the best model.

2. A water quality prediction method based on artificial neural network according to claim 1, characterized in that: The water quality data set comprises M rows and N columns, wherein rows represent samples and columns represent sample features; The water quality dataset is preprocessed by deleting features or samples, removing duplicate samples, marking samples, removing missing values, and normalizing them, including: Count the number of non-null values ​​in each column and delete the columns whose number of non-null values ​​exceeds the set threshold; Delete the rows with abnormal station status in the water quality dataset; Delete the rows with exactly the same data in the water quality dataset; Mark the dissolved oxygen content of each row in the water quality data set after TI time, after T2 time, and after T3 time as the target value predicted by the model; Remove rows with missing values ​​from the water quality dataset; The water quality dataset is normalized using MinMaxScaler.

3. A water quality prediction method based on artificial neural network according to claim 2, characterized in that: The water quality data set is a set of continuous sequence data monitored every t hours, where TI, T2, and T3 are integer multiples of t; Based on the dissolved oxygen content of each row in the labeled water quality data set after TI time, T2 time and T3 time, three multi-layer perceptron models, a long short-term memory network model and a clustered multi-layer perceptron model were constructed respectively.

4. The water quality prediction method based on artificial neural network according to claim 1 is characterized in that: The preprocessed water quality dataset is randomly divided into training set and test set in a ratio of 3:

1.

5. The water quality prediction method based on artificial neural network according to claim 1 is characterized in that: The multilayer perceptron model, the long short-term memory network model and the clustered multilayer perceptron model are respectively composed of an input layer, an output layer and at least one hidden layer, wherein the number of nodes in the input layer is equal to the number of features contained in the preprocessed water quality data set, and the number of nodes in the output layer is 1.

6. A water quality prediction system based on artificial neural network, characterized in that: It includes: An acquisition preprocessing module is used to acquire a water quality data set and preprocess the water quality data set; A data partitioning module is used to randomly divide the preprocessed water quality data set into a training set and a test set; Model building module, used to build multi-layer perceptron model, long short-term memory network model and clustering multi-layer perceptron model respectively; A model training module is used to train a multi-layer perceptron model, a long short-term memory network model, and a clustered multi-layer perceptron model using a training set; The model testing module is used to test the trained multi-layer perceptron model, long short-term memory network model and clustering multi-layer perceptron model using the test set; The model evaluation module is used to compare the root mean square errors of the multilayer perceptron model, the long short-term memory network model and the clustered multilayer perceptron model on the test set, and select the model with the smallest root mean square error as the best model.

7. A water quality prediction system based on artificial neural network according to claim 6, characterized in that: The water quality data set comprises M rows and N columns, wherein rows represent samples and columns represent sample features; The preprocessing module is used to perform feature or sample deletion, sample deduplication, sample labeling, missing value removal, and normalization preprocessing operations on the water quality dataset, including: Count the number of non-null values ​​in each column and delete the columns whose number of non-null values ​​exceeds the set threshold; Delete the rows with abnormal station status in the water quality dataset; Delete the rows with exactly the same data in the water quality dataset; Mark the dissolved oxygen content of each row in the water quality data set after TI time, after T2 time, and after T3 time as the target value predicted by the model; Remove rows with missing values ​​from the water quality dataset; The water quality dataset is normalized using MinMaxScaler.

8. A water quality prediction system based on artificial neural network according to claim 7, characterized in that: The water quality data set is a set of continuous sequence data monitored every t hours, where TI, T2, and T3 are integer multiples of t; Based on the dissolved oxygen content of each row in the labeled water quality data set after TI time, T2 time and T3 time, three multi-layer perceptron models, a long short-term memory network model and a clustered multi-layer perceptron model are constructed respectively through the model building module.

9. The water quality prediction system based on artificial neural network according to claim 6, characterized in that: The preprocessed water quality data set is randomly divided into training set and test set in a ratio of 3:1 through the data partitioning module.

10. The water quality prediction system based on artificial neural network according to claim 6, characterized in that: The multilayer perceptron model, long short-term memory network model and clustered multilayer perceptron model constructed by the model construction module are respectively composed of an input layer, an output layer and at least one hidden layer, wherein the number of nodes in the input layer is equal to the number of features contained in the preprocessed water quality data set, and the number of nodes in the output layer is 1.

Citation Information

Patent Citations

  • Aquatic cultivation dissolved oxygen prediction method and device

    CN107169610A

  • Dissolved-oxygen prediction method and system based on long short-term memory network

    CN108133297A

  • Water supply quality prediction method based on long-term and short-term memory neural network

    CN111369078A

  • Bank outlet workload prediction method and device, electronic equipment and storage medium

    CN111738505A