Water supply network leakage detection method based on Kriging interpolation method and CatBoost model

By reconstructing the pressure distribution of the water supply network using the Kriging interpolation method and combining it with the CatBoost model, the problem of data sparsity caused by the sparse pressure monitoring points in the water supply network was solved, enabling high-precision identification of leakage areas and levels, and improving the accuracy and efficiency of detection.

CN122020407APending Publication Date: 2026-05-12ANHUI UNIVERSITY OF ARCHITECTURE
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ANHUI UNIVERSITY OF ARCHITECTURE
Filing Date
2026-01-30
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing methods for detecting leaks in water supply networks are insufficient to accurately reflect the pressure distribution and leakage impact range of the entire network when pressure monitoring points are sparsely distributed and data is sparse. Furthermore, the models are prone to overfitting and have insufficient generalization ability, resulting in low accuracy in identifying leakage areas and levels.

Method used

Kriging interpolation is used to reconstruct the pressure distribution of all nodes in the pipeline network. The CatBoost model is used to sort and filter features based on their importance, and a multi-class leakage detection model is constructed. By overcoming the interference of spatial data sparsity and redundant features, high-precision identification of leakage areas and levels is achieved.

Benefits of technology

It significantly improves the spatial representation capability of leak samples, enhances the model's adaptability and training efficiency in sparse monitoring scenarios, and achieves high-precision and high-stability pipeline leak detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122020407A_ABST
    Figure CN122020407A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of water supply network monitoring, and particularly relates to a water supply network leakage detection method based on a Kriging interpolation method and a CatBoost model, and the method comprises the steps: firstly constructing a network hydraulic model, and calculating an inter-node Euclidean distance matrix; a hydraulic model is used for simulating multiple times of leakage, and pressure data of pressure value monitoring points and corresponding leakage labels are collected to form training samples; based on a Kriging interpolation method, fusing the pressure data and the distance matrix, estimating a pressure value of a non-monitoring point, and constructing a pressure feature set covering nodes of the whole network; performing importance sorting and screening on the features to obtain an optimal feature subset; combining the data with leakage labels to form a training sample matrix, and inputting the training sample matrix into a CatBoost model for training; and utilizing the trained model to realize the identification of the leakage area and grade according to the real-time pressure data. According to the invention, based on the pressure data of a small number of monitoring points, the independent metering partition where leakage occurs can be positioned more accurately, and the severity of the leakage can be judged.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of water supply network monitoring technology, specifically relating to a water supply network leakage detection method based on Kriging interpolation and CatBoost model. Background Technology

[0002] Leak detection technology in water supply networks has evolved from traditional manual inspections to automated monitoring systems based on the Internet of Things (IoT) and intelligent algorithms. Early methods relied primarily on manual location using equipment such as listening poles and correlators, which was inefficient and dependent on experience. With the development of sensor technology, pressure and flow monitoring equipment has been widely deployed, enabling remote data acquisition and preliminary analysis. In recent years, machine learning methods have been introduced into the field of leak detection. Models such as Support Vector Machines (SVMs) and Random Forests analyze historical data to identify leak patterns, improving the intelligence level of detection. Some research attempts to combine hydraulic model simulations to generate training data to address the problem of insufficient actual leak samples.

[0003] However, existing methods still have significant limitations: on the one hand, the sparse distribution of pressure monitoring points in actual pipeline networks leads to insufficient spatial representativeness of the collected data, making it difficult to accurately reflect the overall pressure distribution and leakage impact range; on the other hand, directly using data from all nodes or monitoring points as features results in high dimensionality and redundancy, easily leading to model overfitting and low training efficiency. Furthermore, most machine learning methods do not fully consider the geographical correlation between pipeline network topology and pressure field, resulting in insufficient generalization ability when monitoring points are limited, making it difficult to achieve high-precision leakage area and level identification in complex pipeline structures. Summary of the Invention

[0004] The purpose of this invention is to provide a method for detecting leaks in water supply networks based on Kriging interpolation and the CatBoost model, so as to overcome the sparsity of spatial data and eliminate the interference of redundant features under the condition of limited deployment of pressure monitoring points in water supply networks, so as to achieve accurate, efficient and automated identification of leak areas and leak levels in the network.

[0005] The present invention achieves the above objectives through the following technical solutions: A method for detecting leaks in water supply networks based on Kriging interpolation and the CatBoost model, the method comprising the following steps: S1. Construct a hydraulic model of the water supply network and obtain the Euclidean distance matrix between nodes, where the nodes include preset pressure monitoring points and pressure estimation points in the network; S2. Simulate leakage based on the hydraulic model, obtain pressure data from the pressure monitoring points, and record the zone and leakage level of the set leakage node to form a training sample; S3. Based on the pressure data and the Euclidean distance matrix, the pressure value of the pressure estimation point is determined by Kriging interpolation, and the pressure data of all pressure monitoring points are fused to construct a full-node pressure feature set; S4. Sort and filter the feature importance of the full node pressure feature set to obtain the optimal feature subset; S5. Combine the optimal feature subset with the corresponding partition and leakage level of the leaking node to form a training sample matrix, and input it into the CatBoost leak detection model for training; S6. Based on the trained model, identify the leakage area and leakage level of the water supply network.

[0006] Furthermore, step S1 includes: S101. Import the topology of the water supply network and the operating parameters of the pipe fittings into the hydraulic analysis tool, and divide the water supply network into... There are 1 independent metering zones, totaling 1 Each node will be one of them. One node serves as a pressure monitoring point, the rest... Using each node as a pressure value estimation point, a hydraulic model of the water supply network is established. S102. Obtain the coordinate matrix of the pressure monitoring points. Coordinate matrix of pressure value estimation points ; S103. Calculation Euclidean distance matrix between each pair of coordinate values ,as well as Each coordinate value in Euclidean distance matrix between each pair of coordinate values .

[0007] Furthermore, step S2 includes: S201. Perform z leakage simulations in the hydraulic model; S202. The leakage amount is divided into multiple levels according to the percentage of the total flow of the pipeline network. In each simulation, a node is randomly selected as the leakage node, and a leakage amount is randomly set within the percentage range. S203. Perform hydraulic analysis to obtain the pressure dataset from all pressure monitoring points at the time of each leak. , , For the first Pressure data values ​​from each pressure monitoring point; S204. Record the independent metering zone to which the leaking node belongs in this simulation. and the aforementioned leakage level , ,Will and Combined into a single training sample , , For training samples The Middle Pressure data values ​​from each pressure monitoring point.

[0008] Furthermore, step S3 includes: S301. Based on the pressure dataset Calculate the semivariance matrix between pressure values ​​at pressure monitoring points. As shown in the following formula: ; S302. Fitting the Euclidean distance matrix using a Gaussian function. and The relationship between them is used to obtain the fitting function; S303. Calculate the Euclidean distance matrix between pressure monitoring points and pressure estimation points. Input the fitting function to obtain the semivariance fitted value matrix. As shown in the following formula: ; S304. Based on Fitting value matrix with semivariance Construct and solve the Kriging interpolation weight matrix equation to obtain the optimal weight coefficients for each pressure value estimation point. ; S305. Optimal weighting coefficients Pressure data values ​​at pressure monitoring points Substituting into the Kriging interpolation definition formula: The pressure dataset for all pressure value estimation points is calculated. , ,in The pressure estimate is the pressure value at the pressure value estimation point. The pressure data value at the pressure monitoring point; S306. Transfer the pressure dataset from the pressure monitoring points. Pressure dataset of pressure value estimation points The feature dataset is composed of pressure data from all nodes in the water supply network. , ; S307. Expand the number of features for each simulated leak to n+m to update the training samples for each simulated leak. The full set of pressure features is obtained. ,in For feature set The Middle Data values ​​for each pressure characteristic.

[0009] Furthermore, step S4 includes: S401. The recursive feature elimination-cross-validation method is adopted, with the CatBoost model as the evaluator and the mean squared error as the loss function, to rank the importance of all features in the full node pressure feature set; S402. Delete the features with the lowest importance ranking in sequence, and evaluate the model performance under different numbers of features using K-fold cross-validation. Select the feature subset that achieves the optimal model performance as the optimal feature subset. , .

[0010] Furthermore, in step S5, the optimal feature subset is combined with the corresponding partition to which the leaking node belongs and the leak level to form a training sample matrix, including: repeat The next steps, S2-S4, will simulate The leak occurred optimal feature subset Combine and construct the training sample matrix when the leakage occurs. As shown in the following formula: .

[0011] Further steps The training process of the CatBoost leak detection model includes: The training sample matrix The feature data in the data is used as input features to define the independent metering partition. Leakage level The combined categories are used as multi-class target labels; The model is initialized and trained in multiple iterations, with each iteration performing the following steps: Calculate the residuals based on the model's current prediction results and the actual labels; Construct a new decision tree to fit the residuals; The output of the new decision tree is added to the model's cumulative score at a preset learning rate. After completing all iterations, a trained CatBoost leak detection model is obtained. The model converts the cumulative score into the predicted probability of each category using the Softmax function.

[0012] Further steps include: S601. Input the real-time pressure data of the pipeline pressure monitoring points collected during the period to be detected into the CatBoost leak detection model trained in step S5. S602. The CatBoost leak detection model outputs the predicted probability of belonging to each independent metering zone and leak level combination category based on the real-time pressure data; S603. Compare the predicted probabilities of all combined categories, and take the category with the highest probability value as the final identification result, wherein the independent measurement partition in the identification result is the predicted leakage area, and the leakage level is the predicted leakage amount level.

[0013] The beneficial effects of this invention are as follows: This invention reconstructs the pressure distribution of the entire pipeline network based on data from a small number of pressure monitoring points using Kriging interpolation, overcoming the spatial information loss problem caused by sparse monitoring points. This significantly improves the spatial representation capability of leak samples and enhances the model's adaptability to small sample sizes and sparse monitoring scenarios. An RFE-CV feature selection mechanism is introduced to automatically filter key features from high-dimensional pressure features, effectively eliminating redundant information, reducing model complexity, avoiding overfitting, and improving training efficiency and robustness. The CatBoost model is used for multi-class identification of leak areas and levels, which has advantages such as insensitivity to noise, support for class imbalance, and high training efficiency. Combined with the aforementioned spatial augmentation and feature optimization, this invention ultimately achieves high-precision and high-stability pipeline leak detection, applicable to water supply network systems of different structures and scales. Attached Figure Description

[0014] Figure 1 This is a flowchart of a water supply network leakage detection method according to the present invention; Figure 2 This is another flowchart of the water supply network leakage detection method in this invention; Figure 3 This is a flowchart of the water supply network leakage detection method in the present invention during the Kriging interpolation stage; Figure 4 This is a flowchart of the water supply network leakage detection method in the RFE-CV stage of the present invention; Figure 5 This is a flowchart of the water supply network leakage detection method in the present invention during the CatBoost model training phase; Figure 6 This is a schematic diagram of a pipeline network model in one embodiment of the present invention; Figure 7 This is an independent metering zoning diagram of the pipeline network in one embodiment of the present invention; Figure 8 This is a distribution map of pipeline pressure monitoring points in one embodiment of the present invention; Figure 9 This is a prediction result diagram for one embodiment of the present invention. Detailed Implementation

[0015] The present application will now be described in further detail with reference to the accompanying drawings. It should be noted that the following specific embodiments are only used to further illustrate the present application and should not be construed as limiting the scope of protection of the present application. Those skilled in the art can make some non-essential improvements and adjustments to the present application based on the above application content. Example

[0016] Please see Figure 1 and Figure 2 A preferred embodiment of this disclosure proposes a method for detecting leaks in water supply networks based on Kriging interpolation and the CatBoost model. The method includes the following steps: S1. Construct a hydraulic model of the water supply network and obtain the Euclidean distance matrix between nodes, where the nodes include preset pressure monitoring points and pressure estimation points in the network.

[0017] In one example, the topology information (including nodes, pipe segments, reservoirs, and water storage tanks) and pipe fitting operating parameters of the L-Town water supply network are imported into the EPANET software to establish a hydraulic model. Combined with... Figure 6 This study uses a hypothetical town, L-Town, as the experimental research subject. The pipeline network consists of 782 water demand nodes, 2 water supply reservoirs, 1 storage tank, and 905 connecting pipe sections. The total water demand is 106 L / s. The minimum elevation of the water demand nodes is 1.8712 m, and the maximum is 76.1173 m. The minimum service water pressure of the network is 3.49 m, and the maximum service water pressure is 73.88 m. Please refer to [link / reference]. Figure 7 As shown, the water supply network is divided into 16 independent metering zones: .

[0018] Preferably, step S1 includes: S101. Please refer to Figure 8 The topology of the water supply network and the operating parameters of the pipe fittings are imported into a hydraulic analysis tool (such as EPANET software), and the water supply network is divided into... There are 1 independent metering zones, totaling 1 Each node will be one of them. One node serves as a pressure monitoring point, the rest... Using each node as a pressure value estimation point, a hydraulic model of the water supply network is established. S102. Obtain the coordinate matrix of the pressure monitoring points. : ; And obtain the coordinate matrix of the pressure value estimation point. : ; In the above formula, This represents the coordinates of a point in a two-dimensional plane.

[0019] S103. Calculation Euclidean distance matrix between each pair of coordinate values : ; In the matrix, each element represents the number of elements from the first element. The coordinates of the pressure monitoring point are transferred to the middle... The Euclidean distance between the coordinates of the pressure monitoring points, where .

[0020] as well as Each coordinate value in Euclidean distance matrix between each pair of coordinate values : ; In the matrix, each element represents the number of pipes in the network. From the first pressure monitoring point to the first The Euclidean distance between the coordinates of the pressure value estimation points.

[0021] S2. Based on the hydraulic model, simulate the leakage, obtain the pressure data of the pressure monitoring point, and record the zone and leakage level of the set leakage node (randomly select any node in the water supply network as the leakage node) to form a training sample.

[0022] Preferably, step S2 includes: S201. Call the EPANET toolbox to perform z leakage simulations in the hydraulic model; S202. Divide the leakage amount into multiple levels according to the percentage of the total flow of the pipeline network. For example, divide the leakage amount of 1%-10% of the total flow of the pipeline network into four levels evenly. In each simulation, randomly select a node as the leakage node and randomly set a leakage amount within the percentage range. For example, randomly set a leakage amount within the range of 1%-10% of the total flow of the pipeline network. S203. Perform hydraulic analysis to obtain the pressure dataset from all pressure monitoring points at the time of each leak. , , For the first Pressure data values ​​from each pressure monitoring point; S204. Record the independent metering zone to which the leaking node belongs in this simulation. and the aforementioned leakage level , ,Will and Combined into a single training sample , , For training samples The Middle Pressure data values ​​from each pressure monitoring point.

[0023] S3. Based on the pressure data and the Euclidean distance matrix, the pressure value of the pressure estimation point is determined by the Kriging interpolation method, and the pressure data of all pressure monitoring points are integrated to construct a full-node pressure feature set.

[0024] As a preferred option, please refer to Figure 3 Step S3 includes: S301. Based on the pressure dataset Calculate the semivariance matrix between pressure values ​​at pressure monitoring points. As shown in the following formula: ; S302. Euclidean distance of the pressure monitoring point coordinate matrix As input, the semivariance of the pressure data matrix from the pressure monitoring points. As output, a Gaussian function is used to fit the numerical relationship between the two.

[0025] S303. Calculate the Euclidean distance matrix between pressure monitoring points and pressure estimation points. Input the fitting function to obtain the semivariance fitted value matrix. As shown in the following formula: ; S304. Based on Fitting value matrix with semivariance Construct and solve the Kriging interpolation weight matrix equation to obtain the optimal weight coefficients for each pressure value estimation point. .

[0026] S305. Optimal weighting coefficients Pressure data values ​​at pressure monitoring points Substituting into the Kriging interpolation definition formula: The pressure dataset for all pressure value estimation points is calculated. , ,in The pressure estimate is the pressure value at the pressure value estimation point. The pressure data value at the pressure monitoring point; S306. Transfer the pressure dataset from the pressure monitoring points. Pressure dataset of pressure value estimation points The feature dataset is composed of pressure data from all nodes in the water supply network. , ; S307. Expand the number of features for each simulated leak to n+m to update the training samples for each simulated leak. The full set of pressure features is obtained. , ,in For feature set The Middle Data values ​​for each pressure characteristic.

[0027] Specifically, a concrete derivation example for step S3 is as follows: (1) According to the semivariance formula ; In the formula, Indicates from the first The data value to the th The difference between data values This represents solving for the mathematical expectation. It involves using a matrix of pressure data from monitoring points at the time of the simulated leak. Substituting the parameters into the semivariance formula, we can obtain the formula for calculating the semivariance between pairwise pressure data values ​​at pipeline pressure monitoring points: ; In the formula, Indicates from the first The pressure data value of the first pressure monitoring point is transferred to the first... The difference between the pressure data values ​​of each pressure monitoring point This represents solving for the expected value. Solving this formula yields the semivariance matrix of pressure data values ​​between each pair of pressure monitoring points: ; In the matrix, each element represents the number of elements from the first element. From the first pressure monitoring point to the first The semivariance of pressure data values ​​between pressure monitoring points, where .

[0028] (2) The formula for the Gaussian function is as follows: ; In the formula, This represents the Euclidean distance between the coordinates of two points. It's worth a piece of gold. It is the base value. It's a variable range. It calculates the semivariance of pressure data values ​​between each pair of pressure monitoring points. As output, the Euclidean distance between the coordinates of each pair of pressure monitoring points. Substituting these two values ​​into the formula for calculating the Gaussian function, we obtain the numerical relationship function between them after fitting, as shown in the following formula: ; In the formula, Euclidean distance is used. As the independent variable, with semivariance As the dependent variable, These are the weight parameters that need to be updated for the fitted function. For Each pressure monitoring point can provide the following information: The optimal weight parameters are obtained by iteratively solving the input and output pairs using the nonlinear least squares method. The core formula for iteration is: ; In the formula, For the first The parameters for the next iteration For residual vectors ; In the formula, It is the true semivariance value. It is the semivariance value of the Gaussian function fit. The Jacobian matrix is ​​calculated using the following formula: ; In the formula, This is the semivariance value of the Gaussian function fit. The objective is to minimize the sum of squared residuals. ; In the formula, For the present Next, the The residuals between the true semivariance value and the fitted semivariance value output by the Gaussian function are iterated repeatedly. Until the sum of squared residuals When the value reaches its minimum, the Gaussian function is fitted to obtain the semivariance of the pressure data values ​​between each pair of pressure monitoring points. As the output, the Euclidean distance between the coordinates of each pair of pressure monitoring points is used. Optimal weight parameters as input Thus, the fitted numerical relationship function is obtained: ; In the formula, This represents the fitted numerical relationship function.

[0029] (3) Based on the obtained numerical relationship function formula, calculate the Euclidean distance matrix between the pressure monitoring point and the pairwise coordinates of all other nodes in the pipeline network. As input, the formula for calculating the semivariance fit value of the pressure data values ​​of the pressure monitoring point and all other nodes in the pipeline network can be obtained. ; Will Substituting the parameters into the calculation formula, the semivariance fit value between each pairwise pressure data value at the pressure monitoring point and the pressure estimate value at the pressure estimation point can be obtained. ; In the matrix, each element represents the number of elements from the first element. Pressure data value from each pressure monitoring point to the first The semivariance fit value between the pressure estimates at each pressure point.

[0030] (4) The calculation formula for Kriging interpolation is as follows: ; In the formula, For the estimated value that needs to be calculated through interpolation, The optimal weighting coefficients for the estimated values. The values ​​are known. Substituting the pressure data from the pressure monitoring points into the formula, we can obtain the formula for calculating the estimated pressure value at the pressure estimation point: ; In the formula, The pressure estimate is the pressure value at the pressure value estimation point. Let be the optimal weighting coefficients for the current pressure value estimation point that we need to solve next, and let be the pressure data values ​​of the pressure monitoring points. Let be the values ​​of where is being calculated. The value of requires the use of the cost function of Kriging interpolation, which is expressed as: ; In the formula, This is the symbol for the cost function. This represents the estimated pressure value at the pressure estimation point. This represents the actual pressure value at the pressure estimation point. Assume the estimated pressure value and the actual pressure value at the pressure estimation point are... Given, use the symbols respectively. and Represented using the cost function. Pressure estimate at the minimum pressure estimate point Compared to the actual stress value The deviation between them is calculated, and the calculation formula of Kriging interpolation is substituted into the cost function of Kriging interpolation. In the middle, Replace with .at this time, For about weight The function. Solving the cost function using the Lagrange multiplication method. Under constraints The minimum value under the given conditions, after simplification, can be obtained as follows: ; In the formula, It is one of the constraints defined by the Kriging interpolation method. It is the Lagrange multiplier. Extending the formula to a system of linear equations: ; In the formula, This represents the semivariance of pressure data values ​​between any two pressure monitoring points. This represents the pairwise semivariance fit between the pressure data values ​​at the pressure monitoring point and the pressure estimates at the pressure estimation point. Furthermore, the linear equation system can be simplified to the optimal weighted value. The solution matrix: ; The semivariance between each pairwise pressure data point and the estimated pressure values ​​of all other nodes in the pipeline network is calculated. and the semivariance of pressure data values ​​between each pair of pressure monitoring points Substitute the optimal weights In the solution matrix. For Each pressure value is estimated point, through The solution can be obtained by calculating the submatrix. Group Optimal Weight .

[0031] According to the calculation formula of Kriging interpolation: ; The optimal weights of the pressure data values ​​from the pressure monitoring points and the pressure estimation points are sequentially calculated. Interpolation calculations are performed. This allows us to obtain the pressure estimates at all pressure estimation points when a leak occurs. .

[0032] Pressure data values ​​from pressure monitoring points Pressure estimate at the pressure estimate point By combining the data, we obtain a dataset representing the pressure values ​​of all nodes in the water supply network at each simulated leak occurrence: ; The number of feature data is reduced from Expanded to One. Then update the training samples for each simulated leak. Ultimately, a new training sample can be obtained: .

[0033] S4. Sort and filter the full node pressure feature set according to feature importance to obtain the optimal feature subset.

[0034] Specifically, please refer to Figure 4 Step S4 uses RFE-CV on the training samples Data cleaning is performed. RFE-CV consists of two steps: Recursive Feature Elimination (RFE) and Cross-Validation (CV).

[0035] First, via RFE Feature importance ranking and feature elimination are performed, and the CatBoost model is used as the evaluation model for RFE. as a subset of samples And input it into the CatBoost model for training. (Targeting...) For each feature data point, RFE will sequentially use the splitting gain generated by the model as the importance weight for that feature data during training. Therefore, based on the weight magnitude, [the following applies to different features / data points]... In We rank the features by importance and remove the feature with the lowest importance, resulting in a feature set with the following number of features. sample subset , ; Then, The input continues to be fed into the CatBoost model for training, and feature importance is ranked and eliminated via RFE. The feature data with the lowest importance ranking is used to obtain the feature subset. This RFE process continued until... In Until all feature data is eliminated. That is, for A total of Secondary feature elimination can be obtained sequentially. Each has A subset of samples with a certain number of features is combined into a single set: ; Secondly, a set of CV sample subsets is used. The data is processed to select feature data with the optimal number of features as training samples. This is done sequentially. Sample subset in Divided into A mutually exclusive fold, that is, sequentially folding the sample set matrix Each row of sample subsets Evenly divided into Disjoint subsets Therefore, we have: ; In sequence The Middle Using a subset as the test set, the remaining subsets... The combined set of each subset is used as the training set and input into the CatBoost model for training and testing. The subsets are recorded sequentially. The output of the CatBoost model when used as a test set was recorded in a total of Output the results and calculate. The average of the output results is used as the evaluation sample subset. The number of features in the model is an indicator of whether it optimizes the performance of the CatBoost model. Until... Each row of sample subsets Up to the point of CV, a total of [number] results can be obtained. One evaluation indicator. Based on the obtained evaluation indicators, The overall impact of sample subsets with a certain number of features on the performance of the CatBoost model is ranked, and the ranking results can be used to obtain... A subset of samples with a certain number of features can optimize the performance of the CatBoost model. Choosing the appropriate sample set... The optimal number of sample subsets As the final training sample: ; This leads to the updated training samples. : .

[0036] Specifically, a concrete derivation example for step S4 is as follows: (1) Use RFE-CV to process the training samples obtained by Kriging interpolation. Data cleaning, RFE-CV, is a two-step process consisting of RFE and CV. Perform data cleaning.

[0037] (2) RFE processing of training samples The process is as follows: a. Using the CatBoost model as the evaluation model, we select MSE as the loss function for the CatBoost model, and its formula is as follows: ; In the formula, The number of data points. For the true value, These are the predicted values ​​from the model. as a subset of samples Substituting this into the loss function, we get: ; In the formula, This represents the sample subset when a single leakage occurs in the simulation. The number of feature data in the dataset. Among them, Represents a subset of samples The feature data in the data represents the true value.

[0038] Refers to sample subset The feature data in the table corresponds to the predicted values ​​generated by the CatBoost leak detection model, representing the predicted values. The data is fed into the CatBoost model for multiple rounds of training, and the training results are recorded.

[0039] b. In each round of training, the CatBoost model completes the prediction task by constructing multiple decision trees, selecting them sequentially. One of the data features As a split node in the decision tree, according to the loss function formula: ; Calculate Feature data in The loss function value used to train the CatBoost model before splitting, serving as the split point. .

[0040] c. In decision trees After splitting as a splitting node, the training samples The feature data will be divided into a left subset: ; By substituting the left subset into the loss function formula: ; In the formula, Represents the left subset The number of data points in the dataset. It refers to The elements in the array represent the actual values. This refers to the CatBoost model corresponding to The predicted value generated by the middle element represents the predicted value. This is used to calculate the left subset. Loss function value for training CatBoost model Substituting the right subset into the loss function formula: ; In the formula, Represents the left subset The number of data points in the dataset. It refers to The elements in the array represent the actual values. This refers to the CatBoost model corresponding to The predicted value generated by the middle element represents the predicted value. The right subset is calculated. Loss function value for training CatBoost model .

[0041] d. According to the formula The splitting gain is obtained. In the formula, For sample subset One of the elements, for The number of data in the data, Left subset The number of data features right subset The number of data features. Based on what has already been obtained... Calculate decision trees Splitting gain at the splitting point and will The numerical value is used as the importance weight.

[0042] Based on the importance weight, the sample subsets All feature data are ranked by importance, and the least important feature is eliminated to obtain a new subset of samples: ; Then based on the new sample subset Jump to a, repeat the RFE process until the training samples are obtained. Until all features are eliminated, a total of [number] operations will be performed. Secondary feature elimination can be obtained sequentially. Each has A subset of features is selected and combined into a single set. ; (3) In the CV part, the set of sample subsets is obtained. conduct Cross-validation, the specific process is as follows: a. Each row of feature subsets Divided into A mutually exclusive fold, soon Evenly divided into Disjoint subsets : ; b. Sequentially... One fold was used as the test set, and the remaining folds were used as the test set. The combined set of the subsets is used as the training set. The CatBoost model is trained using the training set, and the trained model is tested using the test set. The test results are recorded.

[0043] exist After training each fold sequentially, we will obtain... The MSE is used as an evaluation metric for the training results of the CatBoost model. According to the formula: ; Calculate and record The average value of each folded evaluation index. Where, The number of MSEs. For the first The data values ​​are the mean square error.

[0044] (4) Based on the test results, calculate the average value of the test results, and obtain a total of Several evaluation indicators were identified and ranked. This yielded... A subset of features with a certain number of features optimizes the performance of the CatBoost model. As the optimal sample subset: ; This allows for updating the training samples: .

[0045] S5. Combine the optimal feature subset with the corresponding partition and leakage level of the leaking node to form a training sample matrix, and input it into the CatBoost leak detection model for training.

[0046] As a preferred option, please refer to Figure 5 In step S5, the optimal feature subset is combined with the corresponding partition and leakage level of the leaking node to form a training sample matrix, including: repeat The next steps, S2-S4, will simulate The leak occurred optimal feature subset Combine and construct the training sample matrix when the leakage occurs. As shown in the following formula: .

[0047] Preferably, in step S5, the training process of the CatBoost leak detection model includes: Using the feature data in the training sample matrix S4 as input features, the independent measurement partitions Leakage level The combined categories are used as multi-class target labels; the model is initialized, and the CatBoost leak detection model is trained in a multi-round iterative manner, wherein each round of iteration performs the following steps: The residual is calculated based on the current prediction result of the model and the true label; a new decision tree is constructed to fit the residual; the output of the new decision tree is accumulated into the cumulative score of the model with a preset learning rate; after completing all iterations, the trained CatBoost leak detection model is obtained, and the model converts the cumulative score into the prediction probability of each category through the Softmax function.

[0048] Specifically, a concrete derivation example for step S5 is as follows: (1) Repetition Steps 2 through 4, simulation The second leak occurred, and the obtained indivual Combine and construct the training sample matrix at the time of leakage: ; (2) The training samples The data is input into the CatBoost leak detection model and trained. For the training samples... of Each dimension will determine the partition to which the leaking node belongs. and leakage level As training labels, the stress data values ​​of the remaining nodes The feature data is input into the CatBoost model for training, and the specific process is as follows: a. The water supply network has a total of There are 1 independent metering zones, divided into 4 leakage levels based on different leakage amounts. By pairing the independent metering zones with the leakage levels, the training samples contain a total of [number missing]. A combination of training labels, i.e. The categories of training labels Initialize the model for each label category. exist of The mean probability of occurrence in each sample is initialized using the following function: ; In the formula, category Indicates the category of the training label. Indicates category The initial score, express The number of training samples in the dataset. It is an indicator function, when the first The true category of each sample belong When the condition is met, the function value is 1; otherwise, it is 0. After initializing all tag categories, a total of [value] will be obtained. An initialization function, using the normalization formula: ; In the formula, For the first Pressure characteristic data of the water supply network in the training samples For traversal The index of each training label combination is used to obtain the initial predicted probability of each training label category on each training sample, totaling [number missing]. indivual.

[0049] b. After initializing the model, the training samples The partition to which the leaking node belongs in each dimension and leakage level As training labels, the two are combined in pairs to form label categories. The pressure data values ​​of the remaining nodes As feature data, it is input into the CatBoost model for iterative training. First, based on the... The model obtained from rounds of iterations outputs The predicted probability of each training sample in each label category Subsequently in During rounds of iterative training, the computational model... The residual between the predicted value and the true value of each sample in each dimension is calculated using the following formula: ; In the formula, In the first In the first iteration Each sample in category The residuals on. Represents the indicator function, when the first The true category of each sample belong When the condition is met, the function value is 1; otherwise, it is 0. This indicates that the CatBoost model, for the th The sample at the th In round iterations, the categories The predicted probability.

[0050] c. With the first The residuals obtained from round-by-round iterative calculation To achieve the goal, MSE is chosen as the loss function, and the loss is calculated for each label category. Fit a global decision tree As a base learner, multi-sample training is transformed into a general model, as shown in the following formula: ; In the formula, For the first In round iterations, for label categories The optimal decision tree base learner obtained through fitting; The feature data that can be input into the model after it has been trained; To find a decision tree that minimizes the subsequent loss function value Mathematical symbols. Training sample matrix The number of samples in the sample. Let be the loss function for mean squared error, and its expression is: ; In the first In the first iteration Each sample in category The residual value. For decision trees to the first Sample feature data The predicted output value is the fitted value of the decision tree to the true residual.

[0051] d. The tree model that yields the optimal fitting residuals Then, the model is updated: ; In the formula, Indicates the first After rounds of iterations, the model has different label types. The prediction function, In the first After rounds of iterations, the model has different label types. The prediction function, The learning rate is used to control the influence of the new decision tree. In the first Wheel for label categories The optimal decision tree is fitted. Finally, after completing the preset... After each round of training iterations, the predicted scores from each iteration are summed, causing the model to output the cumulative predicted score for each label category, as shown in the following formula: ; In the formula, For the model to label categories The final cumulative predicted score; This indicates the label categories during the model initialization phase. The initial predicted score; Indicates the learning rate; Indicates the first In round iterations, for label categories The optimal decision tree that fits the criteria. (For...) Each tag category can be used to obtain... The final cumulative predicted score.

[0052] S6. Based on the trained model, identify the leakage area and leakage level of the water supply network.

[0053] Preferably, step S6 includes: S601. Input the real-time pressure data of the pipeline pressure monitoring points collected during the period to be detected into the CatBoost leak detection model trained in step S5. S602. The CatBoost leak detection model outputs the predicted probability of belonging to each independent metering zone and leak level combination category based on the real-time pressure data; S603. Compare the predicted probabilities of all combined categories, and take the category with the highest probability value as the final identification result, wherein the independent measurement partition in the identification result is the predicted leakage area, and the leakage level is the predicted leakage amount level.

[0054] Specifically, the model output Final cumulative score The cumulative score is converted into a probability value using the softmax function, as shown in the following formula: ; In the formula, The feature data is input to the trained leak detection model; This indicates that the input feature data belongs to a category. The final predicted probability, This indicates that the input feature data is in the category The cumulative score of the CatBoost model. For traversal The index of the final cumulative score. All are determined by the softmax function. The scores of each label category are normalized into probabilities, and the label category with the highest probability value is selected as the final prediction result. After obtaining the prediction results, the partition to which the nodes in the label categories belong is determined. As the leak area, the leak level will be determined. As the leakage amount, the task of detecting leaks in the water supply network is ultimately completed.

[0055] Specifically, in practical applications of this invention, the above-described detection method can be embedded into a smart monitoring platform for water supply networks. After real-time collection of data from preset pressure monitoring points, a trained CatBoost model is invoked for inference, outputting the possible zones and levels of leakage in real time, and visualizing the early warning in a geographic information system. This method is particularly suitable for the renovation of aging pipeline networks with sparse monitoring points, significantly improving the timeliness and accuracy of leak detection.

[0056] Please see the appendix Figure 9 The attached figure shows the confusion matrix of the prediction results after implementing the above detection method. The horizontal axis represents the model output, and the vertical axis represents the true labels. Each cell in the matrix represents the number of samples where a true label is predicted by the model to be of a certain category. The diagonal values ​​represent the number of correct predictions, with darker colors indicating a larger number of samples. As can be seen from the figure, after implementing the above detection method, the correct prediction rate for the leakage level is 94.65%, and the correct prediction rate for the leakage area is 96.82%.

[0057] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0058] In addition, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

Claims

1. A method for detecting leaks in water supply networks based on Kriging interpolation and the CatBoost model, characterized in that, The method includes the following steps: S1. Construct a hydraulic model of the water supply network and obtain the Euclidean distance matrix between nodes, where the nodes include preset pressure monitoring points and pressure estimation points in the network; S2. Simulate leakage based on the hydraulic model, obtain pressure data from the pressure monitoring points, and record the zone and leakage level of the set leakage node to form a training sample; S3. Based on the pressure data and the Euclidean distance matrix, the pressure value of the pressure estimation point is determined by Kriging interpolation, and the pressure data of all pressure monitoring points are fused to construct a full-node pressure feature set; S4. Sort and filter the feature importance of the full node pressure feature set to obtain the optimal feature subset; S5. Combine the optimal feature subset with the corresponding partition and leakage level of the leaking node to form a training sample matrix, and input it into the CatBoost leak detection model for training; S6. Based on the trained model, identify the leakage area and leakage level of the water supply network.

2. The water supply network leakage detection method based on Kriging interpolation and CatBoost model according to claim 1, characterized in that, Step S1 includes: S101. Import the topology of the water supply network and the operating parameters of the pipe fittings into the hydraulic analysis tool, and divide the water supply network into... There are 1 independent metering zones, totaling 1 Each node will be one of them. One node serves as a pressure monitoring point, the rest... Using each node as a pressure value estimation point, a hydraulic model of the water supply network is established. S102. Obtain the coordinate matrix of the pressure monitoring points. Coordinate matrix of pressure value estimation points ; S103. Calculation Euclidean distance matrix between each pair of coordinate values ,as well as Each coordinate value in Euclidean distance matrix between each pair of coordinate values .

3. The method for detecting leaks in water supply networks based on Kriging interpolation and the CatBoost model according to claim 2, characterized in that, Step S2 includes: S201. Perform z leakage simulations in the hydraulic model; S202. The leakage amount is divided into multiple levels according to the percentage of the total flow of the pipeline network. In each simulation, a node is randomly selected as the leakage node, and a leakage amount is randomly set within the percentage range. S203. Perform hydraulic analysis to obtain the pressure dataset from all pressure monitoring points at the time of each leak. , , The pressure data value of the i-th pressure monitoring point; S204. Record the independent metering zone to which the leaking node belongs in this simulation. and the aforementioned leakage level , ,Will , and Combined into a single training sample , , For training samples The pressure data value of the i-th pressure monitoring point.

4. The water supply network leakage detection method based on Kriging interpolation and CatBoost model according to claim 3, characterized in that, Step S3 includes: S301. Based on the pressure dataset Calculate the semivariance matrix between pressure values ​​at pressure monitoring points. As shown in the following formula: ; S302. Fitting the Euclidean distance matrix using a Gaussian function. and The relationship between them is used to obtain the fitting function; S303. Calculate the Euclidean distance matrix between pressure monitoring points and pressure estimation points. Input the fitting function to obtain the semivariance fitted value matrix. As shown in the following formula: ; S304. Based on Fitting value matrix with semivariance Construct and solve the Kriging interpolation weight matrix equation to obtain the optimal weight coefficients for each pressure value estimation point. ; S305. Optimal weighting coefficients Pressure data values ​​at pressure monitoring points Substituting into the Kriging interpolation definition formula: The pressure dataset for all pressure value estimation points is calculated. , ,in The pressure estimate is the pressure value at the pressure value estimation point. The pressure data value at the pressure monitoring point; S306. Transfer the pressure dataset from the pressure monitoring points. Pressure dataset of pressure value estimation points The feature dataset is composed of pressure data from all nodes in the water supply network. , ; S307. Expand the number of features for each simulated leak to n+m to update the training samples for each simulated leak. The full set of pressure features is obtained. , ,in For feature set The Middle Data values ​​for each pressure characteristic.

5. The method for detecting leaks in a water supply network based on Kriging interpolation and the CatBoost model according to claim 4, characterized in that, Step S4 includes: S401. The recursive feature elimination-cross-validation method is adopted, with the CatBoost model as the evaluator and the mean squared error as the loss function, to rank the importance of all features in the full node pressure feature set; S402. Delete the features with the lowest importance ranking in sequence, and evaluate the model performance under different numbers of features using K-fold cross-validation. Select the feature subset that achieves the optimal model performance as the optimal feature subset. , .

6. The method for detecting leaks in a water supply network based on Kriging interpolation and the CatBoost model according to claim 5, characterized in that, In step S5, the optimal feature subset is combined with the corresponding partition and leakage level of the leaking node to form a training sample matrix, including: repeat The next steps, S2-S4, will simulate The leak occurred optimal feature subset Combine and construct the training sample matrix when the leakage occurs. As shown in the following formula: 。 7. The method for detecting leaks in a water supply network based on Kriging interpolation and the CatBoost model according to claim 6, characterized in that, In step S5, the training process of the CatBoost leak detection model includes: Using the feature data in the training sample matrix S4 as input features, the independent measurement partitions Leakage level The combined categories are used as multi-class target labels; The model is initialized and trained in multiple iterations, with each iteration performing the following steps: Calculate the residuals based on the model's current prediction results and the actual labels; Construct a new decision tree to fit the residuals; The output of the new decision tree is added to the model's cumulative score at a preset learning rate. After completing all iterations, a trained CatBoost leak detection model is obtained. The model converts the cumulative score into the predicted probability of each category using the Softmax function.

8. The method for detecting leaks in water supply networks based on Kriging interpolation and the CatBoost model according to claim 1, characterized in that, Step S6 includes: S601. Input the real-time pressure data of the pipeline pressure monitoring points collected during the period to be detected into the CatBoost leak detection model trained in step S5. S602. The CatBoost leak detection model outputs the predicted probability of belonging to each independent metering zone and leak level combination category based on the real-time pressure data; S603. The predicted probabilities of all combination categories are compared, and the category with the highest probability value is taken as the final identification result, wherein the independent metering zone in the identification result is the predicted leak area, and the leak level is the predicted leak amount level.