An interpretable water quality prediction method based on semi-embedded feature selection

Through semi-embedded feature selection and SHAP interpretation framework, it solves the problem that existing water quality prediction methods cannot explain the influence of watershed characteristics, improves the interpretability of water quality prediction models, identifies the core driving factors and mechanisms of river water quality, and achieves efficient Water quality simulation and pollution factor analysis.

CN115728463BActive Publication Date: 2024-10-11HARBIN INST OF TECH
View PDF 23 Cites 0 Cited by

Patent Information

Application Number
CN202211533758.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-01
Publication Date
2024-10-11
Estimated Expiration
2042-12-01

AI Technical Summary

Technical Problem

Existing water quality prediction methods cannot quantitatively and accurately explain the impact of each basin's characteristics on river water quality changes, and machine learning models have poor interpretability and cannot identify core water quality driving factors and their mechanisms.

Method used

An interpretable water quality prediction method based on semi-embedded feature selection is adopted. By collecting and cleaning river characteristic data, autocorrelation analysis is performed, the SHAP interpretation framework is used to calculate feature importance, and low-importance features are eliminated to construct optimal machine learning regression. model, and use SHAP values ​​to explain the water quality prediction values ​​and identify the contribution of each feature to water quality.

Benefits of technology

It improves the interpretability of the water quality prediction model, identifies core water quality driving factors and their action mechanisms, and achieves efficient simulation of river water quality and analysis of pollution factors. It is suitable for water quality simulation and pollution factor analysis in any scale basin.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115728463B_ABST
    Figure CN115728463B_ABST
Patent Text Reader

Abstract

An interpretable water quality prediction method based on semi-embedded feature selection belongs to the field of environmental engineering technology. The present invention solves the problem that existing water quality prediction methods cannot quantitatively and accurately explain the impact of various basin characteristics on river water quality changes. The present invention selects a corresponding interpreter based on a machine learning regression algorithm, interprets the model based on the SHAP value output by the SHAP package, compares the contribution of each basin characteristic to river water quality, identifies core water quality driving factors, and analyzes the mechanism of action of each core driving factor on river water quality. The present invention is applicable to river water quality prediction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of environmental engineering and relates to environmental system simulation prediction technology. Background Art

[0002] With the continuous development of human society, a large number of pollutants have entered rivers, causing increasingly serious water pollution problems in river basins. Today, it is advocated to accelerate water pollution prevention and control and implement comprehensive river basin environmental management. However, the natural and cultural characteristics of the river basin are complex and changeable, and there are many factors affecting river water quality and the interactions are intricate. Conventional means are difficult to accurately simulate changes in river water quality, and it is impossible to quantitatively evaluate the impact of various environmental factors on river water quality. Constructing an accurate, efficient, and interpretable river water quality prediction model to predict the concentration trend of pollutants after diffusion, migration, and transformation, and analyzing the contribution and mechanism of various river basin characteristics to river water quality changes are of great guiding significance for responding to water environment crises, achieving accurate prevention and control of river basin pollution, and scientific decision-making.

[0003] The diversity of water quality influencing factors, the complexity of influencing mechanisms and the spatial heterogeneity of watershed characteristics are the key factors limiting the application of river water quality models. At present, there are three main types of river water quality prediction models: conceptual models, mechanism models and machine learning models. Conceptual models mainly involve runoff theory, water quality diffusion and transformation theory and related mathematical theories. They have simple structures and are easy to build, but they have single theories and backward functions. Mechanism models are composed of a series of continuous equations and dynamic equations, which can dynamically simulate the generation, migration and transformation of pollutants in water bodies. They have high simulation accuracy, but parameter calibration is difficult. In large basin applications, they cannot solve the problem of spatial heterogeneity and are limited in application scale. Machine learning models are based on probability and statistics methods. They do not need to consider the complex migration and transformation process of pollutants in water bodies. They use computer thinking to solve environmental problems. They are suitable for water quality prediction at large basin scales, large sample sizes and long time scales, and have high nonlinear data processing capabilities. However, due to the inherent black box properties of machine learning algorithms, water quality prediction models based on machine learning all have the problem of poor interpretability. Currently, in related studies at home and abroad that use machine learning models to predict river water quality, only the simulation prediction function of water quality changes can be achieved, but it is impossible to quantitatively and accurately explain the contribution and mechanism of each basin characteristic to river water quality changes. Summary of the invention

[0004] The purpose of the present invention is to solve the problem that the existing water quality prediction methods cannot quantitatively and accurately explain the impact of various river basin characteristics on river water quality changes, and to provide an interpretable water quality prediction method based on semi-embedded feature selection.

[0005] The present invention provides an explainable water quality prediction method based on semi-embedded feature selection, the method specifically comprising:

[0006] Step 1: Collect the river channel distribution map of the target river, determine the watershed covered by the river, obtain the DEM map of the watershed, extract the river network of the watershed according to the DEM (Digital Elevation Model, DEM, digital elevation model data) map, and divide the watershed catchment area;

[0007] Step 2: According to the influencing factors of the target river water quality, a target river water quality prediction feature system is constructed to obtain the characteristics that affect the target river water quality, collect the historical data of the target river characteristics and the corresponding water quality data in the basin catchment area, clean the characteristic data and the corresponding water quality data, and generate a preliminary input data set for the machine learning model;

[0008] Step 3: Perform autocorrelation analysis on the historical data of every two features in the preliminary input data set in turn to obtain a strong autocorrelation feature pair; the Spearman correlation coefficient of the strong autocorrelation feature pair is greater than 0.8;

[0009] Step 4: Establish a pre-machine learning model, and use the SHAP (SHapley Additive exPlanations, SHAP) interpretation framework based on the model to calculate the global feature importance values ​​of all features in the preliminary input data set, delete the feature values ​​with low global feature importance values ​​in the strongly autocorrelated feature pairs, complete feature selection, and obtain the final input data set of the machine learning model;

[0010] Step 5: Divide the input data set into a training set and a test set, and use the training set to determine the coefficient r 2 , mean square error MSE, mean absolute error MAE, and mean absolute percentage error MAPE are used as model evaluation indicators to optimize the parameters of the machine learning regression model and obtain the optimal parameter combination;

[0011] Step 6: Use the optimal parameter combination as the machine learning regression model parameters, use the training set and the test set to train and verify the machine learning regression model respectively, and obtain the optimal machine learning regression model;

[0012] Step 7: Use the optimal machine learning regression model described in step 6 to predict the water quality of the target river using the characteristic data of the current target river water quality.

[0013] Furthermore, in the present invention, after step seven, the step also includes: based on the SHAP interpretation framework of the optimal machine learning regression model, the water quality prediction value is disassembled to obtain the SHAP value that characterizes the influence of each feature on the water quality prediction value.

[0014] Furthermore, in the present invention, in step 1, the specific method of dividing the watershed catchment area is:

[0015] Collect DEM (Digital Elevation Model) data within the target watershed, perform spatial interpolation on the collected DEM data, and obtain the DEM map of the watershed. Use ArcGIS (English full spelling Chinese name) hydrological analysis tools to extract the river network of the watershed based on the DEM map of the watershed and divide the watershed catchment area.

[0016] Furthermore, in the present invention, in step 2, the historical data of the characteristics of the target river within n years and the corresponding water quality data are collected as follows:

[0017] Based on the water quality data provided by the statistical yearbook environmental bulletin and the public data platform of the target river, the watershed characteristic data are collected in the unit of watershed catchment area;

[0018] The collection of watershed characteristic data includes: collection of raster data and collection of point feature data;

[0019] For raster data, the zonal statistics function in ArcGIS spatial analysis tools was used to aggregate the data into each catchment area;

[0020] For point feature data, spatial discretization is first performed on the point feature data, and then the data are summarized into each watershed through zoning statistics.

[0021] Furthermore, in the present invention, in step 2, the specific method for cleaning the watershed characteristic data is:

[0022] Find the erroneous values, missing values, and outliers in the collected watershed characteristic data and process them; uniformly delete the erroneous values, use the contemporaneous mean filling method to fill the missing values ​​in the watershed characteristic data, and based on the quadrant diagram, use the third quartile to replace the high outliers in the watershed characteristic data, and use the first quartile to replace the low outliers in the watershed characteristic data to achieve data cleaning.

[0023] Furthermore, in the present invention, in step 3, the historical data of every two features in the preliminary input data set are sequentially subjected to autocorrelation analysis, and the specific method for obtaining a strong autocorrelation feature pair is:

[0024] Scipy was called in Python software to calculate the Spearman correlation coefficient between each feature in turn, and the feature pairs with Spearman correlation coefficient greater than 0.8 were screened out as strong autocorrelation feature pairs.

[0025] Furthermore, in the present invention, in step 4, the SHAP interpretation framework includes multiple interpreters, applicable to any machine learning model, for interpreting tree-based models and for interpreting deep learning models.

[0026] Furthermore, in the present invention, in step 6, the specific method for decomposing the water quality prediction value of each water quality prediction sample based on the SHAP framework is:

[0027]

[0028] Among them, f(x j ) is the predicted value of the water quality of the jth sample; is the mean value of water quality prediction of machine learning regression model; M is the number of features; is the SHAP value of the i-th feature for the j-th water quality prediction value, The size of represents the contribution of the i-th feature to the j-th sample, and the positive or negative sign represents whether the contribution direction is positive or negative.

[0029] The present invention selects the corresponding interpreter according to the machine learning regression algorithm, interprets the model based on the SHAP value output by the SHAP package, compares the contribution of each basin characteristic to river water quality, identifies the core water quality driving factors, and analyzes the mechanism of action of each core driving factor on river water quality. Compared with a single machine learning prediction model, the present invention greatly improves the interpretability, strengthens the water quality driving factor analysis function of the water quality prediction model, and has more practical guiding significance.

[0030] The present invention constructs a machine learning water quality prediction model through data cleaning, feature selection, hyperparameter tuning, and model verification. It combines the SHAP framework to enhance the interpretability of the machine learning model, realizes efficient simulation of river water quality, analysis of core water quality driving factors, and analysis of driving mechanisms, and is suitable for water quality simulation and pollution factor analysis of river basins of any scale. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 is a flow chart of the method of the present invention;

[0032] Figure 2 It is a principle block diagram of the method of the present invention;

[0033] Figure 3 is the characteristic Spearman autocorrelation heat map;

[0034] Figure 4 is a histogram of the global importance of features;

[0035] Figure 5 It is the measured and fitted data distribution diagram of COD concentration prediction model based on SVM;

[0036] Figure 6 It is the SHAP summary diagram of the COD prediction model. DETAILED DESCRIPTION

[0037] 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.

[0038] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.

[0039] Specific implementation method 1: The following is combined Figure 1 and Figure 2 This embodiment describes an explainable water quality prediction method based on semi-embedded feature selection, which specifically includes:

[0040] Step 1: Collect the river channel distribution map of the target river, determine the watershed covered by the river, obtain the DEM map of the watershed, extract the river network of the watershed according to the DEM (Digital Elevation Model, DEM, digital elevation model data) map, and divide the watershed catchment area;

[0041] Step 2: According to the influencing factors of the target river water quality, a target river water quality prediction feature system is constructed to obtain the characteristics that affect the target river water quality, collect the historical data of the target river characteristics and the corresponding water quality data in the basin catchment area, clean the characteristic data and the corresponding water quality data, and generate a preliminary input data set for the machine learning model;

[0042] Step 3: Perform autocorrelation analysis on the historical data of every two features in the preliminary input data set in turn to obtain a strong autocorrelation feature pair; the Spearman correlation coefficient of the strong autocorrelation feature pair is greater than 0.8;

[0043] For example, there are four features A, B, C, and D, and there are 6 feature pair combinations AB, AC, AD, BC, BD, and CD. The Spearman correlation coefficients between the 6 feature pairs obtained by autocorrelation analysis are 0.9, 0.82, 0.3, 0.5, 0.6, and 0.83, respectively. The feature pairs AB, AC, and CD with Spearman correlation coefficients greater than 0.8 are considered strong autocorrelation feature pairs;

[0044] Step 4: Establish a pre-machine learning model, and use the SHAP (SHapley Additive exPlanations, SHAP) interpretation framework based on the model to calculate the global feature importance values ​​of all features in the preliminary input data set, delete the feature values ​​with low global feature importance values ​​in the strongly autocorrelated feature pairs, complete feature selection, and obtain the final input data set of the machine learning model;

[0045] For example, the global feature importance values ​​of each feature described in step 3 are calculated using the SHAP interpretation framework: A-0.92, B-0.83, C-0.76, D-0.94. For the strongly autocorrelated feature pair AB, because the global feature importance of A is greater than that of B, feature A is retained and feature B is eliminated; similarly, for the strongly autocorrelated feature pair AC, feature A is retained and feature C is eliminated; for the strongly autocorrelated feature pair CD, feature D is retained and feature C is eliminated. At this point, feature selection is completed, and features A and D are retained; if there are features that do not belong to the strongly autocorrelated feature pair, they are retained directly;

[0046] Step 5: Divide the final input data set into a training set and a test set, and use the training set to determine the coefficient r 2 , mean square error MSE, mean absolute error MAE, and mean absolute percentage error MAPE are used as model evaluation indicators to optimize the parameters of the machine learning regression model and obtain the optimal parameter combination;

[0047] Step 6: Use the optimal parameter combination as the machine learning regression model parameters, use the training set and the test set to train and verify the machine learning regression model respectively, and obtain the optimal machine learning regression model;

[0048] Step 7: using the optimal machine learning regression model described in step 6, and using the characteristic data of the current target river water quality to predict the target river water quality;

[0049] Furthermore, in the present invention, after step seven, the step also includes: based on the SHAP interpretation framework of the optimal machine learning regression model, the water quality prediction value is disassembled to obtain the SHAP value that characterizes the influence of each feature on the water quality prediction value.

[0050] Furthermore, in the present invention, in step 1, the specific method of dividing the watershed catchment area is:

[0051] Collect DEM (Digital Elevation Model) data within the target watershed, perform spatial interpolation on the collected DEM data, and obtain the DEM map of the watershed. Use ArcGIS (English full spelling Chinese name) hydrological analysis tools to extract the river network of the watershed based on the DEM map of the watershed and divide the watershed catchment area.

[0052] Furthermore, in the present invention, in step 2, the historical data of the characteristics of the target river within n years and the corresponding water quality data are collected as follows:

[0053] Based on the water quality data provided by the statistical yearbook environmental bulletin and the public data platform of the target river, the watershed characteristic data are collected in the unit of watershed catchment area;

[0054] The collection of watershed characteristic data includes: collection of raster data and collection of point feature data;

[0055] For raster data, the zonal statistics function in ArcGIS spatial analysis tools was used to aggregate the data into each catchment area;

[0056] For point feature data, spatial discretization is first performed on the point feature data, and then the data are summarized into each watershed through zoning statistics.

[0057] Furthermore, in the present invention, in step 2, the specific method for cleaning the watershed characteristic data is:

[0058] Find the erroneous values, missing values, and outliers in the collected watershed characteristic data and process them; uniformly delete the erroneous values, use the contemporaneous mean filling method to fill the missing values ​​in the watershed characteristic data, and based on the quadrant diagram, use the third quartile to replace the high outliers in the watershed characteristic data, and use the first quartile to replace the low outliers in the watershed characteristic data to achieve data cleaning.

[0059] Furthermore, in the present invention, in step 3, the historical data of every two features in the preliminary input data set are sequentially subjected to autocorrelation analysis, and the specific method for obtaining a strong autocorrelation feature pair is:

[0060] Scipy was called in Python software to calculate the Spearman correlation coefficient between each feature in turn, and the feature pairs with Spearman correlation coefficient greater than 0.8 were screened out as strong autocorrelation feature pairs.

[0061] Furthermore, in the present invention, in step 4, the SHAP interpretation framework includes multiple interpreters, applicable to any machine learning model, for interpreting tree-based models and for interpreting deep learning models.

[0062] Furthermore, in the present invention, in step 6, the specific method for decomposing the water quality prediction value of each water quality prediction sample based on the SHAP framework is:

[0063]

[0064] Among them, f(x j ) is the predicted value of the water quality of the jth sample; is the mean value of water quality prediction of machine learning regression model; M is the number of features; is the SHAP value of the i-th feature for the j-th water quality prediction value, The size of represents the contribution of the i-th feature to the j-th sample, and the positive or negative sign represents whether the contribution direction is positive or negative.

[0065] The present invention firstly adopts semi-embedded feature selection and utilizes an explanation framework at the same time. The former can improve the model accuracy, and the latter can enhance the model interpretability. Both can improve the model performance.

[0066] The method described in the present invention is a method for constructing a water quality prediction model that is fast, accurate, interpretable, and widely applicable. The feature selection method based on Shapley value realizes efficient and automatic simplification of the water quality prediction index system, greatly improving the model operation speed and accuracy; the machine learning regression algorithm is used to construct a river water quality prediction model, which solves the problem of spatial heterogeneity of basin characteristics in large-scale basin water quality prediction and expands the application scale of the water quality prediction model; the interpretability enhancement method breaks through the problem of poor interpretability of the machine learning regression algorithm in river water quality prediction applications, and is applicable to any machine learning regression model. The present invention helps to accurately determine the key control factors of river water quality, and is of great significance to precise pollution control and scientific decision-making in basins. Specific embodiment:

[0068] Combination Figures 2 to 6 , taking the construction of the river COD concentration prediction model in the eastern source basin of Minjiang River in Sichuan Province as an example, the specific implementation process is as follows:

[0069] (1) Determine the scope of the watershed and divide the catchment area;

[0070] The Minjiang River is a first-level tributary of the Yangtze River, with a total length of 658.8 km. It is a key tributary in the Yangtze River protection campaign. The case study takes the Minjiang River East Source as an example. The basin area of ​​the Minjiang River East Source is 51,600 km 2 , located in the middle and eastern part of Sichuan. The 250m DEM data of Sichuan Province was collected on the Resource and Environmental Science and Data Platform of the Chinese Academy of Sciences. The hydrological analysis tools of ArcGIS were used to extract the river network of the basin based on the basin DEM map and divide the basin catchment area.

[0071] (2) Collect and clean watershed characteristic data and construct input data sets;

[0072] Considering various natural and human factors that affect the COD concentration of rivers, basin characteristics are selected from the aspects of climate and meteorology, soil and geomorphology, land use, landscape pattern, social economy, hydrology and water quality to construct a water quality prediction index system; data are collected from sources such as the "Sichuan Statistical Yearbook" and the "Sichuan Environmental Statistical Bulletin" in units of watershed areas, and the zoning statistics function of ArcGIS is used to summarize the raster data into each watershed area. After spatial discretization of point feature data, the data are summarized into each watershed area through zoning statistics; erroneous values ​​are deleted, and missing values ​​are filled with the mean of basin characteristics or water quality data of the same period; outliers are corrected based on box plots, and high outliers and low outliers are replaced by the third quartile and the first quartile respectively. The cleaned data are sorted according to the input data format requirements of the machine learning regression model to generate an input data set.

[0073] (3) Feature selection based on Shapley value;

[0074] Call the corr('spearman') function in Python to calculate the Spearman correlation coefficient between two features. Figure 3 As shown, identify features with high autocorrelation and screen out feature pairs with Spearman correlation coefficients greater than 0.8. In this case, based on the measured data of COD concentration in the basin, the support vector machine (SVM) algorithm was selected to build a river water quality prediction model. SVM is a classic machine learning algorithm that can achieve good prediction results when the number of features is greater than the number of samples. Call the SVR regression in the sklearn.svm module in Python to directly build a regression model under the default parameters. Call the SHAP model interpretation package in Python, use kernel explainer as the interpreter, calculate the shapley value of each feature, and generate a global feature importance ranking of each feature, as shown in Figure 3 As shown in . Compare the global feature importance of the two features in the feature pairs with a Spearman correlation coefficient greater than 0.8, and retain the higher feature. Figure 3 It can be seen that the correlation coefficient between precipitation and river flow is 0.82, which is a mutually autocorrelated characteristic pair. Figure 4 It can be seen that the global importance of precipitation (0.6) is higher than that of river flow (0.26), so precipitation is retained and river flow is deleted. All features with Spearman correlation coefficients greater than 0.8 are compared and screened to complete feature selection.

[0075] It can be seen that the correlation coefficient between precipitation and river flow is 0.82, which are mutually autocorrelated feature pairs. From the feature global importance histogram, Figure 4It can be seen that the global importance of precipitation (0.6) is higher than that of river flow (0.26), so precipitation is retained and river flow indicators are deleted. All features with Spearman correlation coefficients greater than 0.8 are compared and screened to complete feature selection.

[0076] (4) Training, tuning and verification of machine learning regression models;

[0077] The train_test_split function in sklearn is called to divide the input data into training set and test set in a ratio of 3:1. The training set data is used as input, and the GridSearchCV() function of sklearn in Python is used to perform grid traversal optimization on the hyperparameters of the SVM regression model. The parameters to be optimized are the core parameters of the SVM regression model, kernel function, kernel function coefficient (gamma), regularization coefficient (C) and polynomial kernel function dimension (degree). The model parameters with the best performance are determined through optimization. The specific parameter optimization range and optimization results are shown in Table 1:

[0078] Table 1 SVM parameter adjustment range and optimal parameter values

[0079]

[0080] The SVM regression model was trained with the optimal parameter combination, and the model was evaluated on the training set and the validation set. The evaluation indicators included the determination coefficient r 2 , mean square error MSE, mean absolute error MAE, mean absolute percentage error MAPE. The evaluation indicators of the SVM regression model are shown in Table 2. It can be seen from the table that SVM has a high accuracy in predicting COD concentration. The training set r 2 As high as 0.982, the test set r2 also reached 0.78.

[0081] Table 2 Evaluation of COD concentration prediction model based on SVM

[0082]

[0083] Substitute the prediction data into the SVM water quality prediction model constructed by the optimal parameter combination in step (4) to predict the COD concentration. The distribution of the simulated data and measured data of COD concentration by the model is as follows: Figure 5 As shown, it can be seen that the model simulation values ​​are basically distributed near the measured values, and the COD prediction model based on SVM has a stable simulation effect on the COD concentration of the river.

[0084] 6) Explain the water quality model based on the SHAP framework;

[0085] Call the SHAP model interpretation package in Python, select kernelexplainer as the interpreter, interpret the SVM model with the optimal parameter combination constructed in step (4), calculate the Shapley value of each feature, and generate the SHAP summary diagram of the COD prediction model as shown in Figure 6 As shown. As can be seen from the figure, the three basin characteristics that have the greatest impact on the COD concentration of rivers within the basin are the number of permanent urban residents, GDP and TDE (ratio of urban and rural construction land). The three core water quality driving factors are positively correlated with the COD concentration; the month and the amount of investment in the treatment of old industrial pollution sources are negatively correlated with the COD concentration of the river. It can be seen that the pollution generated by urban production and life is the main reason for the increase in COD concentration in the study area. The stronger the urbanization and the faster the economic development, the worse the water quality. The COD concentration will decrease in winter, and the investment in industrial pollution control has effectively limited the increase in COD concentration. The above conclusions encourage urban managers to start with domestic sewage treatment, strengthen sewage treatment efficiency, and reflect seasonal differences in COD control.

[0086] The present invention proposes a feature selection method based on Shapley value, uses the Spearman autocorrelation coefficient to identify strong autocorrelation feature pairs, and generates the global feature importance of each feature as the basis for retaining strong autocorrelation features based on the Shapley value of each feature, thereby solving the problem of reduced model running speed and accuracy caused by multicollinearity of redundant features in watershed modeling. Compared with the currently widely used feature selection method of autocorrelation analysis plus subjective screening, this method considers the global contribution of watershed characteristics to the water quality prediction model based on Shapley value, and has a more scientific basis for retaining and selecting strong autocorrelation features; feature comparison and selection eliminates the process of human subjective judgment, and has a higher degree of automation; after feature selection, irrelevant features and redundant features are eliminated, the feature dimension is controlled, the training time is reduced, and the generalization ability of the model and the understanding of features are enhanced.

[0087] The present invention also proposes a method for enhancing the interpretability of river water quality prediction models. In order to address the problem of poor interpretability of black box models, the SHAP framework is used to identify core water quality driving factors and analyze their contribution to water quality and their mechanism of action. A single machine learning model can only output the strength of the correlation between features and prediction indicators through correlation analysis between features and prediction indicators. It cannot explain the quantitative response relationship between features and prediction indicators, nor can it determine the strength of the contribution of features to prediction indicators, which is not conducive to the guidance of water quality prediction models on practical work. Compared with the qualitative post-hoc attribution analysis based on correlation analysis of a single machine learning model, this method can quantitatively describe the overall contribution and direction of watershed characteristics to water quality, explain how the model makes predictions based on the entire feature space and model structure and parameters, identify the core driving factors of water quality, and greatly improve interpretability;

[0088] Although the present invention is described herein with reference to specific embodiments, it should be understood that these embodiments are merely examples of the principles and applications of the present invention. It should therefore be understood that many modifications may be made to the exemplary embodiments and that other arrangements may be devised without departing from the spirit and scope of the present invention as defined by the appended claims. It should be understood that the various dependent claims and features described herein may be combined in a manner different from that described in the original claims. It should also be understood that features described in conjunction with individual embodiments may be used in other described embodiments.

Claims

1. An interpretable water quality prediction method based on semi-embedded feature selection, characterized in that: The method specifically includes: Step 1: Collect the river channel distribution map of the target river, determine the watershed covered by the river, obtain the DEM map of the watershed, extract the river network of the watershed according to the DEM map, and divide the watershed catchment area; Step 2: According to the influencing factors of the target river water quality, a target river water quality prediction feature system is constructed to obtain the characteristics that affect the target river water quality, collect the historical data of the target river characteristics and the corresponding water quality data in the basin catchment area, clean the historical data of the characteristics and the corresponding water quality data, and generate a preliminary input data set for the machine learning model; Step 3: Perform autocorrelation analysis on the historical data of every two features in the preliminary input data set in turn to obtain a strong autocorrelation feature pair; the Spearman correlation coefficient of the strong autocorrelation feature pair is greater than 0.8; Step 4: Establish a pre-machine learning model, and use the SHAP interpretation framework based on the model to calculate the global feature importance values ​​of all features in the preliminary input data set, delete the features with low global feature importance values ​​in the strong autocorrelation feature pairs, complete feature selection, and obtain the final input data set of the machine learning model; Step 5: Divide the final input data set into a training set and a test set, and use the training set to determine the coefficient r 2 , mean square error MSE, mean absolute error MAE, and mean absolute percentage error MAPE are used as model evaluation indicators to optimize the parameters of the machine learning regression model and obtain the optimal parameter combination; Step 6: Use the optimal parameter combination as the machine learning regression model parameters, use the training set and the test set to train and verify the machine learning regression model respectively, and obtain the optimal machine learning regression model; Step 7: Use the optimal machine learning regression model described in step 6 to predict the water quality of the target river using the characteristic data of the current target river water quality. Step seven also includes: based on the SHAP interpretation framework of the optimal machine learning regression model, the water quality prediction value is disassembled to obtain the SHAP value that characterizes the influence of each feature on the water quality prediction value.

2. The explainable water quality prediction method based on semi-embedded feature selection according to claim 1 is characterized in that: In step 1, the specific method for dividing the watershed is: Collect DEM data within the target watershed, perform spatial interpolation on the collected DEM data to obtain the DEM map of the watershed; use ArcGIS hydrological analysis tools to extract the river network of the watershed based on the DEM map of the watershed and divide the watershed catchment area.

3. The explainable water quality prediction method based on semi-embedded feature selection according to claim 1 is characterized in that: In step 2, the specific method for cleaning the watershed characteristic data is: Find the erroneous values, missing values, and outliers in the collected watershed characteristic data and process them; uniformly delete the erroneous values, use the contemporaneous mean filling method to fill the missing values ​​in the watershed characteristic data, and based on the quadrant diagram, use the third quartile to replace the high outliers in the watershed characteristic data, and use the first quartile to replace the low outliers in the watershed characteristic data to achieve data cleaning.

4. The explainable water quality prediction method based on semi-embedded feature selection according to claim 1 is characterized in that: In step 3, the historical data of every two features in the preliminary input data set are analyzed for autocorrelation in turn. The specific method for obtaining strong autocorrelation feature pairs is as follows: Scipy was called in Python software to calculate the Spearman correlation coefficients between the features in the preliminary input data set in turn, and feature pairs with Spearman correlation coefficients greater than 0.8 were screened out as strong autocorrelation feature pairs.

5. The explainable water quality prediction method based on semi-embedded feature selection according to claim 1 is characterized in that: In step 4, the SHAP explanation framework includes multiple explainers, applicable to any machine learning model, for explaining tree-based models, and for explaining deep learning models.

6. The explainable water quality prediction method based on semi-embedded feature selection according to claim 1 is characterized in that: Based on the SHAP interpretation framework of the optimal machine learning regression model, the water quality prediction value is disassembled, and the specific method to obtain the SHAP value that characterizes the influence of each feature on the water quality prediction value is as follows: Among them, f(x j ) is the predicted value of the water quality of the jth sample; is the mean value of water quality prediction of machine learning regression model; M is the number of features; is the SHAP value of the i-th feature for the j-th water quality prediction value.

7. The explainable water quality prediction method based on semi-embedded feature selection according to claim 6 is characterized in that: SHAP value of water quality prediction The size of represents the contribution of the i-th feature to the j-th sample, and the positive or negative sign represents whether the contribution direction is positive or negative.

Citation Information

Patent Citations

  • Method and device for building river diatom bloom warning model

    AU2020103356A4

  • Water quality monitoring method and water quality monitoring device based on adaptive model

    CN106525762A

  • A river water quality prediction and an evaluation method of water quality influencing factors

    CN109242203A

  • The invention discloses a mMethod and device for predicting section water quality parameter data

    CN109614570A

  • Lake water quality prediction method and system

    CN110070144A