A method and device for optimizing coagulation dosage based on SHAP interpretation
By adopting a coagulation dosage optimization method based on SHAP explanation during the water treatment process, using the spatial and temporal water quality characteristics and a multi-objective optimization framework, the problems of low dosage prediction accuracy and poor model interpretability are solved, and efficient water quality purification and drug use optimization are achieved.
Patent Information
- Application Number
- CN202411477414.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-10-22
AI Technical Summary
The prior art has low accuracy in dosage prediction, poor model interpretability and lack of limitations of multi-objective optimization during water treatment.
The coagulation dosage optimization method based on SHAP explanation is adopted. By obtaining the water quality index data of different monitoring points of the water plant, a graph structure sequence is constructed and the spatial and temporal water quality characteristics are extracted. The dosage dosage prediction is combined with the logistic regression prediction module and SHAP, and the purification effect and agent usage are balanced through a multi-objective optimization framework.
The accuracy of coagulation dosage prediction is improved, the interpretability of the model is enhanced, and the balance optimization between the water quality purification effect and the amount of medicine is achieved, reducing the cost of medicine use and the risk of secondary pollution.
Smart Images

Figure CN119007876B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of water treatment, and in particular relates to a method and a device for optimizing coagulation dosage based on SHAP interpretation. Background Art
[0002] In the water treatment process, accurate control of coagulant dosage is crucial to ensure water quality and optimize economic benefits. Traditional dosage control methods, such as proportional integral differential control (PID control) and fuzzy control, rely on fixed rules and empirical judgments, and are difficult to adapt to real-time changes in water quality. Especially in the face of complex and dynamically changing water quality environments, the control accuracy is limited, resulting in unstable coagulation effects.
[0003] With the development of data-driven technology, machine learning models are gradually being applied to the field of water treatment technology. By modeling historical water quality data, researchers have developed models based on artificial intelligence (AI) to predict the appropriate amount of coagulant to be added. For example, using technologies such as artificial neural networks (ANN) and adaptive fuzzy inference systems (ANFIS), the models in these technologies can handle nonlinear and complex water quality changes. For example, studies have shown that ANN models can effectively predict dosage and achieve good results under various water quality conditions.
[0004] However, although these machine learning models perform well in dealing with nonlinear problems, they are still limited in capturing the spatial dependencies and temporal dynamic changes between water quality monitoring points. For water quality monitoring under a multi-monitoring point network structure, machine learning models often find it difficult to accurately capture the mutual influence between monitoring points, affecting the accuracy of dosing prediction. In addition, traditional machine learning models also have black box problems, making it difficult to explain the decision-making process of the model, reducing its transparency and trust in application.
[0005] In order to overcome these challenges, graph convolutional network (GCN) and temporal convolutional network (TCN) technologies have been gradually applied to the field of water treatment. GCN can model the spatial relationship between monitoring points through graph structure, while TCN can capture the temporal dynamic changes of water quality, thereby effectively extracting spatiotemporal water quality characteristics. However, there are currently few studies on dosage optimization based on GCN and TCN technologies, and more effective strategies still need to be developed to achieve automated dosing optimization.
[0006] At the same time, the optimization of dosage in the water treatment process is not only a prediction problem, but also involves balancing the purification effect and the amount of reagents used. Traditional single-objective optimization methods usually only focus on the purification effect, ignoring the cost of reagents and potential secondary pollution problems. Existing research suggests that through a multi-objective optimization framework, while ensuring that water quality meets standards, the use of chemical reagents can be reduced, balancing economic benefits and environmental impacts. Summary of the invention
[0007] In view of the above, the purpose of the present invention is to provide a coagulation dosage optimization method and device based on SHAP interpretation to solve the limitations of the prior art in water treatment processes, such as low dosage prediction accuracy, poor model interpretability and lack of multi-objective optimization.
[0008] To achieve the above-mentioned purpose of the invention, an embodiment provides a method for optimizing coagulation dosage based on SHAP interpretation, comprising the following steps:
[0009] Obtain water quality index data from different monitoring points in the water plant and construct a graph structure sequence of all monitoring points after preprocessing;
[0010] Construct a coagulation dosage prediction model, which includes a spatiotemporal water quality feature extraction module, a logistic regression prediction module, and SHAP, wherein the spatiotemporal water quality feature extraction module is used to extract the spatiotemporal water quality features of the graph structure sequence from the graph structure sequence, the logistic regression prediction module is used to predict the coagulation dosage based on the spatiotemporal water quality features, and SHAP is used to explain the contribution of the spatiotemporal water quality features to the prediction of the coagulation dosage;
[0011] Based on the water quality index data, a dosage objective function and a purification effect objective function are constructed, and a two-objective optimization problem is constructed based on these two objective functions. The two-objective optimization problem is solved to obtain the minimum coagulation dosage to achieve a given purification degree. The loss function is constructed by the difference between the coagulation dosage predicted by the model and the solved minimum coagulation dosage. The loss function is used to optimize the parameters of the coagulation dosage prediction model.
[0012] The parameter-optimized coagulation dosage prediction model is used to predict the real-time dosage, and the monitoring points that contribute to the predicted dosage in the spatiotemporal water quality characteristics are explained by SHAP. The monitoring points are used to guide the actual coagulation dosage.
[0013] Preferably, the water quality index data of different monitoring points are preprocessed, including: outlier removal and missing value supplementation of water quality index data, smoothing of water quality index data, and standardization of different water quality index data.
[0014] Preferably, a graph structure sequence of all monitoring points is constructed, including:
[0015] Each detection point is taken as a node, and the water value index data of the monitoring point is used as the node attribute to construct the node feature, edges are constructed between the nodes, and edge weights are assigned to the edges to construct the adjacency matrix. The edge weights are determined as follows: high edge weights are assigned if the distance between the monitoring points is short, high edge weights are assigned if the monitoring points are connected by pipes, and high edge weights are assigned if the water flow speed is fast.
[0016] Preferably, the spatiotemporal water quality feature extraction module includes an ST-GCN composed of multiple spatiotemporal convolution blocks, each of which is used to extract spatiotemporal water quality features, specifically including a spatial convolution layer for extracting spatial features of detection points and a gate sequence convolution layer for extracting time point features based on the spatial features of monitoring points. At the same time, a spatial attention mechanism is introduced in the spatial convolution layer of each spatiotemporal convolution block to focus on the spatial features of monitoring points, and a temporal attention mechanism is introduced in each gate sequence convolution layer to focus on the time point features.
[0017] Preferably, the logistic regression prediction module adopts the XGBoost model, and uses the XGBoost model to perform logistic regression to predict the coagulation dosage based on the extracted spatiotemporal water quality characteristics.
[0018] Preferably, the dosage objective function It is expressed as: ,in, represents the dosage objective function, represents the coagulation dosage at time t;
[0019] Purification effect objective function It is expressed as: ,in, N Indicates the number of water quality indicators involved in optimization, It indicates the target value of the i-th water quality index to reach the qualified water quality standard, Represents the coagulation dosage based on time t The calculated i The actual value of the water quality index, Indicates the weight of each water quality index, reflecting the relative importance of different water quality indexes to the purification effect;
[0020] Based on the two objective functions, a two-objective optimization problem is constructed, which is expressed as: , and Respectively represent the weights of dosage and purification effect. When solving the two-objective optimization problem, we look for the optimal solution that can minimize the dosage. , and can ensure the water purification effect The optimal solution of the minimized dosage is the minimum coagulation dosage to achieve a given purification effect.
[0021] Preferably, the Pareto frontier method is used to solve the two-objective optimization problem to obtain the minimum coagulation dosage to achieve a given purification degree.
[0022] To achieve the above-mentioned purpose of the invention, the embodiment of the present invention further provides a coagulation dosage optimization device based on SHAP interpretation, comprising:
[0023] A data processing unit, which is used to obtain water quality index data of different monitoring points in the water plant and construct a graph structure sequence of all monitoring points after preprocessing;
[0024] A model building unit, which is used to build a coagulation dosage prediction model, which includes a spatiotemporal water quality feature extraction module, a logistic regression prediction module, and SHAP, wherein the spatiotemporal water quality feature extraction module is used to extract the spatiotemporal water quality features of the graph structure sequence from the graph structure sequence, the logistic regression prediction module is used to predict the coagulation dosage based on the spatiotemporal water quality features, and SHAP is used to explain the contribution of the spatiotemporal water quality features to the predicted dosage;
[0025] A loss function construction and optimization unit, which is used to construct a dosage objective function and a purification effect objective function based on water quality index data, and to construct a two-objective optimization problem based on these two objective functions, and to solve the two-objective optimization problem to obtain the minimum coagulation dosage for a given purification degree, and to construct a loss function based on the difference between the coagulation dosage predicted by the model and the minimum coagulation dosage solved, and to use the loss function to optimize the parameters of the coagulation dosage prediction model;
[0026] The real-time prediction unit is used to make real-time dosage prediction using the parameter-optimized coagulation dosage prediction model, and to interpret the monitoring points that contribute to the predicted dosage in the spatiotemporal water quality characteristics through SHAP. The monitoring points are used to guide the actual coagulation dosage.
[0027] To achieve the above-mentioned purpose of the invention, an embodiment also provides a computing device, including a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement the above-mentioned coagulation dosage optimization method based on SHAP interpretation.
[0028] Compared with the prior art, the present invention has the following beneficial effects:
[0029] The present invention extracts spatiotemporal water quality characteristics based on the spatial and temporal relationships of water quality index data at different detection points in a water plant, and takes into account the correlation between coagulation dosage and water purification effect when constructing a loss function. A two-objective optimization problem is used to calculate the minimum coagulation dosage for achieving water purification effect and use it as a supervisory label. A loss function is constructed based on the supervisory label to optimize the coagulation dosage prediction model parameters, so that the model takes into account the water purification effect during learning and gives the optimal coagulation dosage prediction. In this way, accurate prediction of the minimized coagulation dosage considering the water purification effect can be achieved, and SHAP is introduced to explain the contribution of spatiotemporal water quality characteristics to the predicted coagulation dosage, and guide the actual coagulation dosage placement. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] 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, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0031] Figure 1 is a flow chart of a coagulation dosage optimization method based on SHAP interpretation provided in an embodiment;
[0032] Figure 2 It is a structural schematic diagram of a coagulation dosage prediction model provided in an embodiment;
[0033] Figure 3 It is a structural schematic diagram of a coagulation dosage optimization device based on SHAP interpretation provided in an embodiment. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific implementation methods described herein are only used to explain the present invention and do not limit the protection scope of the present invention.
[0035] The inventive concept of the present invention is to address the technical problems of low dosage prediction accuracy, poor model interpretability and lack of multi-objective optimization considerations in the prior art during water treatment. The embodiment of the present invention provides a coagulation dosage optimization scheme based on SHAP interpretation, which not only improves the accuracy of coagulation dosage prediction, but also has good model interpretability, and achieves low-cost balance optimization between water purification effect and minimum agent usage, thereby improving the automated guidance of coagulation dosage in the water treatment process.
[0036] Based on the above inventive concept, an embodiment provides a method for optimizing coagulation dosage based on SHAP interpretation, comprising the following steps:
[0037] S1, obtains water quality index data of different monitoring points in the water plant and constructs a graph structure sequence of all monitoring points after preprocessing.
[0038] In water treatment applications, the monitored water quality index data such as turbidity, pH value, dissolved oxygen, temperature, etc. are highly heterogeneous, time-varying and irregular. Therefore, the preprocessing of water quality index data is a key link affecting the performance of the model. The original water quality index data needs to be comprehensively and strictly preprocessed to ensure the stability and consistency of the input data. The specific preprocessing includes:
[0039] The water quality index data is cleaned to remove outliers and supplement missing values. There are usually noise and missing values in water quality index data. To this end, the present invention adopts a dual data cleaning strategy. First, the obvious sensor failure data (such as data points with extremely large abnormal deviations or continuity loss) is initially filtered, and then unreasonable abnormal data is further eliminated through rules based on spatiotemporal association to ensure the high quality of model input data.
[0040] Specifically, in terms of outlier removal, the IQR (Interquartile Range) method is combined with the cluster-based LOF (Local Outlier Factor) algorithm to identify extreme outliers in water quality index data. These outliers may be caused by emergencies or equipment failures. If they are used directly for model training without being processed, the performance of the prediction model will be significantly reduced.
[0041] In terms of missing value supplementation, multivariate interpolation is used to interpolate and fill in the missing values in combination with the spatiotemporal correlation of the data from surrounding monitoring points. In addition, when there is a nonlinear relationship between water quality indicator data, machine learning-based interpolation methods, such as the random forest interpolation model, can also be introduced to ensure the continuity and integrity of the data.
[0042] The water quality index data is smoothed. In order to eliminate the interference of high-frequency noise on the model, the exponential weighted moving average (EWMA) sliding window is introduced. This method can effectively smooth short-term fluctuations and retain long-term trend signals, thereby improving the robustness of the model.
[0043] Standardize the water quality index data. In order to eliminate the dimensional differences between different water quality index data, the Z-score standardization method is used to standardize the water temperature, turbidity, pH value and other water quality index data to a range of mean 0 and variance 1, ensuring that different features have the same scale during model training and avoiding unreasonable weight effects of certain features on the model.
[0044] Through the above preprocessing process, the high consistency and quality of water quality index data are ensured, thus providing a reliable data basis for the subsequent training and prediction of the coagulation dosage prediction model.
[0045] In the embodiment, during the coagulation process of the water plant, there are complex spatial relationships between multiple water quality monitoring points (such as water inlets, sedimentation tanks, drains, etc.). These monitoring points are not only affected by distance, but also related to factors such as water flow paths and pipeline connections. The spatial relationship of these monitoring points can be modeled through a graph structure. Specifically, each monitoring point is used as a node in the graph structure, and the water value index data of the monitoring point is used as a node attribute to construct a node feature X, and edges representing the connection relationship or physical distance of the water flow are constructed between the nodes, and edge weights are assigned to the edges to construct an adjacency matrix A, which characterizes the correlation of spatial nodes. The edge weights are assigned according to the strength of pipeline connection, geographical distance or water flow velocity, and the specific determination method is: if the distance between the monitoring points is short, a high edge weight is assigned, if the monitoring points are connected by pipelines, a high edge weight is assigned, and if the water flow velocity is fast, a high edge weight is assigned.
[0046] The change of water quality index data is not only determined by the spatial structure, but also significantly affected by the temporal dynamics. Therefore, adding time dimension modeling to construct a graph structure sequence, extracting spatiotemporal water quality characteristics based on the graph structure sequence and predicting the dosage can improve the accuracy of dosage prediction. t The graph structure is represented as (X t ,A t ), the graph structures at multiple moments form a graph structure sequence represented as {(X1,A1), (X2,A2),…,( X t ,A t ),…,( X T ,A T )}, and the graph structure sequence is input into the model.
[0047] S2, construct a coagulant dosage prediction model, which includes a spatiotemporal water quality feature extraction module, a logistic regression prediction module, and SHAP, wherein the spatiotemporal water quality feature extraction module is used to extract the spatiotemporal water quality characteristics of the graph structure sequence from the graph structure sequence, the logistic regression prediction module is used to predict the coagulant dosage based on the spatiotemporal water quality characteristics, and SHAP is used to explain the contribution of the spatiotemporal water quality characteristics to the prediction of the coagulant dosage.
[0048] In the embodiment, Figure 2 As shown, the constructed coagulation dosage prediction model includes a spatiotemporal water quality feature extraction module and a logistic regression prediction module, which are used to extract the spatiotemporal water quality features of the graph structure sequence from the graph structure sequence and predict the coagulation dosage based on the spatiotemporal water quality features.
[0049] Taking into account the lag effect between water quality index data and dosage, the present invention introduces the historical data of key water quality indicators (such as turbidity and pH value) with delay by constructing time lag features. The selection of specific lag windows is based on dynamic analysis, and multiple time lag windows such as 1 hour, 3 hours, 6 hours and 12 hours are usually used for modeling to fully capture the dynamic characteristics of water quality changes and their impact on dosage. When the graph structure sequence is input into the model, in order to reflect the latest changes in water quality indicators in real time, a sliding window mechanism can be introduced in time. That is, the model only uses the monitoring data of the most recent period (such as data from the past 1 hour or 30 minutes) for prediction, so that the latest status of water quality can be responded to in a timely manner during model training and prediction.
[0050] In the embodiment, the spatiotemporal water quality feature extraction module adopts ST-GCN composed of multiple spatiotemporal convolution blocks, each of which is used to extract spatiotemporal water quality features, specifically including a spatial convolution layer for extracting the spatial features of the detection points and a gate sequence convolution layer for extracting the time point features based on the spatial features of the monitoring points. Specifically, a spatiotemporal convolution module is formed by the gate sequence convolution layer, the spatial convolution layer, and the gate sequence convolution layer. The features output by each spatiotemporal convolution module are spatiotemporal water quality features.
[0051] The influence of the extracted spatiotemporal water quality characteristics on the coagulation dosage is not evenly distributed. The water quality characteristics of certain monitoring points or specific time periods may be more important at a certain moment. By introducing the attention mechanism, the model can dynamically adjust the degree of attention to different spatiotemporal information and improve the prediction accuracy of the dosage.
[0052] Specifically, a spatial attention mechanism is introduced in the spatial convolution layer of each spatiotemporal convolution block to focus on the spatial characteristics of the monitoring points, that is, different weights are assigned to different monitoring points. For example, when the water quality of a certain monitoring point upstream changes dramatically, the impact of this point on the predicted dosage may be greater.
[0053] Specifically, a temporal attention mechanism is introduced in each gate sequence convolution layer to focus on the time point features. By dynamically adjusting the attention to different time points, the model can identify the most critical time steps for dosage prediction. For example, a certain change in water quality may have a greater impact on the prediction, while monitoring data from a long time ago may have less impact.
[0054] In the embodiment, the logistic regression prediction module uses the XGBoost model. For complex nonlinear relationships, the XGBoost model is a powerful integrated learning method, especially suitable for processing high-dimensional, nonlinear data. The XGBoost model captures the complex relationship between dosage and spatiotemporal water quality characteristics by training multiple decision trees, and ultimately predicts the accurate dosage.
[0055] In the embodiment, in order to enhance the interpretability of the model, the coagulation dosage prediction model also introduces SHAP (SHapleyAdditive exPlanations), which is a model interpretation package for explaining the output of the machine learning model. SHAP can help explain the decision-making process of the model. SHAP is based on the theory of cooperative game theory and calculates the marginal contribution of each input feature to the prediction result, thereby providing a clear feature explanation. SHAP value calculation: The SHAP algorithm can calculate the contribution of each monitoring point and each water quality indicator (such as turbidity, temperature, conductivity, pH value, etc.) to the prediction of the coagulation dosage.
[0056] The SHAP value calculated in the embodiment can be used to explain the contribution of spatiotemporal water quality characteristics to the prediction of coagulation dosage. Through SHAP interpretation, users can intuitively see which water quality characteristics have the greatest impact on the dosage at different monitoring points or time points. For example, the turbidity at a certain monitoring point may be the main reason for the increase in dosage, while the pH value at another monitoring point may be irrelevant to the dosage decision at a certain moment.
[0057] S3, constructs the dosage objective function and the purification effect objective function based on the graph structure sequence, and constructs a two-objective optimization problem based on these two objective functions. The two-objective optimization problem is solved to obtain the minimum coagulation dosage to achieve a given purification degree. The loss function is constructed by the difference between the coagulation dosage predicted by the model and the solved minimum coagulation dosage. The loss function is used to optimize the parameters of the coagulation dosage prediction model.
[0058] In the embodiment, during the coagulation process, the optimization of the dosage is not a single goal, and it is usually necessary to balance multiple goals. Maximizing the purification effect can ensure that water quality indicators (such as turbidity) meet or exceed the set standards. Minimizing the use of reagents can minimize the use of chemical agents, reduce costs and reduce the risk of secondary pollution. To this end, in order to enable the model to predict the coagulation dosage to balance the water quality purification effect to meet or maximize the water quality, and use the lowest dosage of reagents to reduce costs and reduce secondary pollution, two objective optimization problems are constructed, and the minimum coagulation dosage is used as the training process of the label constraint model. Specifically including:
[0059] Based on the water quality index data, the dosage objective function and the purification effect objective function are constructed. It represents the total amount of chemical agents used to calculate coagulation. The goal is to minimize the dosage while ensuring the water purification effect. The specific formula is: ,in, To optimize the dosage at time t within the time range, it is usually expressed in mg / L.
[0060] Purification effect objective function It refers to the objective function based on water quality indicators, which is used to measure the degree of water purification after coagulation treatment. It can be defined by the degree of compliance of water quality indicators (such as turbidity, chromaticity, chemical oxygen demand (COD), total organic carbon (TOC), etc.). The specific formula is: ,in, N Indicates the number of water quality indicators involved in optimization, It indicates the target value of the i-th water quality index to reach the qualified water quality standard, Represents the dosage based on time t The calculated i The actual value of the water quality index, Indicates the weight of each water quality index, reflecting the relative importance of different water quality indicators to the purification effect; Purification effect objective function The purpose of optimization is to make each water quality index close to its target value and ensure that the purification effect meets the requirements.
[0061] The two-objective optimization problem constructed based on these two objective functions is expressed as: , when solving the problem, different weights of purification effect and dosage are given and , according to the actual application requirements (such as environmental protection requirements or cost control), adjust the weight ratio: When solving a two-objective optimization problem, we need to find the optimal solution that minimizes the dosage. , and can ensure the water purification effect The optimal solution of the minimized dosage is the minimum coagulation dosage to achieve a given purification effect.
[0062] Specifically, the Pareto frontier method is used to find a set of optimal solutions, that is, to reduce the amount of reagents used as much as possible without sacrificing the water purification effect, or to maximize the purification effect without increasing the amount of reagents. Specifically, the minimum coagulation dosage for a given purification degree is obtained by reducing the amount of reagents used as much as possible without sacrificing the water purification effect.
[0063] The loss function is constructed based on the difference between the minimum coagulation dosage and the coagulation dosage predicted by the model. , expressed as: ,in, Represents the model at time t Predicted coagulant dosage, represents the moment obtained by solving the two-objective optimization tThe minimum coagulation dosage is obtained, and a regularization term based on the model parameters is introduced into the loss function to constrain the complexity of the model. The coagulation dosage prediction parameters are optimized by minimizing the loss function, which can improve the accuracy of the model, so that the model considers the water purification effect when predicting the coagulation dosage and outputs the minimum dosage as much as possible. In this way, through the solution of the two-objective optimization problem and the loss function, the improvement of the coagulation dosage prediction model based on actual water quality optimization can be achieved.
[0064] S4, using the parameter-optimized coagulation dosage prediction model to perform real-time dosage prediction, and using SHAP to explain the monitoring points that contribute to the predicted dosage in the spatiotemporal water quality characteristics, which are used to guide the actual coagulation dosage.
[0065] When applied, the real-time monitored water quality index data is input into the parameter-optimized coagulation dosage prediction model for real-time dosage prediction, and the monitoring points that contribute to the predicted dosage in the spatiotemporal water quality characteristics are explained through SHAP, which can be used to guide the actual coagulation dosage. The water quality changes are also monitored in real time after the agent is added, and the feedback is used to adjust the dosage in real time based on the real-time prediction of the reuse model to avoid the risk of agent waste and secondary pollution.
[0066] The coagulation dosage optimization method based on SHAP interpretation provided in the above embodiment can significantly improve the prediction accuracy of dosage, the interpretability of the model and the water treatment efficiency in the coagulation process of the water plant, which is specifically reflected in the following aspects:
[0067] (1) The accuracy of dosage prediction is significantly improved: By introducing ST-GCN to simultaneously capture the spatial correlation between water quality monitoring points and the temporal dynamic changes of water quality indicators, the model can fully reflect the spatiotemporal variation characteristics of water quality indicators. Experimental results show that the mean square error (MSE) of dosage prediction using the method of the present invention is reduced by about 30% compared with traditional rule-based or experience-based control methods, and by 15% compared with the use of traditional XGBoost models. This means that the present invention can more accurately predict water quality changes and reasonably optimize dosage.
[0068] (1) Enhanced interpretability of the model: By introducing the SHAP algorithm, the present invention can provide a clear explanation for each dosing decision and show the marginal contribution of each input water quality feature to the predicted result. In the experiment, through SHAP visualization, it was found that the key water quality features (such as turbidity, pH value, dissolved oxygen, etc.) have different contribution weights to the dosing under different water quality conditions, which can help operators identify key features and optimize the dosing process. This greatly improves the transparency and credibility of the model in practical applications, allowing operators to trust and understand the decision-making process of the model.
[0069] (3) Dynamic optimization of dosage and reduction of reagent cost: The present invention constructs the minimum coagulation dosage as the supervision target through a multi-objective optimization framework, and performs parameter learning on the model, so that the model takes into account the water quality optimization effect when predicting the dosage, and predicts the smallest possible dosage to achieve the water quality optimization effect, which can reduce unnecessary waste of reagents. Experimental data show that using the multi-objective optimization strategy of the present invention, the amount of reagents used is reduced by an average of about 10% to 20%, which greatly reduces the cost of using reagents while ensuring that the water quality meets the standards. In addition, due to the reduction in excessive dosage of reagents, the risk of secondary pollution in the water plant is significantly reduced, which improves the environmental friendliness of water treatment.
[0070] (4) Enhanced adaptability and robustness of the system: Since the present invention combines spatiotemporal feature extraction and a multi-objective optimization model, the system can dynamically respond to diverse needs under complex water quality conditions and make adjustments based on real-time water quality data, ensuring the system's ability to flexibly respond to sudden changes in water quality. In multiple simulation experiments, this method was able to maintain a stable dosage prediction effect under various complex water quality conditions, demonstrating high robustness.
[0071] (5) Broad application prospects: The present invention is applicable to the coagulation dosage control process of various water plants and sewage treatment plants, especially water quality monitoring and dynamic dosing optimization control in large-scale water treatment systems. Its high dosing accuracy, model interpretability and ease of operation make this solution widely applicable to the water treatment industry, promoting the intelligent and automated upgrading of water treatment systems.
[0072] Based on the same inventive concept, Figure 3As shown, the embodiment also provides a coagulation dosage optimization device 30 based on SHAP interpretation, including: a data processing unit 31, a model building unit 32, a loss function building and optimization unit 33, and a real-time prediction unit 34, wherein the data processing unit 31 is used to obtain water quality index data of different monitoring points in the water plant and construct a graph structure sequence of all monitoring points after preprocessing; the model building unit 32 is used to construct a coagulation dosage prediction model, which includes a spatiotemporal water quality feature extraction module, a logistic regression prediction module, and SHAP, wherein the spatiotemporal water quality feature extraction module is used to extract the spatiotemporal water quality features of the graph structure sequence from the graph structure sequence, the logistic regression prediction module is used to predict the coagulation dosage based on the spatiotemporal water quality features, and SHAP is used to predict the coagulation dosage based on the spatiotemporal water quality features. The loss function construction and optimization unit 33 is used to explain the contribution of spatiotemporal water quality characteristics to the predicted dosage; the loss function construction and optimization unit 33 is used to construct the dosage objective function and the purification effect objective function based on the water quality index data, and to construct a two-objective optimization problem based on these two objective functions, and to solve the two-objective optimization problem to obtain the minimum coagulation dosage for a given purification degree, and to construct the loss function with the difference between the coagulation dosage predicted by the model and the solved minimum coagulation dosage, and to optimize the parameters of the coagulation dosage prediction model using the loss function; the real-time prediction unit 34 is used to perform real-time dosage prediction using the parameter-optimized coagulation dosage prediction model, and to explain the monitoring points that contribute to the predicted dosage in the spatiotemporal water quality characteristics through SHAP, and the monitoring points are used to guide the actual coagulation dosage placement.
[0073] It should be noted that the coagulation dosage optimization device based on SHAP interpretation provided in the above embodiment should be illustrated by the division of the above-mentioned functional modules or units when performing the coagulation dosage optimization prediction. The above-mentioned functions can be assigned to different functional modules or units as needed, that is, the internal structure of the terminal or server is divided into different functional modules or units to complete all or part of the functions described above. In addition, the coagulation dosage optimization device based on SHAP interpretation provided in the above embodiment belongs to the same concept as the coagulation dosage optimization method embodiment based on SHAP interpretation. The specific implementation process is detailed in the coagulation dosage optimization method embodiment based on SHAP interpretation, which will not be repeated here.
[0074] Based on the same inventive concept, an embodiment further provides a computing device, including a memory and one or more processors, wherein executable code is stored in the memory, and when the one or more processors execute the executable code, the method for optimizing the coagulation dosage based on SHAP interpretation is implemented, specifically including the following steps:
[0075] S1, obtain the water quality index data of different monitoring points in the water plant and construct the graph structure sequence of all monitoring points after preprocessing;
[0076] S2, constructing a coagulation dosage prediction model, which includes a spatiotemporal water quality feature extraction module, a logistic regression prediction module, and SHAP, wherein the spatiotemporal water quality feature extraction module is used to extract the spatiotemporal water quality features of the graph structure sequence from the graph structure sequence, the logistic regression prediction module is used to predict the coagulation dosage based on the spatiotemporal water quality features, and SHAP is used to explain the contribution of the spatiotemporal water quality features to the prediction of the coagulation dosage;
[0077] S3, constructing a dosage objective function and a purification effect objective function based on water quality index data, and constructing a two-objective optimization problem based on these two objective functions, and solving the two-objective optimization problem to obtain the minimum coagulation dosage to achieve a given purification degree, and constructing a loss function based on the difference between the coagulation dosage predicted by the model and the solved minimum coagulation dosage, and using the loss function to optimize the parameters of the coagulation dosage prediction model;
[0078] S4, using the parameter-optimized coagulation dosage prediction model to perform real-time dosage prediction, and using SHAP to explain the monitoring points that contribute to the predicted dosage in the spatiotemporal water quality characteristics, which are used to guide the actual coagulation dosage.
[0079] The computing device provided in the embodiment, in addition to the processor and memory, also includes hardware required for other services such as internal bus, network interface, memory, etc. at the hardware level. The memory is a non-volatile memory, and the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the coagulation dosage optimization method based on SHAP interpretation described in S1-S4 above. Of course, in addition to the software implementation method, the present invention does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0080] The specific implementation methods described above provide a detailed description of the technical solutions and beneficial effects of the present invention. It should be understood that the above is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A coagulation dosage optimization method based on SHAP interpretation, characterized in that: The following steps are involved: The water quality index data of different monitoring points in the water plant are obtained and preprocessed to construct a graph structure sequence of all monitoring points. Each detection point is used as a node, and the water value index data of the monitoring point is used as the node attribute to construct the node feature. Edges are constructed between nodes, and edge weights are assigned to the edges to construct an adjacency matrix. The edge weights are determined as follows: a high edge weight is assigned if the distance between the monitoring points is short, a high edge weight is assigned if the monitoring points are connected by pipes, and a high edge weight is assigned if the water flow speed is fast. The time dimension modeling is added to construct the graph structure sequence. A coagulation dosage prediction model is constructed, which includes a spatiotemporal water quality feature extraction module, a logistic regression prediction module, and SHAP, wherein the spatiotemporal water quality feature extraction module is used to extract the spatiotemporal water quality features of the graph structure sequence from the graph structure sequence, the logistic regression prediction module is used to predict the coagulation dosage based on the spatiotemporal water quality features, and SHAP is used to explain the contribution of the spatiotemporal water quality features to the prediction of the coagulation dosage; wherein the spatiotemporal water quality feature extraction module includes an ST-GCN composed of a plurality of spatiotemporal convolution blocks, each of which is used to extract spatiotemporal water quality features, specifically including a spatial convolution layer for extracting the spatial features of the detection point and a gate sequence convolution layer for extracting the time point features based on the spatial features of the monitoring point, and at the same time, a spatial attention mechanism is introduced in the spatial convolution layer of each spatiotemporal convolution block to focus on the spatial features of the monitoring point, and a temporal attention mechanism is introduced in each gate sequence convolution layer to focus on the time point features; Based on the water quality index data, the dosage objective function and the purification effect objective function are constructed, and a two-objective optimization problem is constructed based on these two objective functions. It is expressed as: ,in, represents the coagulation dosage at time t; Purification effect objective function It is expressed as: ,in, N Indicates the number of water quality indicators involved in optimization, It indicates the target value of the i-th water quality index to reach the qualified water quality standard, Represents the coagulation dosage based on time t The calculated i The actual value of the water quality index, Indicates the weight of each water quality index, reflecting the relative importance of different water quality indexes to the purification effect; Based on the two objective functions, a two-objective optimization problem is constructed, which is expressed as: , and Respectively represent the weights of dosage and purification effect. When solving the two-objective optimization problem, we look for the optimal solution that can minimize the dosage. , and can ensure the water purification effect The optimal solution of the minimized dosage is the minimum coagulation dosage to achieve a given purification effect. The two-objective optimization problem is solved to obtain the minimum coagulation dosage to achieve a given purification degree. The loss function is constructed based on the difference between the coagulation dosage predicted by the model and the minimum coagulation dosage solved. The loss function is used to optimize the parameters of the coagulation dosage prediction model. The parameter-optimized coagulation dosage prediction model is used to predict the real-time dosage, and the monitoring points that contribute to the predicted dosage in the spatiotemporal water quality characteristics are explained by SHAP. The monitoring points are used to guide the actual coagulation dosage.
2. The coagulation dosage optimization method based on SHAP interpretation according to claim 1 is characterized in that: The water quality index data of different monitoring points are preprocessed, including: outlier removal and missing value supplementation of water quality index data, smoothing of water quality index data, and standardization of different water quality index data.
3. The coagulation dosage optimization method based on SHAP interpretation according to claim 1 is characterized in that: The logistic regression prediction module adopts the XGBoost model, which uses the XGBoost model to perform logistic regression to predict the coagulation dosage based on the extracted spatiotemporal water quality characteristics.
4. The coagulation dosage optimization method based on SHAP interpretation according to claim 1 is characterized in that: The Pareto frontier method is used to solve the two-objective optimization problem and obtain the minimum coagulation dosage to achieve a given purification degree.
5. The coagulation dosage optimization method based on SHAP interpretation according to claim 1 is characterized in that: When constructing the loss function, a regular term based on the coagulation dosage prediction model parameters is introduced to constrain the complexity of the model.
6. A coagulation dosage optimization device based on SHAP interpretation, characterized in that: include: A data processing unit is used to obtain water quality index data of different monitoring points in the water plant and construct a graph structure sequence of all monitoring points after preprocessing, take each detection point as a node, and use the water value index data of the monitoring point as the node attribute to construct the node feature, construct edges between the nodes, and assign edge weights to the edges to construct an adjacency matrix, wherein the edge weights are determined in the following way: a high edge weight is assigned if the distance between the monitoring points is short, a high edge weight is assigned if the monitoring points are connected by pipes, and a high edge weight is assigned if the water flow speed is fast, and a time dimension modeling is added to construct a graph structure sequence; A model building unit, which is used to build a coagulation dosage prediction model, which includes a spatiotemporal water quality feature extraction module, a logistic regression prediction module, and SHAP, wherein the spatiotemporal water quality feature extraction module is used to extract the spatiotemporal water quality features of the graph structure sequence from the graph structure sequence, the logistic regression prediction module is used to predict the coagulation dosage based on the spatiotemporal water quality features, and SHAP is used to explain the contribution of the spatiotemporal water quality features to the predicted dosage; wherein the spatiotemporal water quality feature extraction module includes an ST-GCN composed of a plurality of spatiotemporal convolution blocks, each spatiotemporal convolution block is used to extract spatiotemporal water quality features, specifically including a spatial convolution layer for extracting the spatial features of the detection point and a gate sequence convolution layer for extracting the time point features based on the spatial features of the monitoring point, and at the same time, a spatial attention mechanism is introduced in the spatial convolution layer of each spatiotemporal convolution block to focus on the spatial features of the monitoring point, and a temporal attention mechanism is introduced in each gate sequence convolution layer to focus on the time point features; The loss function construction and optimization unit is used to construct the dosage objective function and the purification effect objective function based on the water quality index data, and to construct a two-objective optimization problem based on these two objective functions, where the dosage objective function It is expressed as: ,in, represents the coagulation dosage at time t; Purification effect objective function It is expressed as: ,in, N Indicates the number of water quality indicators involved in optimization, It indicates the target value of the i-th water quality index to reach the qualified water quality standard, Represents the coagulation dosage based on time t The calculated i The actual value of the water quality index, Indicates the weight of each water quality index, reflecting the relative importance of different water quality indexes to the purification effect; Based on the two objective functions, a two-objective optimization problem is constructed, which is expressed as: , and Respectively represent the weights of dosage and purification effect. When solving the two-objective optimization problem, we look for the optimal solution that can minimize the dosage. , and can ensure the water purification effect The optimal solution of the minimized dosage is the minimum coagulation dosage to achieve a given purification effect. The two-objective optimization problem is solved to obtain the minimum coagulation dosage to achieve a given purification degree. The loss function is constructed based on the difference between the coagulation dosage predicted by the model and the minimum coagulation dosage solved. The loss function is used to optimize the parameters of the coagulation dosage prediction model. The real-time prediction unit is used to make real-time dosage prediction using the parameter-optimized coagulation dosage prediction model, and to interpret the monitoring points that contribute to the predicted dosage in the spatiotemporal water quality characteristics through SHAP. The monitoring points are used to guide the actual coagulation dosage.
7. A computing device comprising a memory and one or more processors, wherein the memory stores executable code, characterized in that: When the one or more processors execute the executable code, they are used to implement the coagulation dosage optimization method based on SHAP interpretation as described in any one of claims 1-5.
Citation Information
Patent Citations
Water quality prediction method, device and equipment based on space-time fusion and storage medium
CN111882138A
Intermittent process fault identification method and system based on TDKSFA nonlinear contribution graph
CN112216352A