River section water quality prediction method based on combined machine learning model
Through combined machine learning models and time series analysis, the problem of insufficient accuracy and response capabilities of existing water quality prediction models in complex environments is solved, real-time prediction and early warning of river section water quality, and the efficiency and science of water environment management are improved. sex.
Patent Information
- Application Number
- CN202411215189.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-12-13
AI Technical Summary
The existing surface water quality prediction model has limited prediction accuracy and generalization capabilities under complex environmental conditions, and lacks real-time updates and self-learning capabilities, making it difficult to meet the needs of long-term water quality prediction and rapid response to emergencies.
Using a method based on a combined machine learning model, integrating support vector machine (SVM), decision tree (DT) and random forest (RF) algorithms, combining time series analysis and Stacking stacking algorithms, build a river section water quality prediction model, and use historical big data Standardize and replenish, and realize real-time prediction and early warning of water quality trends and levels.
It significantly improves the accuracy and response speed of water quality prediction, reduces monitoring costs, enhances the ability to respond quickly to water pollution incidents, ensures timely updates and long-term effectiveness of predicted results, and provides a scientific basis for water environment management.
Smart Images

Figure CN119129772A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of water environment monitoring, and in particular relates to a method for predicting river section water quality based on a combined machine learning model. Background Art
[0002] Surface water quality monitoring is an important measure to ensure the safety of urban and rural water supply, promote economic and social development, and maintain a good ecological environment. The existing water environment monitoring network has a mature water quality index detection system. However, due to the complexity of environmental media and the uncertainty of pollution behavior, the monitoring of river water quality indicators has always been plagued by problems such as low detection frequency, high site cost, expensive online equipment, and lack of early warning capabilities. Therefore, it is urgent to carry out low-cost and high-efficiency surface water quality real-time prediction technology innovation and research and development. At present, conventional surface water quality prediction models are mainly based on statistical models or simple machine learning models for water quality analysis and prediction. However, since the water quality of river monitoring sections is usually affected by multiple sources of hydrology, meteorology, human activities and other environmental factors, traditional statistical models have limitations in adapting to these rapidly changing environmental conditions in different regions, resulting in limited accuracy of prediction results and poor model generalization ability. At the same time, real-time monitoring usually requires high-frequency data collection in order to capture the dynamic changes of water quality in a timely manner, but traditional machine learning models that rely on a small amount of low-frequency monitoring data may have delays in data processing and analysis, and cannot achieve real-time or near-real-time prediction updates. In addition, traditional water quality models lack effective prediction update mechanisms and self-learning capabilities, making it difficult to meet the accuracy and timeliness requirements of long-term water quality prediction tasks, which limits their ability to respond quickly to water quality emergencies. The present invention aims to make full use of the correlation of historical big data of river sections in time series, integrate machine learning algorithms such as support vector machines (SVM), decision trees (DT), and random forests (RF), and construct a combined machine learning model that can predict the water quality change trend and water quality level of river sections in real time, thereby achieving long-term prediction of water quality indicators of river sections and timely warning of potential water pollution events. The establishment of this method not only improves the accuracy of water quality prediction, but also enhances the ability to respond to water pollution risks, providing strong technical support for water environment management and pollution prevention.
[0003] With the development of artificial intelligence technology, intelligent analysis and processing of drone inspection images are gradually replacing manual judgment and improving the level of power grid operation and maintenance. However, existing research mainly improves conventional target detection models based on deep learning from aspects such as expanding data sets, introducing attention mechanisms in feature extraction networks, and multi-scale and multi-stage feature fusion. However, for power towers with characteristics such as multi-angle, multi-scale, multi-posture, and large aspect ratio, there is a lack of targeted improvement methods to effectively improve the model detection accuracy.
[0004] Looking at the existing methods for building water quality prediction models, the following problems still exist: (1) Conventional surface water quality prediction models are mainly based on statistical models or simple machine learning models for water quality analysis and prediction. They perform poorly when dealing with complex changes in environmental conditions, resulting in limited accuracy and generalization of prediction results; (2) Existing models rely on a small amount of historical monitoring data with relatively low frequency, which may have delays in data processing and analysis and cannot achieve real-time or near real-time prediction updates; (3) Traditional water quality models lack effective prediction update mechanisms and self-learning capabilities, making it difficult to meet the accuracy and timeliness requirements of long-term water quality prediction tasks, which limits their ability to respond quickly to water quality emergencies. Summary of the invention
[0005] In view of the shortcomings of the prior art, the present invention proposes a real-time prediction method for river section water quality based on water quality big data and combined machine learning models. This method makes full use of the correlation of historical data of river sections in time series, integrates multiple machine learning algorithms such as SVM, DT, RF, and constructs an intelligent early warning model that can predict the trend of river water quality changes and water quality levels in real time. This model not only improves the accuracy and real-time performance of water quality prediction, but also enhances the ability to respond to sudden water quality events, significantly reduces the cost of monitoring and early warning, and improves the efficiency and scientificity of water environment management. Its self-learning ability and high-frequency data processing capabilities ensure the timely update and long-term effectiveness of the prediction results, providing solid technical support for water pollution prevention and water quality management.
[0006] The purpose of the present invention can be achieved by the following technical solutions:
[0007] A river section water quality prediction method based on a combined machine learning model includes the following steps:
[0008] Establish long-term series Ai,j water quality matrix big data of river monitoring sections, and standardize and complete water quality index data;
[0009] Preparation of water quality index data sets and water quality evaluation data sets, selection and processing of water quality big data features;
[0010] A water quality prediction model was established based on a combined machine learning algorithm.
[0011] Furthermore, water quality matrix big data is established: the long-term water quality big data of river monitoring sections is formed by collecting long-term water quality historical monitoring data of key river monitoring sections and online water quality monitoring data collected at a fixed sampling period to form m groups of water quality monitoring data. Each group of monitoring data corresponds to n types of water quality indicators, and Ai,j = (m, n) water quality matrix big data is obtained.
[0012] Furthermore, water quality index data standardization and completion: the collected Ai,j water quality matrix big data is standardized to reduce the magnitude difference between different water quality characteristics. The data standardization process is as follows:
[0013]
[0014]
[0015]
[0016] Among them, x i is the original water quality index data, μ is the mean of each water quality characteristic, SD is the standard deviation of the water quality characteristic, Z i is the standardized data. In addition, the Lagrange polynomial interpolation method is used to complete the default water quality data. That is, given n+1 known data points (x0, y0), (x1, y1), …, (x n ,y n ), (x n ,y n ), the Lagrange interpolation polynomial P(x) is as follows:
[0017]
[0018] Among them, l i (x) is the Lagrangian basis function, as shown in the formula:
[0019]
[0020] Furthermore, the water quality index data set and the water quality evaluation data set are prepared by arranging the data used for training the model into the water quality index data set and the water quality evaluation data set, wherein the water quality index data set is the standardized water quality matrix big data Ai,j, and the water quality evaluation data set Bi,j is the water quality evaluation data obtained by the water quality single factor evaluation method and the comprehensive factor evaluation method;
[0021] Among all the water quality indicators evaluated, if any single water quality indicator exceeds the standard, the use function of the water area will be lost or cannot be satisfied. The calculation formula is as follows:
[0022] Q=max(Q i )
[0023] In the formula: Q is the comprehensive level of water quality evaluated by a single factor; Qi is the water quality level of evaluation parameter i; max refers to the worst one among the i water quality indicators. Based on this, water quality is divided into categories I, II, III, IV and V;
[0024] The pollution index is calculated by comparing the actual measured water quality parameter values with the established evaluation criteria, and then a comprehensive pollution index is calculated by the equal weighted average method. The calculation formula is as follows:
[0025]
[0026] Where: Pi represents the single factor pollution index corresponding to pollution factor i; Ci refers to the mass concentration of pollution factor i actually measured; Ci0 is the water quality standard value corresponding to pollution factor i.
[0027] The average comprehensive pollution index refers to selecting multiple water quality parameters for comprehensive evaluation, calculating the water quality index by weighted average or arithmetic average of each pollution index, and then performing graded evaluation according to the standards. The calculation formula for the comprehensive pollution index based on the arithmetic average method is as follows:
[0028]
[0029] Where: Pi is the single factor index of pollution factor i; n is the number of indicators involved in water quality evaluation.
[0030] Furthermore, the feature selection and processing of water quality big data uses correlation analysis and principal component analysis (PCA) methods to select important characteristic factors that affect the river section water quality matrix big data Ai,j. At the same time, label encoding (LabelEncoding) is used to convert the water quality evaluation grade classification value in the water quality evaluation data set Bi,j into an integer for quantitative description of the ordered classification characteristics of the water quality grade.
[0031] Furthermore, the development of a water quality prediction model based on a combined machine learning algorithm is based on the collected long-term historical water quality monitoring data. The three integrated algorithms of SVM, DT, and RF are used to carry out supervised machine learning modeling based on long-term series. When training the water quality trend change model, the temperature, pH, dissolved oxygen, and permanganate indexes in the multivariate historical monitoring data in the water quality matrix big data Ai,j are used as input, and the key water quality indicators COD, total nitrogen, total phosphorus, and ammonia nitrogen important characteristic factors are used as model output indicators to carry out multivariate regression supervised learning. When training the water quality grade evaluation model, the multivariate water quality historical data in the water quality evaluation data set Bi,j is used as input, and the surface water environment quality grade Q and the average comprehensive pollution index P based on the single factor evaluation method are used as output to carry out multi-task classification learning. In the training process of these two types of models, Stackin is used. The g-stacking algorithm combines the above three integrated algorithms into a two-layer combined machine learning model. The first layer of the model is composed of three integrated algorithms, namely SVM, DT, and RF, as basic learners. During the training process of the stacked model, a strategy similar to k-fold cross-validation is adopted to train the first-level basic learners; then, combined with the prediction results of the basic learners, the original features can be obtained through majority voting and input into the meta-learner of the second layer as feature information. Finally, according to the prediction results of different weak models in the meta-learner, the input features and output results of the second layer are used as the final features to train the best performance model. The algorithm construction and training process of all models adopt the k-fold cross-validation (k=5) strategy to optimize the hyperparameters and measure the generalizability of the model. The data set is randomly divided into training set and test set according to a specific ratio, and the average value of the prediction results in the evaluation index is output.
[0032] Furthermore, it also includes water quality prediction model performance evaluation: for the water quality trend change model, three indicators, namely, determination coefficient (R2), mean absolute error (MAE) and root mean square error (RMSE), are used to evaluate the model prediction performance:
[0033]
[0034]
[0035]
[0036] Where n is the sample size, is the predicted value, y i is the true value,
[0037] For the water quality grade evaluation model, the prediction accuracy of the confusion matrix is used to evaluate:
[0038]
[0039] Among them, TP is the number of positive samples correctly classified by the classifier, TN is the number of negative samples correctly classified by the classifier, FP is the number of negative samples incorrectly labeled as positive samples, and FN is the number of positive samples incorrectly labeled as negative samples.
[0040] Furthermore, the generalization ability test of the water quality prediction model is also included: the combined machine learning model trained on historical data is used to predict the water quality trend and water quality grade of river sections in the future long-term series. In the model evaluation stage, R 2 , RSME and MAE statistical indicators are used to measure the predictive performance of the water quality trend change model; Accuracy is used to evaluate the prediction accuracy of the water quality grade evaluation model.
[0041] A river section water quality prediction system based on a combined machine learning model, comprising:
[0042] Water quality data unit: By collecting long-term historical water quality monitoring data of key river monitoring sections and online water quality monitoring data collected at fixed sampling periods, the Ai,j water quality matrix big data is constructed.
[0043] Data collection and processing module: The collected Ai,j water quality matrix big data is standardized, and the important characteristic factors affecting the river section water quality matrix big data Ai,j are selected using correlation analysis and principal component analysis methods. At the same time, label coding is used to convert the water quality evaluation grade classification value in the water quality evaluation data set Bi,j into an integer for quantitative description of the ordered classification characteristics of the water quality grade.
[0044] Algorithm model building module: Based on the collected long-term historical water quality monitoring data, three integrated algorithms, SVM, DT, and RF, are used to carry out supervised machine learning modeling based on long-term series. Combined with the prediction results of the basic learner, the original features can be obtained through majority voting and input into the meta-learner of the second layer as feature information. Finally, according to the prediction results of different weak models in the meta-learner, the input features and output results of the second layer are used as the final features to train the model with the best performance. The data set is randomly divided into training set and test set according to a specific ratio, and the average value of the prediction results in the evaluation index is output.
[0045] A river section water quality prediction device based on a combined machine learning model, comprising:
[0046] one or more processors;
[0047] A memory for storing one or more programs;
[0048] When the one or more programs are executed by the one or more processors, the one or more processors implement the above method.
[0049] Beneficial effects of the present invention:
[0050] 1. This method successfully constructed a model for predicting the trend of water quality changes in river sections and real-time early warning of water quality, realizing forward-looking prediction and real-time alarm of water quality indicators in river sections. By analyzing historical water quality monitoring data, using time series analysis and machine learning algorithms, the trend of water quality changes in river sections in the future is predicted. The model can identify long-term change patterns and seasonal fluctuations of water quality parameters, providing a scientific basis for water quality management and decision-making. At the same time, the model combines real-time water quality monitoring data and statistical learning technology to quickly respond to and warn of potential water quality anomalies and pollution events. By setting thresholds and alarm mechanisms, the model can automatically trigger alarms when water quality indicators exceed the normal range, reminding relevant departments to take timely measures to prevent water quality deterioration and pollution spread;
[0051] 2. By innovatively integrating multiple basic machine learning algorithms such as SVM, DT, and RF, a water quality prediction model based on a combined machine learning model was constructed, which realized the prediction of water quality change trends and water quality grades in river sections. This method significantly improved the accuracy and response speed of water quality prediction, and was able to use historical big data and real-time monitoring data to accurately capture the changing trends and water quality grades of water quality indicators, thereby providing more accurate prediction results. In addition, the model has strong self-learning ability and high-frequency data processing ability, and can automatically adjust the prediction model over time to ensure timely updating and long-term effectiveness of the prediction results. By adopting k-fold cross-validation and Stacking algorithm optimization, the model shows good generalization ability under different environmental conditions, reducing dependence on expensive online monitoring equipment and reducing monitoring costs. More importantly, the technology can timely warn of potential water pollution incidents, providing a scientific basis for water environment management and pollution prevention, and significantly improving the efficiency and scientificity of water environment management. Overall, the present invention is not only technically innovative, but also shows significant economic and social benefits in practical applications, providing strong technical support for the protection and sustainable development of the water environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0053] Figure 1It is a flow chart of the method for predicting water quality of a river section of the present invention;
[0054] Figure 2 It is a water quality prediction model diagram of the present invention combined with a machine learning algorithm;
[0055] Figure 3 It is a quartile diagram of the distribution of water quality data of the sampling points of the present invention;
[0056] Figure 4 is a flow chart of the water quality prediction model training of the present invention combined with the machine learning algorithm;
[0057] Figure 5 It is the three integrated models of SVM, DT, RF and CML model diagram of the present invention;
[0058] Figure 6 It is a statistical chart of the surface water environment quality grade and average comprehensive pollution index prediction of the present invention;
[0059] Figure 7 It is a water quality trend change prediction task diagram of the present invention;
[0060] Figure 8 It is the water quality grade evaluation task diagram of the present invention. DETAILED DESCRIPTION
[0061] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0062] Example 1: Figure 1-8 As shown, a river section water quality prediction method based on a combined machine learning model includes the following steps:
[0063] Establish long-term series Ai,j water quality matrix big data of river monitoring sections, and standardize and complete water quality index data;
[0064] Preparation of water quality index data sets and water quality evaluation data sets, selection and processing of water quality big data features;
[0065] A water quality prediction model was established based on a combined machine learning algorithm.
[0066] Furthermore, water quality matrix big data is established: the long-term water quality big data of river monitoring sections is formed by collecting long-term water quality historical monitoring data of key river monitoring sections and online water quality monitoring data collected at a fixed sampling period to form m groups of water quality monitoring data. Each group of monitoring data corresponds to n types of water quality indicators, and Ai,j=(m,n) water quality matrix big data is obtained.
[0067] Furthermore, water quality index data standardization and completion: the collected Ai,j water quality matrix big data is standardized to reduce the magnitude differences between different water quality characteristics. The data standardization process is as follows:
[0068]
[0069]
[0070]
[0071] Among them, x i is the original water quality index data, μ is the mean of each water quality characteristic, SD is the standard deviation of the water quality characteristic, Z i is the standardized data. In addition, the Lagrange polynomial interpolation method is used to complete the default water quality data. That is, given n+1 known data points (x0, y0), (x1, y1), …, (x n ,y n ), (x n ,y n ), the Lagrange interpolation polynomial P(x) is as follows:
[0072]
[0073] Among them, l i (x) is the Lagrangian basis function, as shown in the formula:
[0074]
[0075] Furthermore, the water quality index data set and the water quality evaluation data set are prepared by arranging the data used for training the model into the water quality index data set and the water quality evaluation data set, wherein the water quality index data set is the standardized water quality matrix big data Ai,j, and the water quality evaluation data set Bi,j is the water quality evaluation data obtained by the water quality single factor evaluation method and the comprehensive factor evaluation method;
[0076] Among all the water quality indicators evaluated, if any single water quality indicator exceeds the standard, the use function of the water area will be lost or cannot be satisfied. The calculation formula is as follows:
[0077] Q=max(Q i )
[0078] In the formula: Q is the comprehensive level of water quality evaluated by a single factor; Qi is the water quality level of evaluation parameter i; max refers to the worst one among the i water quality indicators. Based on this, water quality is divided into categories I, II, III, IV and V;
[0079] Table 1 Surface water environment quality grades based on single factor evaluation method
[0080]
[0081]
[0082] The pollution index is calculated by comparing the actual measured water quality parameter values with the established evaluation criteria, and then a comprehensive pollution index is calculated by the equal weighted average method. The calculation formula is as follows:
[0083]
[0084] Where: Pi represents the single factor pollution index corresponding to pollution factor i; Ci refers to the mass concentration of pollution factor i actually measured; Ci0 is the water quality standard value corresponding to pollution factor i.
[0085] The average comprehensive pollution index refers to selecting multiple water quality parameters for comprehensive evaluation, calculating the water quality index by weighted average or arithmetic average of each pollution index, and then performing graded evaluation according to the standards. The calculation formula for the comprehensive pollution index based on the arithmetic average method is as follows:
[0086]
[0087] Where: Pi is the single factor index of pollution factor i; n is the number of indicators involved in water quality evaluation.
[0088] Furthermore, the feature selection and processing of water quality big data uses correlation analysis and principal component analysis (PCA) methods to select important characteristic factors that affect the river section water quality matrix big data Ai,j. At the same time, label encoding (LabelEncoding) is used to convert the water quality evaluation grade classification value in the water quality evaluation data set Bi,j into an integer for quantitative description of the ordered classification characteristics of the water quality grade.
[0089] Furthermore, the development of a water quality prediction model based on a combined machine learning algorithm is based on the collected long-term historical water quality monitoring data, and three integrated algorithms, SVM, DT, and RF, are used to carry out supervised machine learning modeling based on long-term series. In the training of the water quality trend change model, the temperature, pH, dissolved oxygen, and permanganate indexes in the multivariate historical monitoring data in the water quality matrix big data Ai,j are used as input, and the key water quality indicators COD, total nitrogen, total phosphorus, and ammonia nitrogen important characteristic factors are used as model output indicators to carry out multivariate regression supervised learning. In the training of the water quality grade evaluation model, the multivariate water quality historical data in the water quality evaluation data set Bi,j is used as input, and the surface water environment quality grade Q and the average comprehensive pollution index P based on the single factor evaluation method are used as output to carry out multi-task classification learning, such as Figure 2 As shown in the figure, in the training process of these two types of models, the Stacking algorithm is used to combine the above three integrated algorithms into a two-layer superimposed combined machine learning model. The first layer of the model is composed of three integrated algorithms, namely SVM, DT, and RF, as basic learners. In the training process of the stacking model, a strategy similar to k-fold cross-validation is used to train the first-level basic learners; then, combined with the prediction results of the basic learners, the original features can be obtained through majority voting and input into the meta-learner of the second layer as feature information. Finally, according to the prediction results of different weak models in the meta-learner, the input features and output results of the second layer are used as the final features to train the model with the best performance. The algorithm construction and training process of all models use the k-fold cross-validation (k=5) strategy to optimize the hyperparameters and measure the generalizability of the model. The data set is randomly divided into a training set and a test set according to a specific ratio, and the average value of the prediction results in the evaluation index is output.
[0090] Furthermore, it also includes water quality prediction model performance evaluation: for the water quality trend change model, three indicators, namely, determination coefficient (R2), mean absolute error (MAE) and root mean square error (RMSE), are used to evaluate the model prediction performance:
[0091]
[0092]
[0093]
[0094] Where n is the sample size, is the predicted value, y i is the true value,
[0095] For the water quality grade evaluation model, the prediction accuracy of the confusion matrix is used to evaluate:
[0096]
[0097] Among them, TP is the number of positive samples correctly classified by the classifier, TN is the number of negative samples correctly classified by the classifier, FP is the number of negative samples incorrectly labeled as positive samples, and FN is the number of positive samples incorrectly labeled as negative samples.
[0098] Furthermore, the generalization ability test of the water quality prediction model is also included: the combined machine learning model trained on historical data is used to predict the water quality trend and water quality grade of river sections in the future long-term series. In the model evaluation stage, R 2 , RSME and MAE statistical indicators are used to measure the predictive performance of the water quality trend change model; Accuracy is used to evaluate the prediction accuracy of the water quality grade evaluation model.
[0099] A river section water quality prediction system based on a combined machine learning model, comprising:
[0100] Data establishment module: By collecting long-term historical water quality monitoring data of key river monitoring sections and online water quality monitoring data collected at fixed sampling periods, the Ai,j water quality matrix big data module is constructed.
[0101] Data collection and processing module: The collected Ai,j water quality matrix big data is standardized, and the important characteristic factors affecting the river section water quality matrix big data Ai,j are selected using correlation analysis and principal component analysis methods. At the same time, label coding is used to convert the water quality evaluation grade classification value in the water quality evaluation data set Bi,j into an integer for quantitative description of the ordered classification characteristics of the water quality grade.
[0102] Algorithm model building module: Based on the collected long-term historical water quality monitoring data, three integrated algorithms, SVM, DT, and RF, are used to carry out supervised machine learning modeling based on long-term series. Combined with the prediction results of the basic learner, the original features can be obtained through majority voting and input into the meta-learner of the second layer as feature information. Finally, according to the prediction results of different weak models in the meta-learner, the input features and output results of the second layer are used as the final features to train the model with the best performance. The data set is randomly divided into training set and test set according to a specific ratio, and the average value of the prediction results in the evaluation index is output.
[0103] A river section water quality prediction device based on a combined machine learning model, comprising:
[0104] one or more processors;
[0105] A memory for storing one or more programs;
[0106] When the one or more programs are executed by the one or more processors, the one or more processors implement the above method.
[0107] Embodiment 2:
[0108] like Figure 4 As shown in the figure, a river section water quality prediction method based on a combined machine learning model is proposed. According to the steps of this method, continuous water quality monitoring data is collected and standardized into a water quality index data set and a water quality evaluation data set; then, a CML model based on the Stacking algorithm is constructed using three integrated models, namely, SVM, DT, and RF, for the prediction of water quality trend changes and water quality grade evaluation of river sections; finally, the results of the two types of water quality prediction models are evaluated, including the following:
[0109] (1) Description of water quality data of river monitoring sections: This method uses statistical analysis methods to statistically describe the water quality data of river monitoring sections, aiming to reveal the distribution characteristics and potential data structure of water quality parameters. The statistical analysis method is used to describe the data distribution, that is, the distribution of water quality data of all sampling points is displayed using a quartile diagram, see Figure 3 .
[0110] (2) Preparation of water quality data set: Through operations such as data standardization, completion, and calculation of label values, the above water quality indicator data set is converted into water quality matrix big data and water quality evaluation data set to prepare for subsequent model training.
[0111] (3) Training of water quality prediction models based on combined machine learning algorithms: Based on the online water quality monitoring data (January-November 2023), three integrated models of SVM, DT, and RF, as well as the CML model, are used to conduct in-depth analysis and prediction of the water quality parameters of the section from January to November, and the generalization of each model is evaluated by performing k-fold cross-validation on the training data.
[0112] (4) Model evaluation: For the water quality trend change model, the three indicators of R2, MAE and RMSE were used to evaluate the model prediction performance; for the water quality grade evaluation model, the prediction accuracy of the confusion matrix was used to evaluate. Figure 5The prediction results of the water quality trend and water quality grade of the section from January 1, 2023 to November 30, 2023 for three integrated models, SVM, DT, and RF, as well as the CML model, are shown. It can be seen that in the task of predicting water quality trend changes, compared with the three integrated models of SVM, DT, and RF, the CML model has the highest degree of overlap between the predicted trend lines of the four water quality indicators and the trend of online monitoring data. When predicting COD, NH3-N, TN, and TP, the R2 between the true value and the predicted value are 0.924, 0.897, 0.925, and 0.937, respectively, the sample standard deviation RMSE is 4.421, 0.223, 0.931, and 0.039, respectively, and the mean absolute error MAE is 2.511, 0.101, 0.531, and 0.025, respectively. All evaluation parameters are good, and it can be used as an ideal water quality trend prediction model.
[0113] For the water quality grade evaluation model, the CML model was selected as the ideal model to predict the surface water environmental quality grade and the average comprehensive pollution index.
[0114] like Figure 6 As shown in the figure, the confusion matrix is used to evaluate the prediction accuracy of the model for the surface water environment quality grade Q, and R2, RMSE and MAE are used to evaluate the prediction of the average comprehensive pollution index P of the section. It can be seen from the confusion matrix a that the overall performance of the model is good considering all grades. The prediction accuracy of grade I is 100%, grade II is 55%, grade III is 71%, grade IV is 79%, grade V is 74%, and the prediction accuracy of grade V is 93%. The average prediction accuracy of water quality grade is 78.67%, especially for the prediction accuracy of grade V, which shows the high efficiency of the model in predicting extreme water quality conditions. As shown in Figure b, the values of model R2, RMSE and MAE are 0.994, 0.043 and 0.020 respectively. All evaluation parameters are good and can be used as an ideal water quality grade prediction model.
[0115] (5) Test of the generalization ability of the water quality prediction model: In order to confirm the generalization performance of the water quality prediction model and its accuracy in predicting future water quality changes, this method further used the above-mentioned trained model to predict the water quality of the section during the period of 2023.12.01-2023.12.16. In the empirical analysis, the prediction output of the CML model was compared and contrasted in detail with the actual online monitoring data of the same period. Through this comparative analysis, the performance of the model on an independent data set can be evaluated, thereby verifying its applicability and effectiveness in actual water environment monitoring and prediction, and in the task of predicting water quality trend changes (see Figure 7), the R2 between the predicted values of COD, NH3-N, TN and TP obtained by the CML model and their true values were 0.963, 0.888, 0.718 and 0.888, respectively, which was still the best prediction effect among all models, and the overlap between the water quality trend prediction and the online monitoring data was the highest. The CML model was not only excellent in quantitative prediction accuracy, but also showed a high accuracy in trend prediction, which showed that it had good generalization ability and robustness in water quality trend prediction.
[0116] In the water quality assessment task (see Figure 8 ), the real water quality level of water quality data was comprehensively evaluated by single factor evaluation method and comprehensive pollution index evaluation method, and then analyzed and fitted with the predicted values obtained by the trained CML model. It can be seen that in the confusion matrix, the CML model performed well as a whole, and its prediction accuracy for the I, II, III, IV, V and inferior V water quality levels of the river section in December was 100%, 100%, 76.5%, 77.78%, 25% and 100% respectively. It can be seen that the model has a very high prediction accuracy for the inferior V water quality of the section, which can meet the needs of water quality forecasting and early warning of river sections. These results show that the model has shown high accuracy and reliability in predicting water quality levels, especially in the identification of higher pollution levels. In addition, the predicted value of the comprehensive water pollution index P obtained by the CML model is scatter fit with the true value. It can be seen that the R2 of scatter point fitting can reach above 0.99, the RMSE is 0.043 and 0.023 respectively, and the MAE is 0.02 and 0.016 respectively. This shows that the model fits the unknown data in December 2023 well and can meet the needs of comprehensive water quality pollution evaluation.
[0117] Among them: Water quality prediction model: The water quality prediction model is a mathematical and statistical tool applied in the field of environmental science and engineering. It aims to predict the future changing trends of various chemical, physical and biological parameters in water bodies by analyzing historical water quality monitoring data, in order to assess the health status and potential risks of the water environment.
[0118] Machine learning: Machine learning is a data-driven intelligent analysis method that uses algorithms to learn patterns and regularities from large amounts of data in order to make predictions or decisions about new data.
[0119] Correlation analysis: Correlation analysis is a statistical method used to evaluate whether there is a certain statistical correlation between two or more variables and to quantify the strength and direction of this relationship. By calculating correlation coefficients, such as the Pearson correlation coefficient, the linear relationship between variables can be revealed, providing a basis for in-depth research on the potential connection between variables.
[0120] Principal component analysis: Principal component analysis (PCA) is a dimensionality reduction technique that transforms a set of possibly correlated variables into a set of linearly uncorrelated variables, called principal components, through an orthogonal transformation. This method aims to extract the main variation information in a data set and is often used in exploratory data analysis and in constructing low-dimensional data representations to simplify the model and reveal the inherent structure of the data.
[0121] Recursive feature elimination: Recursive feature elimination is a feature selection method that recursively builds a model and removes the feature with the smallest weight coefficient in each iteration until the required number of features is reached. It optimizes model performance by gradually reducing the feature set to ensure that the selected features contribute significantly to the prediction results, thereby improving the interpretability and accuracy of the model.
[0122] Decision tree: Decision tree (DT) is a supervised learning algorithm that recursively divides the data set into smaller and smaller subsets and applies simple decision rules to each subset to build a tree-like classification or regression model. It forms internal nodes and leaf nodes through feature selection and node splitting to simulate the logic and causal relationships in the decision-making process and realize the prediction of new data.
[0123] Support vector machine: Support vector machine (SVM) is a supervised learning model used for classification and regression analysis. It achieves accurate classification or prediction of new samples by finding the optimal hyperplane in the feature space to maximize the boundary distance between data points. SVM has powerful processing capabilities for high-dimensional data and nonlinear problems. It maps data to high-dimensional space through kernel techniques to solve complex pattern recognition tasks.
[0124] Random Forest: Random Forest (RF) is an ensemble learning method that builds multiple decision trees and aggregates their prediction results to improve the prediction accuracy and robustness of the model. RF reduces the risk of overfitting and enhances the generalization ability of the model by introducing randomness in the training process, such as randomly selecting data samples and features. This method is suitable for classification and regression problems and is easy to process and adjust in parallel, making it particularly effective in big data applications.
[0125] Cross-validation: Cross-validation is a statistical technique used to evaluate and improve the predictive performance of a model. It splits the dataset into multiple subsets, uses one of the subsets as a test set, and the rest as a training set, and performs multiple iterations of training and validation. This method can effectively evaluate the generalization ability of the model on unknown data, reduce overfitting, and provide robust performance estimates for model selection and parameter tuning.
[0126] Model generalization ability: Model generalization ability refers to the ability of a machine learning model to predict unseen data. A model with good generalization ability can learn generally applicable patterns from training data and make accurate predictions on new, independent data. This requires the model to not only perform well on the training set, but also maintain stable performance on the validation set or test set to avoid overfitting and ensure that the model's prediction results are widely applicable and reliable.
[0127] Water quality single factor index evaluation method: Water quality single factor index evaluation method is a water quality assessment method in environmental science. It evaluates water quality conditions by calculating the degree of deviation of a single water quality parameter relative to its standard value. This method assigns a single factor index to each monitored parameter, which is usually calculated based on the ratio between the measured concentration and the water quality standard. Through this method, the contribution of each parameter to water pollution can be quantified, providing intuitive evaluation indicators for water environment management and pollution control.
[0128] Comprehensive water pollution index evaluation method: Comprehensive water pollution index evaluation method is a method for comprehensively evaluating the degree of water pollution. It calculates an overall pollution index by comprehensively considering the single factor index of multiple water quality parameters and assigning different weights. This method can comprehensively reflect the pollution status of water bodies, identify major pollution sources and pollutants, and provide a scientific basis for water quality management and the formulation of pollution prevention and control strategies. The level of the comprehensive pollution index is directly related to the health status of the water environment and the level of ecological risk.
[0129] Confusion matrix: The confusion matrix is a tool for evaluating model performance in classification problems. It constructs a table with columns representing predicted categories and rows representing actual categories to visualize the accuracy of model predictions. Each cell in the matrix represents the number of samples that combine the actual category with the predicted category, so that the true positives (TP), false positives (FP), true negatives (TN), and false negatives (FN) of the model can be calculated, and evaluation indicators such as accuracy, recall, precision, and F1 score can be obtained.
[0130] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example, and the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0131] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments, and the above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, and these changes and improvements all fall within the scope of the present invention to be protected.
Claims
1. A river section water quality prediction method based on a combined machine learning model, characterized in that: The following steps are involved: Establish long-term series Ai,j water quality matrix big data of river monitoring sections, and standardize and complete water quality index data; Preparation of water quality index datasets and water quality evaluation datasets, and selection and processing of water quality big data features; A water quality prediction model was established based on a combined machine learning algorithm.
2. The method for predicting river section water quality based on a combined machine learning model according to claim 1, characterized in that: Establishment of water quality matrix big data: The long-term water quality big data of river monitoring sections is formed by collecting long-term historical water quality monitoring data of key river monitoring sections and online water quality monitoring data collected at a fixed sampling period to form m groups of water quality monitoring data. Each group of monitoring data corresponds to n types of water quality indicators, and Ai,j = (m, n) water quality matrix big data is obtained.
3. The method for predicting river section water quality based on a combined machine learning model according to claim 2, characterized in that: Water quality index data standardization and completion: The collected Ai,j water quality matrix big data is standardized to reduce the magnitude differences between different water quality characteristics. The data standardization process is as follows: Among them, x i is the original water quality index data, μ is the mean of each water quality characteristic, SD is the standard deviation of the water quality characteristic, Z i is the standardized data. In addition, the Lagrange polynomial interpolation method is used to complete the default water quality data. That is, given n+1 known data points (x0, y0), (x1, y1), …, (x n ,y n ), (x n ,y n ), Lagrange interpolation polynomial P(x) is as follows: Among them, l i (x) is the Lagrangian basis function, as shown in the formula:
4. The method for predicting river section water quality based on a combined machine learning model according to claim 3, characterized in that: The preparation of water quality index data set and water quality evaluation data set is to organize the data used for training the model into water quality index data set and water quality evaluation data set, where the water quality index data set is the standardized water quality matrix big data Ai,j, and the water quality evaluation data set Bi,j is the water quality evaluation data obtained by the water quality single factor evaluation method and the comprehensive factor evaluation method; Among all the water quality indicators evaluated, if any single water quality indicator exceeds the standard, the use function of the water area will be lost or cannot be satisfied. The calculation formula is as follows: Q=max(Q i ) In the formula: Q is the comprehensive level of water quality evaluated by a single factor; Qi is the water quality level of evaluation parameter i; max refers to the worst one among the i water quality indicators. Based on this, water quality is divided into categories I, II, III, IV and V; The pollution index is calculated by comparing the actual measured water quality parameter values with the established evaluation criteria, and then a comprehensive pollution index is calculated by the equal weighted average method. The calculation formula is as follows: Where: Pi represents the single factor pollution index corresponding to pollution factor i; Ci refers to the mass concentration of pollution factor i actually measured; Ci0 is the water quality standard value corresponding to pollution factor i. The average comprehensive pollution index refers to selecting multiple water quality parameters for comprehensive evaluation, calculating the water quality index by weighted average or arithmetic average of each pollution index, and then performing graded evaluation according to the standards. The calculation formula for the comprehensive pollution index based on the arithmetic average method is as follows: Where: Pi is the single factor index of pollution factor i; n is the number of indicators involved in water quality evaluation.
5. The method for predicting river section water quality based on a combined machine learning model according to claim 4, characterized in that: The feature selection and processing of water quality big data is to use correlation analysis and principal component analysis (PCA) methods to select important characteristic factors that affect the river section water quality matrix big data Ai,j. At the same time, label encoding is used to convert the water quality evaluation grade classification value in the water quality evaluation data set Bi,j into an integer for quantitative description of the ordered classification characteristics of water quality grades.
6. A river section water quality prediction method based on a combined machine learning model according to claim 5, characterized in that: The development of water quality prediction model based on combined machine learning algorithm is based on the collected long-term historical water quality monitoring data, and uses three integrated algorithms, SVM, DT and RF, to carry out supervised machine learning modeling based on long-term series. In the training of water quality trend change model, the temperature, pH, dissolved oxygen and permanganate indexes in the multivariate historical monitoring data in the water quality matrix big data Ai,j are used as input, and the key water quality indicators COD, total nitrogen, total phosphorus and ammonia nitrogen important characteristic factors are used as model output indicators to carry out multivariate regression supervised learning. In the training of water quality grade evaluation model, the multivariate water quality historical data in the water quality evaluation data set Bi,j is used as input, and the surface water environment quality grade Q and the average comprehensive pollution index P based on the single factor evaluation method are used as output to carry out multi-task classification learning. In the training process of these two types of models, Stacking is used The algorithm combines the above three integrated algorithms into a two-layer stacked combined machine learning model. The first layer of the model is composed of three integrated algorithms, SVM, DT, and RF, as basic learners. In the training process of the stacked model, a strategy similar to k-fold cross-validation is used to train the first-level basic learners; then, combined with the prediction results of the basic learners, the original features can be obtained through majority voting and input into the meta-learner of the second layer as feature information. Finally, according to the prediction results of different weak models in the meta-learner, the input features and output results of the second layer are used as the final features to train the best performance model. The algorithm construction and training process of all models use the k-fold cross-validation (k=5) strategy to optimize hyperparameters and measure the generalizability of the model. The data set is randomly divided into training set and test set according to a specific ratio, and the average value of the prediction results in the evaluation index is output.
7. A method for predicting river section water quality based on a combined machine learning model according to claim 6, characterized in that: It also includes water quality prediction model performance evaluation: for the water quality trend change model, three indicators, namely, determination coefficient (R2), mean absolute error (MAE) and root mean square error (RMSE), are used to evaluate the model prediction performance: Where n is the sample size, is the predicted value, y i is the true value, For the water quality grade evaluation model, the prediction accuracy of the confusion matrix is used to evaluate: Among them, TP is the number of positive samples correctly classified by the classifier, TN is the number of negative samples correctly classified by the classifier, FP is the number of negative samples incorrectly labeled as positive samples, and FN is the number of positive samples incorrectly labeled as negative samples.
8. The method for predicting river section water quality based on a combined machine learning model according to claim 6, characterized in that: It also includes the generalization ability test of the water quality prediction model: the combined machine learning model trained on historical data is used to predict the water quality trend and water quality grade of river sections in the future long-term series. In the model evaluation stage, R 2 , RSME and MAE statistical indicators are used to measure the predictive performance of the water quality trend change model; Accuracy is used to evaluate the prediction accuracy of the water quality grade evaluation model.
9. A river section water quality prediction system based on a combined machine learning model, characterized in that: include: Water quality data unit: By collecting long-term historical water quality monitoring data of key river monitoring sections and online water quality monitoring data collected at fixed sampling periods, the Ai,j water quality matrix big data is constructed. Data collection and processing module: The collected Ai,j water quality matrix big data is standardized, and the important characteristic factors affecting the river section water quality matrix big data Ai,j are selected using correlation analysis and principal component analysis methods. At the same time, label coding is used to convert the water quality evaluation grade classification value in the water quality evaluation data set Bi,j into an integer for quantitative description of the ordered classification characteristics of the water quality grade. Algorithm model building module: Based on the collected long-term historical water quality monitoring data, three integrated algorithms, SVM, DT, and RF, are used to carry out supervised machine learning modeling based on long-term series. Combined with the prediction results of the basic learner, the original features can be obtained through majority voting and input into the meta-learner of the second layer as feature information. Finally, according to the prediction results of different weak models in the meta-learner, the input features and output results of the second layer are used as the final features to train the model with the best performance. The data set is randomly divided into training set and test set according to a specific ratio, and the average value of the prediction results in the evaluation index is output.
10. A river section water quality prediction device based on a combined machine learning model, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.
Citation Information
Cited By
Rural digital governance control method and system based on cloud platform sharing
CN119579029A
Water supply regulation management system and method based on water quality dynamic monitoring and machine learning
CN120297800A
Fish diversity monitoring method and system based on visual identification
CN121305611A
Water pollution monitoring method and device, electronic equipment and storage medium
CN121524681A
Surface water monitoring data complementation and credibility evaluation method based on machine learning
CN121614730A
