Oil and gas leakage detection method and system
By integrating decision trees and support vector machines through a gradient boosting framework, and combining spatiotemporal gain coefficients and improved Gini coefficients, the problem of insufficient sensitivity in oil and gas pipeline network leak detection in existing technologies is solved, and more efficient leak detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-09
- Publication Date
- 2026-04-03
AI Technical Summary
Existing methods for detecting leaks in oil and gas pipelines fail to fully exploit the anomalies in leak data and the inherent correlation between multidimensional monitoring features. They lack flexibility, resulting in high false alarm and false negative rates, and the models are not sensitive enough to leak events.
A gradient boosting framework is used to integrate decision trees and support vector machines as base learners. The weights of misjudged samples are updated through spatiotemporal gain coefficients, and the base learners are selected based on the entropy and autocorrelation coefficients of the residual sequence. An improved Gini coefficient is used for decision tree node splitting to enhance the model's ability to identify leakage events.
It improves the fitting effect and generalization performance of the oil and gas leak detection model, enhances the sensitivity and attention to leak events, and reduces the false alarm rate and false negative rate.
Smart Images

Figure CN121782528A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of testing, and in particular relates to a method and system for detecting oil and gas leaks. Background Technology
[0002] Leaks in oil and gas pipeline networks cause economic losses and energy waste, leading to environmental pollution and safety accidents. Therefore, real-time leak detection of oil and gas pipelines is necessary to ensure network safety. Leak detection methods are based on physical models, such as the negative pressure wave method, mass balance method, and real-time model method. However, these methods are not sensitive to small-scale leaks and are easily affected by interference, resulting in high false alarm and false negative rates. Data-driven machine learning methods analyze historical monitoring data on flow rate, pressure, temperature, and acoustics to learn the differences in data patterns under normal and leaking conditions, thereby constructing intelligent detection models.
[0003] In the technical practice of applying machine learning for leak detection, support vector machines, decision trees, and neural network algorithms have been used. Ensemble learning strategies, such as gradient boosting decision trees, are employed to construct a strong learner by combining multiple weak learners. However, in the process of constructing the decision tree as the base learner, the splitting criterion cannot fully exploit the anomaly characteristics of the leak data itself and the inherent correlation between multi-dimensional monitoring features. In the iterative enhancement process of ensemble learning, the weight adjustment mechanism for misclassified samples is relatively generic and fails to utilize the strong correlation between pipeline monitoring data in the physical space and time dimensions. Ignoring these spatiotemporal characteristics reduces the model's sensitivity to leak events. Most ensemble frameworks use homogeneous base learners, lacking flexibility and failing to select appropriate learner types based on the residual distribution at different stages of model training, thus affecting the model's fitting effect and generalization performance. Summary of the Invention
[0004] This invention proposes an oil and gas leak detection method to address the shortcomings of existing methods, such as failing to fully exploit the anomalous characteristics of leak data and the inherent correlation between multi-dimensional monitoring features, and lacking flexibility. The method includes: The system acquires monitoring data from multiple sensor nodes in an oil and gas pipeline network, including flow rate, pressure, and acoustic characteristics; it integrates multiple base learners using a gradient boosting framework, including decision trees and support vector machines. In each iteration of the gradient boosting framework, when updating the weights of misjudged samples, a spatiotemporal gain coefficient is applied for enhancement. The spatiotemporal gain coefficient is composed of the sum of the inverses of the physical distances between the misjudged sample and other misjudged samples and the sum of the inverses of the timestamp differences. If the misjudged sample is in a leaky state, the sample weight update value is multiplied by a gain factor based on the anomaly penalty value. When selecting a base learner in each iteration, the entropy and autocorrelation coefficient of the residual sequence of the current model on the training set are calculated; when the entropy is greater than a first preset threshold and the autocorrelation coefficient is less than a second preset threshold, a decision tree is selected as the base learner, and the tree depth is set according to the entropy; otherwise, a support vector machine is selected as the base learner. The trained ensemble model is used to process new monitoring data to achieve oil and gas leak detection.
[0005] Furthermore, the present invention also relates to an oil and gas leak detection system, comprising the following modules: An integrated module is used to acquire monitoring data from multiple sensor nodes in an oil and gas pipeline network, including flow rate, pressure, and acoustic characteristics; multiple base learners are integrated using a gradient boosting framework, including decision trees and support vector machines. The weighting module is used to enhance the weights of misjudged samples in each iteration of the gradient boosting framework by applying a spatiotemporal gain coefficient. The spatiotemporal gain coefficient is composed of the sum of the inverses of the physical distances between the misjudged sample and other misjudged samples and the sum of the inverses of the timestamp differences. If the misjudged sample is in a leaky state, the sample weight update value is multiplied by a gain factor based on the anomaly penalty value. The selection module is used to calculate the entropy and autocorrelation coefficient of the residual sequence of the current model on the training set when selecting a base learner in each iteration; when the entropy is greater than a first preset threshold and the autocorrelation coefficient is less than a second preset threshold, a decision tree is selected as the base learner, and the tree depth is set according to the entropy; otherwise, a support vector machine is selected as the base learner. The processing module is used to process new monitoring data using the trained ensemble model to achieve oil and gas leak detection.
[0006] This invention utilizes an improved Gini coefficient during decision tree node splitting, comprehensively considering the anomaly degree of the leaked sample itself and the synergistic relationship between monitoring features. This enables the decision tree, acting as a base learner, to detect data patterns related to leak events. During the gradient boosting iteration, the weights of misclassified samples are updated by applying a spatiotemporal gain coefficient. This leverages the clustering characteristics of leak events in both physical space and time, allowing the model to focus on learning the true leak regions and enhancing the sensitivity of leak event identification. Additional enhancements are applied to the weights of misclassified leaked samples, increasing the focus on leak signals. During iteration, decision trees or support vector machines are constructed as base learners based on the characteristics of the residual sequence. This achieves complementary advantages of different learner types, enabling the ensemble model to fit residuals at different stages, thereby improving the overall fitting effect and generalization performance of the model. Attached Figure Description
[0007] Figure 1 A flowchart of the first embodiment; Figure 2 A schematic diagram of the base learner selection mechanism; Figure 3 This is a schematic diagram illustrating the application of the model to leak detection. Figure 4 A schematic diagram illustrating the improved Gini coefficients. Detailed Implementation
[0008] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0009] The term "multiple" in this application refers to two or more. Furthermore, it should be understood that the terms "first," "second," etc., used in the description of this application are used only for descriptive purposes and should not be construed as indicating or implying relative importance, nor as indicating or implying order.
[0010] In the first embodiment, the present invention proposes a method for detecting oil and gas leaks, such as... Figure 1 ,include: S1, acquire monitoring data from multiple sensor nodes in the oil and gas pipeline network, the monitoring data including flow rate, pressure and acoustic characteristics; integrate multiple base learners using a gradient boosting framework, the base learners including decision trees and support vector machines; Multiple sensor nodes deployed along the oil and gas pipeline network are used in a Supervisory Control and Data Acquisition (SCADA) system to continuously collect monitoring data from each node at a fixed time frequency, such as once per second. This data constitutes a multi-dimensional time-series dataset, where each data record contains a timestamp, sensor node ID, and the flow rate, pressure, and acoustic characteristic values of that node at that moment. Before being fed into the model, the collected raw data undergoes preprocessing, including missing value imputation (e.g., using the mean of adjacent time points) and data normalization (e.g., using min-max normalization to scale all feature values to the range of 0 to 1) to eliminate the influence of different physical dimensions on model training.
[0011] Initialize a simple base model, such as a constant model containing only the means of leaked and non-leaked labels from the training dataset. In each iteration, calculate the difference between the current ensemble model's predicted values and the true label values, i.e., the residual, which represents the portion the model is currently failing to fit. Train a new base learner whose goal is to fit the residual. Add the newly trained base learner to the existing ensemble model with a certain learning rate, thereby gradually reducing the overall model's prediction error. This iterative process continues for a predetermined number of times, or until the model's performance on the validation set no longer improves. The base learner library here includes both decision trees and support vector machines.
[0012] S2, In each iteration of the gradient boosting framework, when updating the weights of misjudged samples, a spatiotemporal gain coefficient is applied for enhancement. The spatiotemporal gain coefficient is composed of the sum of the inverses of the physical distances between the misjudged sample and other misjudged samples and the sum of the inverses of the timestamp differences. If the misjudged sample is in a leaky state, the sample weight update value is multiplied by a gain factor based on the anomaly penalty value. After the m-th iteration, identify all current ensemble models. Misclassified samples. For any misclassified sample i, calculate the spatiotemporal gain coefficient of the sample. The spatial part is the sum of the reciprocals of the physical pipe distances between the sensor containing sample i and the sensors containing all other misclassified samples j. The temporal part is the sum of the reciprocals of the absolute differences between the timestamp of sample i and the timestamps of all other misclassified samples j. The spatial and temporal parts are weighted and summed to obtain the spatiotemporal gain coefficient of sample i. In the next iteration of training the base learner, the weight of sample i or its contribution to the loss function will be multiplied by this gain coefficient. In another embodiment, the weights of misclassified samples are updated by multiplying the spatiotemporal gain and / or the outlier gain on the residuals after calculation, allowing the model to focus on fitting the enhanced residuals, or by using a weighted loss function when training the next base learner, where the loss of each sample is weighted by the spatiotemporal gain and / or the outlier gain coefficient. In an alternative embodiment, the spatiotemporal gain coefficient is a constant.
[0013] Furthermore, if the true label of sample i is a leak state, the sample weight will be multiplied again by a gain factor, which is a monotonically increasing function of the anomaly penalty value, thereby giving high attention to the true leak points that are difficult to classify.
[0014] In an optional embodiment, the enhancement by applying a spatiotemporal gain coefficient when updating the weights of misclassified samples in each iteration of the gradient boosting framework includes: For any misclassified sample i, the spatiotemporal gain coefficient Calculated using the following formula: in, Let be the physical pipe distance between the sensor node containing the misclassified sample i and any other misclassified sample j. It is the absolute value of the difference between the two timestamps. and Each of the added terms is dimensionless by using preset reference distances and reference times. and These are preset spatial and temporal weighting coefficients.
[0015] Specifically, suppose that after one iteration, the model misclassifies three samples, i, j, and k. Now we need to calculate the spatiotemporal gain coefficient for sample i. Obtain the spatiotemporal information between the misjudged samples, such as the pipe distance between samples i and j. The distance is 50 meters, and the time difference is... The time is 2 seconds; the pipe distance between sample i and k is... The distance is 120 meters, and the time difference is... It lasts for 5 seconds.
[0016] Set reference distance 10 meters, reference time For 1 second, spatial weight The time weight is 0.6. It is 0.4. Calculated according to the formula. The spatiotemporal gain coefficient of sample i The gain coefficient is 0.45. When updating sample weights, the gain coefficient is used to amplify the weight of sample i, so that the base learner in the next round of training pays attention to sample i, and there are other misclassified samples in the surrounding spatiotemporal neighborhood.
[0017] To prioritize the penalty for misclassified leak samples with high anomalousness during the weight update phase of the gradient boosting algorithm, in an optional embodiment, if a misclassified sample is indeed leaking, the sample weight update value is multiplied by a gain factor based on the anomalous penalty value, including: The gain factor The calculation formula is: ,in, The anomaly penalty value corresponding to the sample; Update weights ,in, The new weights of the leaked samples are calculated using the gradient boosting algorithm. is the gain factor.
[0018] Specifically, suppose that in a certain iteration, the model incorrectly classifies a real leak sample as normal. This sample had previously had an anomaly penalty value calculated. The value is 0.95, and this high value indicates that it is a leakage signal.
[0019] In the standard gradient boosting weight update process, assume that the algorithm calculates the new weights for the misjudged samples. The value is 0.12. At this point, the gain factor is calculated first. According to the formula, =1.95. The original new weights... Multiplying by this gain factor yields the updated weights. =0.234. The weight of the misclassified, high-abnormality leak sample was increased from 0.12 to 0.234, allowing the model to devote more effort to correctly classifying the sample in the next round of training, thereby improving the model's sensitivity to leak events.
[0020] S3, when selecting a base learner in each iteration, calculate the entropy and autocorrelation coefficient of the residual sequence of the current model on the training set; when the entropy is greater than a first preset threshold and the autocorrelation coefficient is less than a second preset threshold, select a decision tree as the base learner and set the tree depth according to the entropy; otherwise, select a support vector machine as the base learner. Before the m-th iteration begins, utilize the current model Predictions are made on all training samples to obtain the residual sequence. The Shannon entropy and first-order autocorrelation coefficient of this residual sequence are calculated. An entropy threshold is pre-set. and autocorrelation coefficient threshold If the calculated entropy value is greater than And the autocorrelation coefficient is less than This indicates that the current residual distribution is relatively disordered. Therefore, a decision tree with strong fitting ability is selected as the base learner for this iteration. Simultaneously, the maximum depth of the decision tree will be set based on the entropy value. For example, the maximum depth equals a base depth value plus the product of the entropy value and a scaling factor, so that the larger the entropy value, the deeper the tree. Conversely, if the entropy value is not greater than... Or the autocorrelation coefficient is not less than This indicates that there may be some linear or simple structural regularity in the residuals. In this case, a support vector machine (SVM), such as an SVM regressor configured with a radial basis function kernel, is chosen as the base learner to fit this part of the residuals. Figure 2 .
[0021] In an optional embodiment, the step of selecting a decision tree as the base learner when the entropy value is greater than a first preset threshold and the autocorrelation coefficient is less than a second preset threshold, and setting the tree depth according to the entropy value, includes: When the conditions for selecting a decision tree are met, the tree depth D is determined by the entropy value H of the residual sequence, calculated using the following formula: ,in This is the floor function.
[0022] At the start of a new iteration, the residual sequence generated by the model prediction in the previous iteration is obtained. The entropy value H and the first-order autocorrelation coefficient of this residual sequence are calculated. Assume the calculated entropy value H is 3.2 and the autocorrelation coefficient is 0.03. These values are compared with preset thresholds: a first threshold of 2.8 and a second threshold of 0.05.
[0023] The comparison results show that H=3.2>2.8 and the autocorrelation coefficient 0.03<0.05. Both conditions are met, indicating that the current model's residuals exhibit high randomness and low time correlation, making it suitable for fitting with a more complex model. Therefore, a decision tree is chosen as the base learner for this iteration. The maximum depth D of the decision tree is determined based on the entropy value. Substituting H=3.2 into the depth calculation formula, D=9. A decision tree with a maximum depth of 9 will be used to fit the residuals of this iteration, thereby adjusting the model.
[0024] S4 utilizes the trained ensemble model to process new monitoring data, enabling oil and gas leak detection.
[0025] After all iterations of training are completed, an ensemble model is obtained, consisting of a weighted combination of multiple decision trees and support vector machines. During actual monitoring, new monitoring data, acquired in real-time from pipeline sensors and preprocessed using the same methods, is input into the trained model. The model outputs a predicted value, which can be interpreted as the probability or confidence level of a leak. This output value is compared to a pre-set decision threshold, such as 0.8. If the output value is greater than this threshold, the current pipeline condition is determined to be a leak, and an alarm mechanism is immediately triggered. Figure 3 It sends alerts to operations and maintenance personnel, including the location and time of suspected leaks.
[0026] In an optional embodiment, the method further includes: When constructing the decision tree as the base learner, in the node splitting step, the improved Gini coefficient is used as the splitting criterion. The calculation method is as follows: for samples marked as leaking, the anomaly penalty value is calculated based on the Euclidean distance between the sample feature vector and the mean vector of historical data within the same time window; the correlation between each feature is calculated based on historical monitoring data to form a feature correlation matrix, and the feature co-factor is calculated based on the correlation between the current splitting feature and other features in the matrix; the standard Gini coefficient, the feature co-factor, and the anomaly penalty value for the leaking sample are combined using a preset weighted combination to obtain the improved Gini coefficient; When selecting the optimal splitting feature and splitting point at a node in the decision tree, the standard Gini coefficient for each candidate splitting scheme is calculated. Simultaneously, for all samples marked as leaking within that node, their respective feature vectors are extracted, and the average monitoring data of the corresponding sensor over the past 24 hours is obtained. The Euclidean distance between the feature vector of each leaking sample and the historical mean vector is calculated as the anomaly penalty value for that sample. Using a large-scale historical monitoring dataset, the Pearson correlation coefficients between all pairs of features are calculated, forming a feature correlation matrix. When evaluating a feature as a splitting feature, the absolute values of the correlation coefficients between that feature and all other features are extracted from this matrix, and these absolute values are summed to obtain the feature co-factor of that feature. The standard Gini coefficient, the feature co-factor of the splitting feature, and the average of the anomaly penalty values of all leaking samples within that node are linearly weighted and summed using preset weighting coefficients α, β, and γ to obtain the improved Gini coefficient, such as... Figure 4 Select the features and split points that maximize the reduction in the improved Gini coefficient for node splitting.
[0027] To calculate the merit of each potential feature split point during the decision tree model construction process, in an optional embodiment, the improved Gini coefficient is formulated as follows: in, The standard Gini coefficient of the node. The feature co-factor of the current splitting characteristics, Anomaly penalty value for all samples marked as leaking states within the node. The average value, and These are the preset non-negative weighting coefficients.
[0028] Specifically, the standard Gini coefficient of this node is calculated. For example, in a node containing 100 samples, with 30 leaking samples and 70 normal samples, the standard Gini coefficient is 0.42. Obtain the feature currently used for splitting, assuming it's a stress feature, and find the pre-calculated feature co-factor for that feature. The value is 0.8. Simultaneously, the anomaly penalty value for the 30 leaked samples within this node is calculated. The average value, assuming we get It is 0.9.
[0029] Set weight coefficients It is 0.5. Substituting the given value of 0.2 into the example data above, the improved Gini coefficient can be calculated. The result is 0.432. The improved Gini coefficient... This will replace the standard Gini coefficient as an indicator of the quality of split points. The model compares different features and different split points. The optimal splitting strategy is selected based on the value, so that the construction of the decision tree not only considers the purity of the data, but also takes into account the synergistic effect between features and the degree of abnormality of the leaked sample itself.
[0030] To represent the degree of anomaly of a single leak sample, in an optional embodiment, for samples marked as leaking, an anomaly penalty value is calculated based on the Euclidean distance between the sample feature vector and the mean vector of historical data within the same time window, including: The time window is set to the 60 consecutive data points preceding the current sample; The Euclidean distance between the feature vector of the current leaked sample and the feature mean vector of the 60 data points within the time window is calculated by subtracting the feature vector of the current leaked sample from the feature mean vector of the 60 data points within the time window. ; The Euclidean distance is expressed by the Sigmoid function. Mapped to anomaly penalty value The calculation formula is: ,in This is the preset scaling factor.
[0031] Suppose a leak sample is detected at a certain moment, and the sample feature vector is [flow rate = 2.5, pressure = 3.8, acoustic intensity = 1.2]. Extract historical data from the previous 60 time points. By calculating the average values of these 60 data points across the three dimensions of flow rate, pressure, and acoustic intensity, a historical data mean vector is obtained, for example, [flow rate = 1.0, pressure = 3.5, acoustic intensity = 0.5].
[0032] Calculate the Euclidean distance *d* between the current leaked sample feature vector and the historical mean vector. Based on the example data, *d* ≈ 1.68. Convert this distance value into an anomaly penalty value between 0 and 1 using the Sigmoid function. If the scaling factor k is set to 2, then... The one close to 1 The value indicates that the current leak sample deviates significantly from the historical normal state.
[0033] To represent the inherent correlation between different monitoring features, in an optional embodiment, calculating the feature synergy factor based on the correlation between the current splitting feature and other features in the matrix includes: Using all samples in the training dataset, calculate the Pearson correlation coefficients between each pair of flow rate, pressure, and acoustic features to form a 3×3 feature correlation matrix; For the feature currently used for splitting, extract the absolute values of the correlation coefficients between the feature and the other two features in the correlation matrix, and calculate the average value. This average value is the feature co-factor. .
[0034] Specifically, based on the entire training dataset, Pearson correlation coefficients are calculated between each pair of the three features: flow rate, pressure, and acoustics. The calculation results form a symmetric 3×3 correlation matrix. For example, the matrix might look like this, where the rows and columns correspond to flow rate, pressure, and acoustics, respectively: first row [1.0, 0.8, 0.5], second row [0.8, 1.0, 0.7], third row [0.5, 0.7, 1.0]. This matrix is calculated all at once before model training.
[0035] In the process of building a decision tree, when it is necessary to evaluate the merits of a feature as a splitting node, this matrix is used to calculate the feature co-factor. For example, if we are considering using pressure as a feature for splitting, we need to find the correlation coefficients between pressure and all other features, namely flow rate and acoustics. From the second row or second column of the matrix, we can see that the correlation coefficient between pressure and flow rate is 0.8, and the correlation coefficient with acoustics is 0.7. Feature Co-factor That is, the average of the absolute values of the two correlation coefficients, calculated as follows: .
[0036] To prioritize the penalty for misclassified leak samples with high anomalousness during the weight update phase of the gradient boosting algorithm, in an optional embodiment, if a misclassified sample is indeed leaking, the sample weight update value is multiplied by a gain factor based on the anomalous penalty value, including: The gain factor The calculation formula is: ,in, The anomaly penalty value corresponding to the sample; Update weights ,in, The new weights of the leaked samples are calculated using the gradient boosting algorithm. is the gain factor.
[0037] Specifically, suppose that in a certain iteration, the model incorrectly classifies a real leak sample as normal. This sample had previously had an anomaly penalty value calculated. The value is 0.95, and this high value indicates that it is a leakage signal.
[0038] In the standard gradient boosting weight update process, assume that the algorithm calculates the new weights for the misjudged samples. The value is 0.12. At this point, the gain factor is calculated first. According to the formula, =1.95. The original new weights... Multiplying by this gain factor yields the updated weights. =0.234. The weight of the misclassified, high-abnormality leak sample was increased from 0.12 to 0.234, allowing the model to devote more effort to correctly classifying the sample in the next round of training, thereby improving the model's sensitivity to leak events.
[0039] In a second embodiment, the present invention also proposes an oil and gas leak detection system, comprising the following modules: An integrated module is used to acquire monitoring data from multiple sensor nodes in an oil and gas pipeline network, including flow rate, pressure, and acoustic characteristics; multiple base learners are integrated using a gradient boosting framework, including decision trees and support vector machines. The weighting module is used to enhance the weights of misjudged samples in each iteration of the gradient boosting framework by applying a spatiotemporal gain coefficient. The spatiotemporal gain coefficient is composed of the sum of the inverses of the physical distances between the misjudged sample and other misjudged samples and the sum of the inverses of the timestamp differences. If the misjudged sample is in a leaky state, the sample weight update value is multiplied by a gain factor based on the anomaly penalty value. The selection module is used to calculate the entropy and autocorrelation coefficient of the residual sequence of the current model on the training set when selecting a base learner in each iteration; when the entropy is greater than a first preset threshold and the autocorrelation coefficient is less than a second preset threshold, a decision tree is selected as the base learner, and the tree depth is set according to the entropy; otherwise, a support vector machine is selected as the base learner. The processing module is used to process new monitoring data using the trained ensemble model to achieve oil and gas leak detection.
[0040] In an optional embodiment, the system further includes: When constructing the decision tree as the base learner, in the node splitting step, the improved Gini coefficient is used as the splitting criterion. The calculation method is as follows: for samples marked as leaking, the anomaly penalty value is calculated based on the Euclidean distance between the sample feature vector and the mean vector of historical data within the same time window; the correlation between each feature is calculated based on historical monitoring data to form a feature correlation matrix, and the feature co-factor is calculated based on the correlation between the current splitting feature and other features in the matrix; the standard Gini coefficient, the feature co-factor, and the anomaly penalty value for the leaking sample are combined using a preset weighted combination to obtain the improved Gini coefficient; In an optional embodiment, the improved Gini coefficient is formulated as follows: in, The standard Gini coefficient of the node. The feature co-factor of the current splitting characteristics, Anomaly penalty value for all samples marked as leaking states within the node. The average value, and These are the preset non-negative weighting coefficients.
[0041] In an optional embodiment, the calculation of anomaly penalty values for samples marked as leaking states, based on the Euclidean distance between the sample feature vector and the mean vector of historical data within the same time window, includes: The time window is set to the 60 consecutive data points preceding the current sample; The Euclidean distance between the feature vector of the current leaked sample and the feature mean vector of the 60 data points within the time window is calculated by subtracting the feature vector of the current leaked sample from the feature mean vector of the 60 data points within the time window. ; The Euclidean distance is expressed by the Sigmoid function. Mapped to anomaly penalty value The calculation formula is: ,in This is the preset scaling factor.
[0042] In an optional embodiment, calculating the feature co-factor based on the correlation between the current splitting feature and other features in the matrix includes: Using all samples in the training dataset, calculate the Pearson correlation coefficients between each pair of flow rate, pressure, and acoustic features to form a 3×3 feature correlation matrix; For the feature currently used for splitting, extract the absolute values of the correlation coefficients between the feature and the other two features in the correlation matrix, and calculate the average value. This average value is the feature co-factor. .
[0043] In an optional embodiment, the enhancement by applying a spatiotemporal gain coefficient when updating the weights of misclassified samples in each iteration of the gradient boosting framework includes: For any misclassified sample i, the spatiotemporal gain coefficient Calculated using the following formula: in, Let be the physical pipe distance between the sensor node containing the misclassified sample i and any other misclassified sample j. It is the absolute value of the difference between the two timestamps. and Each of the added terms is dimensionless by using preset reference distances and reference times. and These are preset spatial and temporal weighting coefficients.
[0044] In an optional embodiment, if the misjudged sample is in a leaked state, the sample weight update value is multiplied by a gain factor based on the anomaly penalty value, including: The gain factor The calculation formula is: ,in, The anomaly penalty value corresponding to the sample; Update weights ,in, The new weights of the leaked samples are calculated using the gradient boosting algorithm. is the gain factor.
[0045] In an optional embodiment, the step of selecting a decision tree as the base learner when the entropy value is greater than a first preset threshold and the autocorrelation coefficient is less than a second preset threshold, and setting the tree depth according to the entropy value, includes: When the conditions for selecting a decision tree are met, the tree depth D is determined by the entropy value H of the residual sequence, calculated using the following formula: ,in This is the floor function.
[0046] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments in this specification are not limited to the described order of actions, because according to the embodiments in this specification, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments in this specification.
[0047] In the above embodiments, the descriptions of each embodiment have their own emphasis. Parts not described in detail in a particular embodiment can be found in the relevant descriptions of other embodiments. The preferred embodiments disclosed above are merely for illustrating this specification. Optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Obviously, many modifications and variations can be made based on the content of the embodiments in this specification. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of the embodiments in this specification, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A method for detecting oil and gas leaks, characterized in that, Includes the following steps: Acquire monitoring data from multiple sensor nodes in the oil and gas pipeline network, the monitoring data including flow rate, pressure, and acoustic characteristics; A gradient boosting framework is used to integrate multiple base learners, including decision trees and support vector machines. In each iteration of the gradient boosting framework, when updating the weights of misjudged samples, a spatiotemporal gain coefficient is applied for enhancement. The spatiotemporal gain coefficient is composed of the sum of the inverses of the physical distances between the misjudged sample and other misjudged samples and the sum of the inverses of the timestamp differences. If the misjudged sample is in a leaky state, the sample weight update value is multiplied by a gain factor based on the anomaly penalty value. When selecting a base learner in each iteration, calculate the entropy and autocorrelation coefficient of the residual sequence of the current model on the training set; When the entropy value is greater than a first preset threshold and the autocorrelation coefficient is less than a second preset threshold, a decision tree is selected as the base learner, and the tree depth is set according to the entropy value; otherwise, a support vector machine is selected as the base learner. The trained ensemble model is used to process new monitoring data to achieve oil and gas leak detection.
2. The method according to claim 1, characterized in that, The method further includes: When constructing the decision tree as the base learner, in the node splitting step, the improved Gini coefficient is used as the splitting criterion. The calculation method is as follows: for samples marked as leaking, the anomaly penalty value is calculated based on the Euclidean distance between the sample feature vector and the mean vector of historical data within the same time window; the correlation between each feature is calculated based on historical monitoring data to form a feature correlation matrix, and the feature co-factor is calculated based on the correlation between the current splitting feature and other features in the matrix; the standard Gini coefficient, the feature co-factor, and the anomaly penalty value for the leaking sample are combined using a preset weighted combination to obtain the improved Gini coefficient.
3. The method according to claim 2, characterized in that, The improved Gini coefficient is formulated as follows: in, The standard Gini coefficient of the node. The feature co-factor of the current splitting characteristics, Anomaly penalty value for all samples marked as leaking states within the node. The average value, and These are the preset non-negative weighting coefficients.
4. The method according to claim 2, characterized in that, For samples marked as leaking, an anomaly penalty value is calculated based on the Euclidean distance between the sample feature vector and the mean vector of historical data within the same time window, including: The time window is set to the 60 consecutive data points preceding the current sample; The Euclidean distance between the feature vector of the current leaked sample and the feature mean vector of the 60 data points within the time window is calculated by subtracting the feature vector of the current leaked sample from the feature mean vector of the 60 data points within the time window. ; The Euclidean distance is expressed by the Sigmoid function. Mapped to anomaly penalty value The calculation formula is: ,in This is the preset scaling factor.
5. The method according to claim 2, characterized in that, The step of calculating the feature co-occurrence factor based on the correlation between the current splitting feature and other features in the matrix includes: Using all samples in the training dataset, calculate the Pearson correlation coefficients between each pair of flow rate, pressure, and acoustic features to form a 3×3 feature correlation matrix; For the feature currently used for splitting, extract the absolute values of the correlation coefficients between the feature and the other two features in the correlation matrix, and calculate the average value. This average value is the feature co-factor. .
6. The method according to claim 1, characterized in that, In each iteration of the gradient boosting framework, when updating the weights of misclassified samples, the application of a spatiotemporal gain coefficient for enhancement includes: For any misclassified sample i, the spatiotemporal gain coefficient Calculated using the following formula: in, Let be the physical pipe distance between the sensor node containing the misclassified sample i and any other misclassified sample j. It is the absolute value of the difference between the two timestamps. and Each of the added terms is dimensionless by using preset reference distances and reference times. and These are preset spatial and temporal weighting coefficients.
7. The method according to claim 1, characterized in that, If the misjudged sample is in a leaked state, the sample weight update value is multiplied by a gain factor based on the anomaly penalty value, including: The gain factor The calculation formula is: ,in, The anomaly penalty value corresponding to the sample; Update weights ,in, The new weights of the leaked samples are calculated using the gradient boosting algorithm. is the gain factor.
8. The method according to claim 1, characterized in that, When the entropy value is greater than a first preset threshold and the autocorrelation coefficient is less than a second preset threshold, a decision tree is selected as the base learner, and the tree depth is set according to the entropy value, including: When the conditions for selecting a decision tree are met, the tree depth D is determined by the entropy value H of the residual sequence, calculated using the following formula: ,in This is the floor function.
9. An oil and gas leak detection system, characterized in that, Includes the following modules: An integrated module is used to acquire monitoring data from multiple sensor nodes in an oil and gas pipeline network, the monitoring data including flow rate, pressure, and acoustic characteristics; A gradient boosting framework is used to integrate multiple base learners, including decision trees and support vector machines. The weighting module is used to enhance the weights of misjudged samples in each iteration of the gradient boosting framework by applying a spatiotemporal gain coefficient. The spatiotemporal gain coefficient is composed of the sum of the inverses of the physical distances between the misjudged sample and other misjudged samples and the sum of the inverses of the timestamp differences. If the misjudged sample is in a leaky state, the sample weight update value is multiplied by a gain factor based on the anomaly penalty value. The selection module is used to calculate the entropy and autocorrelation coefficient of the residual sequence of the current model on the training set when selecting a base learner in each iteration; When the entropy value is greater than a first preset threshold and the autocorrelation coefficient is less than a second preset threshold, a decision tree is selected as the base learner, and the tree depth is set according to the entropy value; otherwise, a support vector machine is selected as the base learner. The processing module is used to process new monitoring data using the trained ensemble model to achieve oil and gas leak detection.
10. The system according to claim 9, characterized in that, The system also includes: When constructing the decision tree as the base learner, in the node splitting step, the improved Gini coefficient is used as the splitting criterion. The calculation method is as follows: for samples marked as leaking, the anomaly penalty value is calculated based on the Euclidean distance between the sample feature vector and the mean vector of historical data within the same time window; the correlation between each feature is calculated based on historical monitoring data to form a feature correlation matrix, and the feature co-factor is calculated based on the correlation between the current splitting feature and other features in the matrix; the standard Gini coefficient, the feature co-factor, and the anomaly penalty value for the leaking sample are combined using a preset weighted combination to obtain the improved Gini coefficient.