Urban gas pipeline risk prediction method and device, electronic equipment and medium

By using the E-XGBoost decision tree model, combined with multi-source real-time data processing and feature extraction, the problem of insufficient risk prediction in traditional gas pipeline management is solved, enabling accurate and timely prediction of gas pipeline risks and improving management efficiency and safety.

CN120974457BActive Publication Date: 2026-02-24中电信数字城市科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511517042.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-23
Publication Date
2026-02-24
Estimated Expiration
2045-10-23

AI Technical Summary

Technical Problem

Traditional gas pipeline management methods are inefficient and fail to capture dynamic changes in pipeline status in a timely manner, resulting in insufficient risk warning and management.

Method used

An E-XGBoost decision tree model was adopted. The model was trained by the first-order gradient, which reflects the trend of the prediction error, and the second-order gradient, which reflects the curvature of the prediction error. Each node was split into three sub-nodes. The model was preprocessed, feature extracted, and time-scale aligned with multi-source real-time data to establish a model for predicting the risk of gas pipelines.

Benefits of technology

It enables accurate and timely prediction of gas pipeline risks, improves the accuracy and timeliness of risk prediction, supports scientific preventive maintenance plans and optimal resource allocation, and reduces the accident rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120974457B_ABST
    Figure CN120974457B_ABST
Patent Text Reader

Abstract

The application provides a kind of city gas pipeline risk prediction method, device, electronic equipment and medium, it is related to gas pipeline risk prediction technical field, including: the multiple-source real-time data of gas pipeline is collected and is preprocessed, obtains multiple target features for the establishment of prediction model E-XGBoost;Multiple target features are time scale aligned and fused, to obtain the training data sample after fusion;Establish the prediction model E-XGBoost for predicting the operating state and failure risk of gas pipeline;Each node of decision tree in prediction model is split into three child nodes;Based on the training data sample after fusion, the first-order gradient reflecting the change trend of prediction error and the second-order gradient reflecting the change curvature of prediction error, train prediction model E-XGBoost, to obtain the target prediction model E-XGBoost after training, to alleviate the technical problems of insufficient accuracy and timeliness of risk prediction in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of gas pipeline risk prediction, and in particular to a method, apparatus, electronic device, and medium for predicting urban gas pipeline risks. Background Technology

[0002] As a crucial component of urban infrastructure, urban gas pipeline systems bear the critical responsibility of delivering safe and stable gas to residents and businesses. With the rapid advancement of urbanization and the continuous expansion of pipeline networks, gas pipeline networks are characterized by complex structures, wide coverage, and variable operating environments.

[0003] Traditional gas pipeline management relies primarily on periodic manual inspections and simple analysis based on limited historical data. This approach was sufficient to meet basic needs when the pipeline network was small and simple. Manual inspections typically involve professionals carrying inspection equipment to conduct on-site checks along the pipeline, assessing its condition through visual observation or simple instrument measurements. Historical data analysis mainly depends on manually recorded maintenance logs and limited sensor data, using experience-based judgment and simple statistics to guide maintenance decisions.

[0004] However, with the expansion of pipeline networks and the increase in their service life, traditional methods are no longer sufficient to meet the growing demands of pipeline management. Manual inspections are not only inefficient and have limited coverage, but are also prone to inconsistencies in inspection results due to human factors; while analysis based on simple historical data lacks the ability to integrate multi-dimensional factors and fails to capture dynamic changes in pipeline status in a timely manner. These limitations make traditional methods significantly inadequate in fault early warning and risk management. Summary of the Invention

[0005] The purpose of this invention is to provide a method, device, electronic device, and medium for predicting the risk of urban gas pipelines. The method predicts the risk of gas pipelines by using a decision tree model with three child nodes per node, trained by a first-order gradient that reflects the trend of the prediction error and a second-order gradient that reflects the curvature of the prediction error. This aims to alleviate the technical problems of insufficient accuracy and timeliness in risk prediction in the prior art.

[0006] In a first aspect, the present invention provides a method for predicting the risks of urban gas pipelines, comprising:

[0007] Multi-source real-time data from gas pipelines are collected and preprocessed to obtain multiple target features for the prediction model EXGBoost.

[0008] The multiple target features are aligned and fused according to time scale to obtain fused training data samples;

[0009] An E-XGBoost predictive model for predicting the operating status and failure risk of gas pipelines is established; wherein each node of the decision tree in the E-XGBoost predictive model is split into three child nodes.

[0010] Based on the fused training data samples, the first-order gradient reflecting the trend of prediction error and the second-order gradient of curvature reflecting the change of prediction error are used to train the prediction model E-XGBoost, and the trained target prediction model E-XGBoost is obtained.

[0011] Based on the trained target prediction model E-XGBoost, the risk outcome of the gas pipeline is predicted.

[0012] In an optional implementation, the step of collecting multi-source real-time data from gas pipelines and preprocessing it to obtain multiple target features for establishing the prediction model EXGBoost includes:

[0013] Multi-source real-time data is cleaned using preset methods to obtain target data that meets preset quality requirements.

[0014] Initial features are extracted from the target data, the initial features are input into a preset model, and the initial features are evaluated using a machine learning algorithm and the preset model.

[0015] Based on the weight coefficients corresponding to each initial feature in the evaluation results, multiple target features whose feature importance meets the requirements are determined from the initial features.

[0016] In an optional implementation, the step of aligning and fusing the multiple target features over time to obtain fused training data samples includes:

[0017] Multiple target features from different data sources are standardized and transformed to obtain target feature data of the same numerical order of magnitude;

[0018] Based on the collection timestamps corresponding to the target feature data and the pipe segment IDs of the gas pipeline, the time scales of the target feature data are synchronized and aligned.

[0019] The time-scale aligned target feature data are fused to obtain fused training data samples.

[0020] In an optional implementation, the step of establishing the predictive model EXGBoost for predicting the operating status and failure risk of gas pipelines includes:

[0021] A ternary tree node structure is constructed based on decision tree node information; wherein, the decision tree node information includes splitting features, three splitting thresholds, and predicted values ​​of the left child node, middle child node, right child node, and leaf node, and the three splitting thresholds are the feature values ​​of three consecutive deduplicated and sorted target features.

[0022] Based on the weighted residual of each training data sample, a weighted residual calculation module that dynamically adjusts the sample weights is constructed.

[0023] Based on the loss function value of each training data sample, a module for calculating the first-order gradient that reflects the trend of error change and the second-order gradient that reflects the curvature of error change is constructed.

[0024] Based on node splitting gain and leaf node prediction values, a pruning optimization module including pre-pruning and post-pruning is constructed.

[0025] By integrating the ternary tree node structure, the weighted residual calculation module, the second-order gradient calculation module, and the pruning optimization module, a prediction model E-XGBoost is constructed to predict the operating status and fault risk of gas pipelines.

[0026] In an optional implementation, the step of training the prediction model E-XGBoost based on the fused training data samples, the first-order gradient reflecting the trend of prediction error change, and the second-order gradient reflecting the curvature of prediction error change, to obtain the trained target prediction model E-XGBoost, includes:

[0027] The fused training data samples are input into the prediction model, and the first and second gradients of the loss function value of the prediction model are calculated, as well as the first sample residual corresponding to the first gradient.

[0028] Use the residual of the first sample as the target variable for the next round;

[0029] The second-order gradient calculation module is called to obtain the first-order and second-order gradients for each round, and the weighted residual calculation module is called to update the weight coefficients of the training data samples for each round and calculate the weighted residuals.

[0030] In each round, each target feature in the training data sample is traversed. After deduplication and sorting of the feature values ​​of each target feature, candidate thresholds are selected. The split gain is calculated by combining the first-order gradient and the second-order gradient in each round. The target feature with the largest split gain and the combination of feature values ​​are selected as the optimal split scheme to construct a new prediction model E-XGBoost for each round.

[0031] The pruning optimization module is invoked to pre-prune the new prediction model E-XGBoost for each round;

[0032] The prediction results of the E-XGBoost model for gas pipelines after each round of pruning are used as the second sample residuals of the true labels as the target variable for the next round.

[0033] When the preset number of rounds is reached, the trained target prediction model E-XGBoost is obtained.

[0034] In an optional implementation, prior to the step of predicting the risk outcome of the gas pipeline based on the trained target prediction model EXGBoost, the method further includes:

[0035] The trained target prediction model E-XGBoost is evaluated based on the test set, and the parameters of the trained target prediction model E-XGBoost are optimized based on the evaluation results.

[0036] In an optional implementation, prior to the step of predicting the risk outcome of the gas pipeline based on the trained target prediction model EXGBoost, the method further includes:

[0037] The model parameters of the trained target prediction model E-XGBoost are updated based on the training data samples at the current moment.

[0038] Secondly, the present invention provides a risk prediction device for urban gas pipelines, comprising:

[0039] The preprocessing module collects multi-source real-time data from gas pipelines and preprocesses it to obtain multiple target features for the prediction model E-XGBoost.

[0040] The fusion module aligns and fuses the multiple target features according to their time scales to obtain fused training data samples.

[0041] A module is established to build a prediction model E-XGBoost for predicting the operating status and failure risk of gas pipelines; wherein, each node of the decision tree in the prediction model E-XGBoost is split into three sub-nodes;

[0042] The training module trains the prediction model E-XGBoost based on the fused training data samples, the first-order gradient reflecting the trend of prediction error, and the second-order gradient of curvature reflecting the change of prediction error, to obtain the trained target prediction model E-XGBoost.

[0043] The prediction module, based on the trained target prediction model E-XGBoost, predicts the risk outcome of the gas pipeline.

[0044] Thirdly, the present invention provides an electronic device including a memory, a processor, and a program stored in the memory and capable of running on the processor, wherein the processor executes the program to implement the method as described in any of the foregoing embodiments.

[0045] Fourthly, the present invention provides a computer-readable storage medium storing a computer program, which, when executed, implements the method described in any of the foregoing embodiments.

[0046] This invention provides a method, device, electronic device, and medium for predicting the risks of urban gas pipelines. Based on preprocessing operations such as cleaning and feature extraction of multi-source real-time data collected from gas pipelines, multiple target features with key influence on the prediction model are obtained, enabling subsequent steps to build the prediction model based on these target features. These target features are then aligned and fused according to time scales to obtain training data samples for the prediction model. A prediction model E-XGBoost is established to predict the operating status and fault risks of gas pipelines. Each node in the decision tree of this prediction model E-XGBoost is split into three child nodes. The prediction model is then trained based on the aforementioned training data samples, the first-order gradient reflecting the trend of prediction error, and the second-order gradient reflecting the curvature of prediction error, resulting in the trained target prediction model E-XGBoost. Based on this target prediction model E-XGBoost, accurate prediction of gas pipeline risks can be achieved.

[0047] Other features and advantages of the invention will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained through the structures particularly pointed out in the description and the drawings.

[0048] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0049] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0050] Figure 1 A flowchart of a method for predicting the risk of urban gas pipelines provided in an embodiment of the present invention;

[0051] Figure 2This is a schematic diagram of the functional modules of an urban gas pipeline risk prediction device provided in an embodiment of the present invention;

[0052] Figure 3 A schematic diagram of the hardware architecture of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0053] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0054] Currently, there are still shortcomings in the risk prediction of urban gas pipelines. Based on this, the present invention provides a method, device, electronic device and medium for predicting the risk of urban gas pipelines. Through a decision tree model with three child nodes per node trained by a first-order gradient that reflects the changing trend of the prediction error and a second-order gradient that reflects the curvature of the prediction error, the risk of gas pipelines can be predicted accurately and timely.

[0055] To facilitate understanding of this embodiment, a method for predicting urban gas pipeline risks disclosed in this embodiment of the invention will first be described in detail. This method can be applied to intelligent control devices such as host computers, servers, and controllers.

[0056] Figure 1 A flowchart of a risk prediction method for urban gas pipelines provided in an embodiment of the present invention.

[0057] Reference Figure 1 This method can be implemented through the following steps, including:

[0058] Step S102: Collect multi-source real-time data of gas pipelines and preprocess them to obtain multiple target features for the prediction model E-XGBoost.

[0059] XGBoost (Extreme Gradient Boosting): is an improved version of the Gradient Boosting Tree (GBDT) algorithm. It belongs to the Boosting method in the ensemble learning framework and is used for supervised learning. It is good at handling different types of tabular data.

[0060] The E-XGBoost (Enhanced-XGBoost) proposed in this application is a novel decision tree structure based on the improved XGBoost algorithm.

[0061] For example, step S102 can be implemented by the following steps, including:

[0062] Step 1.1: Perform a preset cleaning operation on the multi-source real-time data to obtain target data that meets the preset quality requirements;

[0063] The system collects multi-source real-time data from urban gas pipelines, including sensor data, geographic information data, historical maintenance records, and weather data. Sensor data includes timestamps, pipe segment IDs, pressure, temperature, and flow rate information. Geographic information data includes pipe segment IDs, longitude, latitude, and elevation information. Historical maintenance records include pipe segment IDs, installation time, maintenance frequency, and last maintenance time. Weather data includes timestamps, temperature, humidity, and rainfall information. The collected multi-source data undergoes data cleaning to remove outliers and fill in missing values, transforming "dirty" data into data that meets quality requirements. As an optional implementation, data cleaning uses an outlier detection algorithm to identify and remove outlier data, and uses mean filling or interpolation methods to fill in missing data.

[0064] The risk prediction method for gas pipelines in this invention considers multiple factors, including pipeline material, service life, pressure, environmental factors, and historical fault records. Compared to traditional methods that typically rely on a single data source or limited datasets, making it difficult to provide a comprehensive risk assessment, this invention, through comprehensive analysis of multi-source data, can more accurately identify various factors affecting pipeline safety, thereby improving the accuracy and reliability of predictions.

[0065] Step 1.2: Extract initial features from the target data, input the initial features into the preset model, and evaluate the initial features using machine learning algorithms and the preset model.

[0066] Here, initial features that have a significant impact on the prediction model are initially selected from the target data that meets the format requirements; this evaluation function can be implemented using a pre-set preset model; as an optional embodiment, the preset model can be a prediction model E-XGBoost.

[0067] Step 1.3: Based on the weight coefficients corresponding to each initial feature in the evaluation results, determine multiple target features from the initial features whose feature importance meets the requirements.

[0068] Feature selection using embedding involves training multi-source data with machine learning algorithms to obtain the weight coefficients of each feature. Features most useful for model building are then selected based on these weight coefficients, from largest to smallest. Embedding feature selection is a method where the algorithm decides which features to use; feature selection and algorithm training occur simultaneously. When using embedding, machine learning algorithms and models are first used for training to obtain the weight coefficients of each initial feature. Features are then selected based on these weight coefficients, from largest to smallest. These weight coefficients often represent a feature's contribution to the model or its importance. For example, the `feature_importances_` attribute in decision trees and ensemble tree models can list the contribution of each feature to tree construction. Based on this contribution evaluation, the most useful target features for model building are further identified from the initial features.

[0069] In practical applications, multiple target features can be divided into training and testing sets according to a preset ratio for use in subsequent model training, evaluation, and optimization steps.

[0070] Here, the dataset D is directly divided into two mutually exclusive sets, one set as the training set S and the other as the test set T, i.e. After training the model on S, T is used to evaluate its test error as an estimate of the generalization error. An 8 / 2 score is typically used.

[0071] For example, the processed multi-source data (target features) can be divided into a training set and a test set in an 8:2 ratio, where the training set is used for model training and the test set is used for model generalization error evaluation.

[0072] Step S104: Align and fuse multiple target features according to their time scales to obtain fused training data samples.

[0073] Step 2.1: Standardize and transform multiple target features from different data sources to obtain target feature data of the same numerical order of magnitude; wherein, the standardization transformation adopts Z-score standardization or Min-Max standardization.

[0074] Step 2.2: Based on the collection timestamps corresponding to the target feature data and the pipe segment IDs of the gas pipeline, synchronize and align the time scales of the target feature data.

[0075] It is understandable that time-scale synchronization and alignment will be performed on multi-source target feature data collected at the same timestamp for the same pipe section.

[0076] Step 2.3: Fuse the time-scale aligned target feature data to obtain fused training data samples.

[0077] It should be noted that if there are multiple sensors in the same pipe section, the data from the multiple sensors in the same pipe section are weighted and averaged before being fused to obtain the fused training data sample.

[0078] Step S106: Establish a prediction model E-XGBoost for predicting the operating status and failure risk of gas pipelines.

[0079] In the prediction model E-XGBoost, each node of the decision tree splits into three child nodes. The nodes of the decision tree model adopt a ternary branch structure, with each node containing three child nodes: left, middle, and right.

[0080] In some embodiments, step S106 may be implemented by the following steps:

[0081] Step 3.1: Construct a ternary tree node structure based on the decision tree node information. The decision tree node information includes splitting features, three splitting thresholds, and predicted values ​​for the left, middle, right, and leaf nodes. The three splitting thresholds are the feature values ​​of three consecutive deduplicated and sorted target features. First, extract all unique feature values ​​for each target feature from the training set consisting of multiple target features and sort them to obtain a threshold candidate list. Second, use every three consecutive feature values ​​in the threshold candidate list as a potential splitting point and calculate the splitting gain for each potential splitting point. Then, based on the node information combination corresponding to the largest splitting gain, split each node of the decision tree in the E-XGBoost model into three child nodes in the optimal way.

[0082] Step 3.2: Based on the weighted residual of each training data sample, construct a weighted residual calculation module that dynamically adjusts the sample weights.

[0083] Here, the weighted residual mechanism assigns weights to each sample when calculating the residuals, thereby strengthening the contribution of important samples to the model. Each sample's residual is multiplied by a weight coefficient, which can be determined based on the sample's error or importance, and can be dynamically adjusted according to the sample's error. For example, samples with larger errors (such as outliers with large prediction errors) can have their weights increased, making the model pay more attention to these samples.

[0084] The weighted residual calculation module calculates the weighted residual for each sample using the `calculate_weighted_residuals` function. The function takes the model, training data samples, true labels, and sample weights as input and outputs the product of the residual and the sample weight as the weighted residual. At the same time, the `calculate_dynamic_weights` function dynamically adjusts the sample weights. For example, it assigns a weight of 2 to samples with an absolute residual value greater than 1 and a weight of 1 to samples with an absolute residual value not greater than 1.

[0085] Step 3.3: Based on the loss function value of each training data sample, construct a module for calculating the first-order gradient that reflects the trend of error change and the second-order gradient that reflects the curvature of error change.

[0086] In gradient boosting, traditional XGBoost uses the first-order gradient to update the tree structure. This invention introduces the second-order gradient, which considers the second derivative of the loss function, providing more accurate information. The second-order gradient can be calculated using the second derivative of the loss function. In regression tasks, the second-order gradient is typically the second derivative of the loss function.

[0087] In the application, the first-order and second-order gradients of each sample are calculated using the `calculate_second_order_gradient` function. The function takes the training data samples, the true labels, the current model, and the loss function as inputs, and outputs the first-order gradient reflecting the trend of error change and the second-order gradient reflecting the curvature of error change. Based on the update of the second-order gradient, the node splitting rules of the decision tree are no longer based solely on the first-order gradient, but are based on the gradient and the Hessian matrix (second-order gradient information) to calculate the optimal splitting point.

[0088] Step 3.4: Based on the node splitting gain and leaf node prediction values, construct a pruning optimization module that includes pre-pruning and post-pruning.

[0089] Pruning can reduce model complexity through pre-pruning (limiting tree depth) and post-pruning (removing unnecessary branches after tree generation). A pruning strategy is introduced during tree generation, deciding whether to prune based on node gain and importance. After tree training is complete, nodes that contribute little to the model are pruned based on their contribution to the leaf nodes, achieving post-pruning.

[0090] In this process, pre-pruning recursively traverses nodes using the `prune_tree` function. If the split gain of a node is lower than the preset `min_gain_threshold`, the left, middle, and right child nodes of that node are set to null and marked as leaf nodes. Post-pruning traverses leaf nodes using the `post_prune_tree` function. If the predicted value of a leaf node is less than 0.05, the leaf node is deleted.

[0091] Step 3.5: Integrate the ternary tree node structure, weighted residual calculation module, second-order gradient calculation module, and pruning optimization module to construct the prediction model E-XGBoost for predicting the operating status and fault risk of gas pipelines.

[0092] In practical applications, it is also necessary to set the maximum tree depth (max_depth) and the pre-pruning gain threshold for the E-XGBoost prediction model after integration.

[0093] Step S108: Based on the fused training data samples, the first-order gradient reflecting the trend of prediction error and the second-order gradient reflecting the curvature of prediction error, train the prediction model E-XGBoost to obtain the trained target prediction model E-XGBoost.

[0094] Here, before training, the parameters and sample weights of the prediction model E-XGBoost are initialized. The sample weights are initialized as all-one vectors with a length equal to the number of samples in the training set.

[0095] Based on this, the training steps of the prediction model in step S108 include the following steps:

[0096] Step 4.1: Input the fused training data samples into the prediction model, calculate the first and second gradients of the loss function value of the prediction model, and the first sample residual corresponding to the first gradient.

[0097] Step 4.1 characterizes the first round of training: using an initial weak learner to predict the training data and calculating the loss function (e.g., mean squared error). The residuals for each sample are calculated based on the negative gradient of the loss function; these residuals represent the difference between the model's prediction and the actual value. The weak learner can be understood as a fundamental component of the prediction model.

[0098] For loss function design, MSE is the most commonly used regression loss function. It squares the error, so larger errors are penalized more severely. Therefore, MSE is suitable for general regression problems, especially for scenarios sensitive to large errors. MAE, on the other hand, calculates the average of the absolute values ​​of the errors, does not amplify the impact of errors, and is therefore more robust to outliers.

[0099] This invention designs a more comprehensive loss function tailored to the data characteristics of different specific application industries, enhancing the model's robustness to outliers while retaining sensitivity to small errors. The comprehensive loss function is: Where α is the adaptively adjusted weight parameter, MAE is the mean absolute error, and MSE is the mean squared error; the first and second gradients of each sample are calculated based on the comprehensive loss function, and the sample residuals are calculated based on the first gradient; the influence of MAE and MSE is balanced by the weight parameter α, which can be adaptively adjusted during the training process of actual data.

[0100] Step 4.2: Use the residuals of the first sample as the target variable for the next round;

[0101] Step 4.2 Begin training for subsequent rounds (rounds K≥2): Use the sample residuals from round K-1 as the target variable / objective function for round K; specifically, use the residuals as the new target variable and train a new weak learner to fit these residuals. Update the model by weighting the predictions of the new weak learner with the previous results to obtain the predictions of the current model. Continue calculating new residuals and training the next weak learner.

[0102] Objective function = Loss function + Regularization term, where the loss function describes how well the model fits the data; the regularization term controls the model complexity; and the objective function is... The first term is the loss function, which measures the model's predicted values. Compared with the true value The first term is the error; the second term is the regularization term, which measures the complexity of the model (to avoid overfitting), where K is the number of weak learners (such as decision trees). This indicates that the k-th weak learner is paired with the sample. The prediction.

[0103] Step 4.3: Call the second gradient calculation module to obtain the first and second gradients for each round, and call the weighted residual calculation module to update the weight coefficients of the training data samples for each round and calculate the weighted residuals.

[0104] Step 4.4: In each round, traverse each target feature in the training data samples, sort the feature values ​​of each target feature after deduplication, and select candidate thresholds. Combine the first-order gradient and second-order gradient in each round to calculate the split gain, select the target feature and feature value combination with the largest split gain as the optimal split scheme, and construct a new prediction model E-XGBoost for each round.

[0105] Here, node splitting is performed based on the ternary tree structure and second-order gradient: all features of the training data sample are traversed, and after deduplication and sorting of the value of each feature, candidate thresholds are selected. The split_node_with_second_order function is used to calculate the split gain by combining the first-order gradient and the second-order gradient. The feature and threshold combination with the largest split gain is selected as the optimal splitting scheme to construct a new weak learner.

[0106] Using the Boosting approach, the learning process is broken down, with the results of the previous tree used to correct subsequent learning:

[0107]

[0108] Therefore, the objective function for the Kth iteration is:

[0109]

[0110] The regularization term controls model complexity and characterizes the degree of fit to the data. Ultimately, only a suitable tree needs to be found. By minimizing the objective function and then iterating K times, the training of K weak learners can be completed.

[0111] Step 4.5: Call the pruning optimization module to pre-prune the new prediction model E-XGBoost for each round.

[0112] Step 4.6: Use the prediction results of the E-XGBoost prediction model for gas pipelines after each round of pruning as the target variable for the next round.

[0113] The pruning optimization module is invoked to perform pre-pruning on the newly constructed weak learner; the objective function value of the Kth round is calculated, and the weights of the new weak learner are adjusted. Its prediction result is weighted and combined with the prediction results of the weak learners in the previous K-1 rounds to obtain the total prediction result of the model in the Kth round; the sample residual is recalculated based on the total prediction result of the Kth round and the true label, and used as the target variable for the K+1th round of training. The above steps are repeated until the training of the weak learner for the max_depth round is completed.

[0114] Step 4.7: When the preset number of rounds K is reached, the trained target prediction model E-XGBoost is obtained.

[0115] Based on the foregoing embodiments, before performing step S110, the method further includes:

[0116] Step 5.1: Evaluate the performance of the trained target prediction model E-XGBoost based on the test set, and optimize the parameters of the trained target prediction model E-XGBoost based on the evaluation results.

[0117] Here, the trained E-XGBoost model is evaluated using a test set, and MAE, MSE, and other parameters are calculated. Evaluation metrics; based on the evaluation results, continuously adjust the model parameters to improve the model's predictive performance:

[0118]

[0119]

[0120]

[0121] It's understandable that MSE (Mean Squared Error) is a regression evaluation metric, which doesn't have an absolute standard range and needs to be judged based on the specific business scenario. MAE (Mean Absolute Error) is another regression evaluation metric, ranging from [0, +∞). It equals 0 when the predicted value perfectly matches the actual value, i.e., a perfect model; the larger the error, the larger this value. (R-Square, coefficient of determination): A regression evaluation index, ranging from [0,1]. Generally, the larger the value, the better the model fit.

[0122] Step 5.2: Update the model parameters of the trained target prediction model E-XGBoost based on the training data samples at the current time.

[0123] Here, cross-validation and grid search methods can also be used to optimize the model hyperparameters, including the number of weak learners, the initial value of the weight parameter α, max_depth, min_gain_threshold, until the model... ≥90%; Model parameters are continuously trained using a constant stream of real-time data;

[0124] After testing, on the existing dataset, and by adjusting the parameters for different application scenarios, the results show that... All can achieve a success rate of over 90%, meeting the requirements for integrated deployment. This invention can be integrated into a unified urban lifeline digital construction platform, achieving access control, data synchronization, and automatic data recovery functions through unified platform management and scheduling.

[0125] This invention accesses real-time multi-source data from urban gas pipelines, performs the preprocessing and fusion operations described in the previous embodiments on the real-time data to obtain real-time training data samples, and then continuously updates the model parameters using the real-time training data samples. The update process is performed during model runtime without system downtime. The prediction model is then periodically evaluated to verify the performance of the updated model and ensure that the model adapts to changes in data distribution.

[0126] Step S110: Based on the trained target prediction model E-XGBoost, predict the risk outcome of the gas pipeline.

[0127] The evaluated, optimized, and automatically updated E-XGBoost model is integrated into a unified digital construction platform for urban lifelines. The platform enables access control, data synchronization, and automatic data recovery for the model. Based on the integrated model, multi-source fusion data of the pipeline segment to be predicted is input, and the risk prediction results for that segment are output. The risk prediction results are used to assist managers in formulating preventive maintenance plans and precise inspection schemes.

[0128] For the city's lifeline digital construction platform, users can view the engine's configuration status through the system platform interface; based on the engine's monitoring of the gas pipeline's risk status, dispatch commands are issued to the engine according to the corresponding risk requirements; real-time data obtained from the data interface connected to the engine automatically updates the engine's configuration status; and an intelligent early warning system is introduced to monitor system status and performance. The system can automatically identify potential problems, such as pipeline burst risk, collapse risk, high temperature and high pressure conditions, and trigger corresponding early warnings. The early warning system uses real-time data analysis to detect anomalies. This includes analysis of performance indicators, system events, and safety logs, as well as comparison with historical data. System administrators can customize early warning rules to meet specific needs. This allows for the development of appropriate early warning strategies based on different application scenarios and environments. Access control measures can also be introduced to ensure that only authorized users can access the configuration engine and early warning system. In scenarios involving module plugging / unplugging or abnormalities, missing data blocks can be automatically loaded according to the load situation to achieve data balancing, high availability, and integrity. The engine and early warning system support automatic recovery functions to recover as quickly as possible after system failure or data loss.

[0129] As an optional embodiment, for a long gas pipeline, a sensor is installed at regular intervals to monitor various data indicators of the gas pipeline. When a device is offline and cannot be put back online in time, the algorithm of this invention can be used to train a learning model to predict and infer the data value at that location, so as to assist managers in making decisions. When all sensor devices are online and working, the algorithm of this invention can be used to train a learning model to predict and infer the data value at a certain location, and compare and judge whether the device at that location is working properly, so as to assist managers in accurate inspection and reduce maintenance costs.

[0130] For urban drainage scenarios, this invention can learn from and train multi-source data, such as atmospheric water vapor content, precipitation, temperature, humidity, and other weather and environmental indicators, as well as surface monitoring information indicators such as reservoir storage, vegetation water content, and surface evapotranspiration, to predict groundwater flow and other information. This helps in the construction of urban water lifelines, providing scientific decision-making suggestions and reasonable scheduling schemes. Based on accurate risk prediction results, developing scientific preventive maintenance plans is an important means to improve the safety management of gas pipelines. Preventive maintenance can prioritize high-risk areas, optimize maintenance resource allocation, reduce operating costs, and improve efficiency. Real-time monitoring and automatic early warning can promptly detect potential risks, reduce the probability of accidents, and ensure urban public safety.

[0131] The urban gas pipeline risk prediction method provided in this invention combines multi-source data comprehensive analysis, automated parameter optimization, and real-time monitoring and early warning technologies, significantly improving the accuracy and timeliness of risk prediction. Through scientific preventive maintenance plans and optimized resource allocation, this algorithm can effectively reduce the accident rate, improve the efficiency and safety of gas pipeline management, and provide reliable technical support for urban digital construction.

[0132] In a preferred embodiment of practical application, preprocessing operations such as cleaning and feature extraction are performed on multi-source real-time data collected from gas pipelines to obtain multiple target features that have a key impact on the prediction model, so that subsequent steps can build the prediction model based on these target features. Then, these target features are aligned and fused according to time scale to obtain training data samples for the prediction model. An E-XGBoost prediction model for predicting the operating status and fault risk of gas pipelines is established. Each node of the decision tree in the E-XGBoost prediction model is split into three child nodes. The prediction model is then trained based on the aforementioned training data samples, as well as the first-order gradient reflecting the trend of prediction error and the second-order gradient reflecting the curvature of prediction error, to obtain the trained target prediction model E-XGBoost. Based on this target prediction model E-XGBoost, accurate prediction of gas pipeline risks can be achieved.

[0133] It is important to emphasize that E-XGBoost has made the following improvements based on XGBoost:

[0134] Ternary tree structure: Currently, XGBoost uses a binary tree (each node has two child nodes). Introducing a ternary tree (each node has three child nodes) can increase the branch depth of the tree, thereby improving the expressive power of the decision tree and capturing richer feature combinations.

[0135] Weighted Residual Enhancement: By weighting the residuals, we can focus more strongly on those samples that contribute significantly to the model's predictions. Important samples are assigned larger weights, which accelerates the model's learning process for these important samples.

[0136] Introducing the second gradient: XGBoost currently uses the first gradient (i.e., the derivative of the loss function) to calculate the residuals, while the second gradient (i.e., the second derivative of the loss function) can provide more information about the shape of the loss function, which helps to update the model more accurately.

[0137] Pruning algorithm optimization: Pruning in XGBoost controls tree complexity through pre-pruning (limiting the tree depth during tree generation) and post-pruning (removing unnecessary branches through traversal after tree generation). Further optimization of the pruning algorithm can improve model efficiency and avoid overfitting.

[0138] In some embodiments, such as Figure 2 As shown, an embodiment of the present invention provides a risk prediction device for urban gas pipelines, comprising:

[0139] The preprocessing module collects multi-source real-time data from gas pipelines and preprocesses it to obtain multiple target features for the prediction model E-XGBoost.

[0140] The fusion module aligns and fuses the multiple target features according to their time scales to obtain fused training data samples.

[0141] A module is established to build a prediction model E-XGBoost for predicting the operating status and failure risk of gas pipelines; wherein, each node of the decision tree in the prediction model E-XGBoost is split into three sub-nodes;

[0142] The training module trains the prediction model E-XGBoost based on the fused training data samples, the first-order gradient reflecting the trend of prediction error, and the second-order gradient of curvature reflecting the change of prediction error, to obtain the trained target prediction model E-XGBoost.

[0143] The prediction module, based on the trained target prediction model E-XGBoost, predicts the risk outcome of the gas pipeline.

[0144] Furthermore, the preprocessing module is specifically used to perform preset cleaning operations on multi-source real-time data to obtain target data that meets preset quality requirements; extract initial features from the target data, input the initial features into a preset model, evaluate the initial features using machine learning algorithms and the preset model; and determine multiple target features whose feature importance meets the requirements from the initial features based on the weight coefficients corresponding to each initial feature in the evaluation results.

[0145] Furthermore, the fusion module is specifically used to standardize and transform multiple target features from different data sources to obtain target feature data of the same numerical magnitude; based on the collection timestamps and pipe segment IDs of the gas pipelines corresponding to the target feature data, synchronously align the time scales of the target feature data; and fuse the time-scale aligned target feature data to obtain fused training data samples.

[0146] Furthermore, a module is established, specifically for constructing a tritree node structure based on decision tree node information; wherein, the decision tree node information includes splitting features, three splitting thresholds, and predicted values ​​of the left child node, middle child node, right child node, and leaf node, and the three splitting thresholds are the feature values ​​of three consecutive deduplicated and sorted target features; a weighted residual calculation module for dynamically adjusting sample weights is constructed based on the weighted residual of each training data sample; a second-order gradient calculation module for outputting the first-order gradient reflecting the error change trend and the second-order gradient reflecting the error change curvature is constructed based on the loss function value of each training data sample; a pruning optimization module including pre-pruning and post-pruning is constructed based on the node splitting gain and the predicted value of the leaf node; integrating the tritree node structure, the weighted residual calculation module, the second-order gradient calculation module, and the pruning optimization module, a prediction model E-XGBoost for predicting the operating status and fault risk of gas pipelines is constructed.

[0147] Furthermore, the training module is specifically used to: input the fused training data samples into the prediction model; calculate the first and second gradients of the loss function value of the prediction model, and the first sample residual corresponding to the first gradient; use the first sample residual as the target variable for the next round; call the second gradient calculation module to obtain the first and second gradients for each round; call the weighted residual calculation module to update the weight coefficients of the training data samples for each round and calculate the weighted residual; and traverse each target feature in the training data samples in each round, and sort the feature values ​​of each target feature by removing duplicates. After screening candidate thresholds, the splitting gain is calculated by combining the first and second gradients in each round. The target feature with the largest splitting gain and the feature value combination are selected as the optimal splitting scheme to construct a new prediction model E-XGBoost for each round. The pruning optimization module is called to pre-prune the new prediction model E-XGBoost for each round. The prediction result of the pruned prediction model E-XGBoost for gas pipelines in each round and the second sample residual of the real label are used as the target variable for the next round. When the preset number of rounds is reached, the trained target prediction model E-XGBoost is obtained.

[0148] Furthermore, before the step of predicting the risk outcome of the gas pipeline based on the trained target prediction model E-XGBoost, the device is also used to evaluate the performance of the trained target prediction model E-XGBoost according to a test set, and optimize the parameters of the trained target prediction model E-XGBoost based on the evaluation results.

[0149] Furthermore, before the step of predicting the risk outcome of the gas pipeline based on the trained target prediction model E-XGBoost, the device is also used to update the model parameters of the trained target prediction model E-XGBoost based on the training data samples at the current time.

[0150] This invention improves the accuracy of identifying potential fault points and hazardous areas through comprehensive analysis of multi-source data, reducing false alarms and missed alarms, and enhancing the accuracy of risk identification. It enables the development of scientific preventative maintenance plans, prioritizing high-risk areas, optimizing resource allocation, reducing maintenance costs, improving management efficiency, and optimizing preventative maintenance. It also allows for real-time monitoring of gas pipeline status, timely warnings of potential risks, and data-driven decision support, reducing the probability of accidents. Simultaneously, it simplifies management processes, reduces manual intervention and human error, lowers system downtime, and improves data availability and system stability. Furthermore, through accurate risk prediction and timely maintenance measures, it reduces the frequency of gas pipeline accidents, ensuring urban public safety and the safety of residents' lives and property. In addition, it utilizes advanced machine learning technology to promote the intelligent and digital management of urban infrastructure, improve overall safety management, and provide technical support for the digital construction of urban lifelines.

[0151] The present invention provides an embodiment of an electronic device. In this embodiment, the electronic device may be, but is not limited to, a personal computer (PC), a laptop computer, a monitoring device, a server, or other computer device with analysis and processing capabilities.

[0152] As an exemplary embodiment, see [reference]. Figure 3 The electronic device 110 includes a communication interface 111, a processor 112, a memory 113, and a bus 114. The processor 112, the communication interface 111, and the memory 113 are connected via the bus 114. The memory 113 is used to store a computer program that supports the processor 112 in executing the above-described method. The processor 112 is configured to execute the program stored in the memory 113.

[0153] The machine-readable storage medium mentioned in this article can be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as executable instructions, data, etc. For example, machine-readable storage media can be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drives (such as hard disk drives), any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or combinations thereof.

[0154] Non-volatile media can be non-volatile memory, flash memory, storage drives (such as hard disk drives), any type of storage disk (such as optical discs, DVDs, etc.), or similar non-volatile storage media, or combinations thereof.

[0155] It is understood that the specific operation methods of each functional module in this embodiment can be referred to the detailed description of the corresponding steps in the above method embodiment, and will not be repeated here.

[0156] The computer-readable storage medium provided in the embodiments of the present invention stores a computer program. When the computer program code is executed, it can implement the method described in any of the above embodiments. For specific implementation, please refer to the method embodiments, which will not be repeated here.

[0157] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0158] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.

[0159] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0160] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit them. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the scope of the technology disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention.

Claims

1. A method for predicting the risks of urban gas pipelines, characterized in that, include: Multi-source real-time data from gas pipelines are collected and preprocessed to obtain multiple target features for the prediction model EXGBoost. The multiple target features are aligned and fused according to time scale to obtain fused training data samples; An E-XGBoost predictive model for predicting the operating status and failure risk of gas pipelines is established; wherein each node of the decision tree in the E-XGBoost predictive model is split into three child nodes. Based on the fused training data samples, the first-order gradient reflecting the trend of prediction error and the second-order gradient of curvature reflecting the change of prediction error are used to train the prediction model E-XGBoost, and the trained target prediction model E-XGBoost is obtained. Based on the trained target prediction model EXGBoost, the risk outcome of the gas pipeline is predicted. The steps for developing the predictive model EXGBoost for forecasting the operating status and failure risk of gas pipelines include: A ternary tree node structure is constructed based on decision tree node information; wherein, the decision tree node information includes splitting features, three splitting thresholds, and predicted values ​​of the left child node, middle child node, right child node, and leaf node, and the three splitting thresholds are the feature values ​​of three consecutive deduplicated and sorted target features. Based on the weighted residual of each training data sample, a weighted residual calculation module that dynamically adjusts the sample weights is constructed. Based on the loss function value of each training data sample, a module for calculating the first-order gradient that reflects the trend of error change and the second-order gradient that reflects the curvature of error change is constructed. Based on node splitting gain and leaf node prediction values, a pruning optimization module including pre-pruning and post-pruning is constructed. By integrating the ternary tree node structure, the weighted residual calculation module, the second-order gradient calculation module, and the pruning optimization module, a prediction model E-XGBoost is constructed to predict the operating status and fault risk of gas pipelines.

2. The method according to claim 1, characterized in that, The steps for collecting multi-source real-time data from gas pipelines and preprocessing it to obtain multiple target features for building the prediction model EXGBoost include: Multi-source real-time data is cleaned using preset methods to obtain target data that meets preset quality requirements. Initial features are extracted from the target data, the initial features are input into a preset model, and the initial features are evaluated using a machine learning algorithm and the preset model. Based on the weight coefficients corresponding to each initial feature in the evaluation results, multiple target features whose feature importance meets the requirements are determined from the initial features.

3. The method according to claim 1, characterized in that, The steps of aligning and fusing the multiple target features over time to obtain fused training data samples include: Multiple target features from different data sources are standardized and transformed to obtain target feature data of the same numerical order of magnitude; Based on the collection timestamps corresponding to the target feature data and the pipe segment IDs of the gas pipeline, the time scales of the target feature data are synchronized and aligned. The time-scale aligned target feature data are fused to obtain fused training data samples.

4. The method according to claim 1, characterized in that, Based on the fused training data samples, the steps of training the prediction model E-XGBoost to obtain the trained target prediction model E-XGBoost include: (1) The first gradient reflecting the trend of prediction error change and the second gradient reflecting the curvature of prediction error change. The fused training data samples are input into the prediction model, and the first and second gradients of the loss function value of the prediction model are calculated, as well as the first sample residual corresponding to the first gradient. Use the residual of the first sample as the target variable for the next round; The second-order gradient calculation module is called to obtain the first-order and second-order gradients for each round, and the weighted residual calculation module is called to update the weight coefficients of the training data samples for each round and calculate the weighted residuals. In each round, each target feature in the training data sample is traversed. After deduplication and sorting of the feature values ​​of each target feature, candidate thresholds are selected. The split gain is calculated by combining the first-order gradient and the second-order gradient in each round. The target feature with the largest split gain and the combination of feature values ​​are selected as the optimal split scheme to construct a new prediction model E-XGBoost for each round. The pruning optimization module is invoked to pre-prune the new prediction model E-XGBoost for each round; The prediction results of the E-XGBoost model for gas pipelines after each round of pruning are used as the second sample residuals of the true labels as the target variable for the next round. When the preset number of rounds is reached, the trained target prediction model E-XGBoost is obtained.

5. The method according to claim 1, characterized in that, Prior to the step of predicting the risk outcome of a gas pipeline based on the trained target prediction model EXGBoost, the method further includes: The trained target prediction model E-XGBoost is evaluated based on the test set, and the parameters of the trained target prediction model E-XGBoost are optimized based on the evaluation results.

6. The method according to claim 5, characterized in that... Prior to the step of predicting the risk outcome of a gas pipeline based on the trained target prediction model EXGBoost, the method further includes: The model parameters of the trained target prediction model E-XGBoost are updated based on the training data samples at the current moment.

7. A risk prediction device for urban gas pipelines, characterized in that, include: The preprocessing module collects multi-source real-time data from gas pipelines and preprocesses it to obtain multiple target features for the prediction model E-XGBoost. The fusion module aligns and fuses the multiple target features according to their time scales to obtain fused training data samples. A module is established to build a prediction model E-XGBoost for predicting the operating status and failure risk of gas pipelines; wherein, each node of the decision tree in the prediction model E-XGBoost is split into three sub-nodes; The training module trains the prediction model E-XGBoost based on the fused training data samples, the first-order gradient reflecting the trend of prediction error, and the second-order gradient of curvature reflecting the change of prediction error, to obtain the trained target prediction model E-XGBoost. The prediction module, based on the trained target prediction model E-XGBoost, predicts the risk outcome of the gas pipeline; The module is also used to construct a tritree node structure based on decision tree node information. The decision tree node information includes splitting features, three splitting thresholds, and predicted values ​​for the left, middle, right, and leaf nodes. The three splitting thresholds are the feature values ​​of three consecutive deduplicated and sorted target features. A weighted residual calculation module is constructed to dynamically adjust sample weights based on the weighted residual of each training data sample. A second-order gradient calculation module is constructed to output the first-order gradient reflecting the error change trend and the second-order gradient reflecting the error change curvature based on the loss function value of each training data sample. A pruning optimization module is constructed, including pre-pruning and post-pruning, based on node splitting gain and leaf node predicted values. Integrating the tritree node structure, the weighted residual calculation module, the second-order gradient calculation module, and the pruning optimization module, a prediction model, E-XGBoost, is constructed to predict the operating status and fault risk of gas pipelines.

8. An electronic device, characterized in that, It includes a memory, a processor, and a program stored in the memory and capable of running on the processor, wherein the processor executes the program to implement the method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The readable storage medium stores a computer program that, when executed, implements the method described in any one of claims 1-6.

Citation Information

Patent Citations

  • Survival prediction method combining XGBoost and Elastic Net-cox algorithms

    CN116825342A

  • Time sequence prediction method for calculating feature weight by fusing XGBoost

    CN116881854A