Oil and gas pipeline corrosion rate prediction method and system based on interpretable ensemble learning
By using an interpretable integrated learning method and SHAP value analysis in oil and gas pipeline corrosion prediction, the problem of insufficient model interpretability in the existing technology is solved, the prediction accuracy and interpretability are improved, and it provides information for the safety assessment of oil and gas pipelines. Scientific basis.
Patent Information
- Application Number
- CN202410839358.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-24
AI Technical Summary
Existing oil and gas pipeline corrosion prediction methods focus on model prediction accuracy but ignore the interpretability of the model, making it difficult to effectively interpret and verify the prediction results, limiting its application in engineering practice.
The interpretable integrated learning method is used to build an integrated learning model through feature engineering and visual analysis of SHAP values, select the optimal model for corrosion rate prediction, and analyze the impact of different input parameters on the corrosion rate through SHAP values.
The goodness of fit of the model is improved from 0.699 to 0.933, which improves the performance by about 23%. It provides an intuitive and comprehensive perspective on the impact of corrosion factors, helps understand the model prediction logic, and provides useful information for pipeline maintenance and maintenance. Targeted suggestions.
Smart Images

Figure CN118690910A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of oil and gas pipeline safety assessment, and in particular relates to an oil and gas pipeline corrosion rate prediction method and system based on explainable ensemble learning. Background Art
[0002] With the continuous growth of energy demand, oil and gas pipelines are important arteries for energy transportation, and their safe operation plays a vital role in ensuring energy supply. During operation, oil and gas pipelines are prone to corrosion due to the influence of various internal and external factors (such as chemical corrosion, microbial corrosion, wear corrosion, etc.), which not only increases maintenance costs, but may also cause leakage or even explosion accidents, posing a serious threat to the environment and human safety.
[0003] At present, oil and gas pipeline corrosion inspection technologies mainly include direct inspection methods and indirect inspection methods. Direct inspection methods, such as ultrasonic inspection and X-ray inspection, have intuitive inspection results, but often require the pipeline to be shut down or partially shut down, and the inspection cost is high. Indirect inspection methods mainly rely on the collection and analysis of corrosion data, and predict the corrosion rate and remaining life by establishing a mathematical model. However, the above-mentioned physical model-based method relies on empirical knowledge and is affected by subjective factors, resulting in low model prediction accuracy.
[0004] In recent years, machine learning technology has been widely used in oil and gas pipeline corrosion prediction, especially ensemble learning methods, which have attracted attention due to their powerful prediction capabilities. However, existing ensemble learning methods often focus on the prediction accuracy of the model, but ignore the interpretability of the model, which may make it difficult to effectively interpret and verify the prediction results in practical applications, limiting its application in engineering practice. Summary of the invention
[0005] In order to solve the problems existing in the prior art, the present invention provides a method for predicting the corrosion rate of oil and gas pipelines based on interpretable ensemble learning, constructs an ensemble learning model, and adopts an interpretable method to realize rapid prediction of the corrosion rate of oil and gas pipelines and analysis of corrosion influencing factors, thereby providing guidance for the safety assessment of oil and gas pipelines.
[0006] In order to achieve the above object, the technical solution adopted by the present invention is: a method for predicting the corrosion rate of oil and gas pipelines based on interpretable ensemble learning, comprising the following steps:
[0007] Obtain oil and gas pipeline corrosion data from field surveys;
[0008] Performing feature engineering on the oil and gas pipeline corrosion data, removing features with a correlation with a corrosion rate less than a set value, and obtaining feature-screened data;
[0009] An integrated learning model is constructed based on the above-screened data, and the evaluation performance of different models is compared to select the optimal model as the corrosion rate prediction model;
[0010] The optimal model selected above is used to test the test data set to predict the corrosion rate of oil and gas pipelines;
[0011] Based on the extra tree regression model, an interpretable method is used to visualize the impact of model input features on the corrosion rate, and the impact of different input parameters on the corrosion rate is analyzed.
[0012] Furthermore, the oil and gas pipeline corrosion data includes pipeline length, temperature, liquid retention, carbon dioxide partial pressure, liquid flow rate, wall shear stress, pH value, and corrosion rate value inside the pipeline.
[0013] Furthermore, the Pearson correlation coefficient was used to perform feature correlation analysis on the oil and gas pipeline corrosion data to obtain the screened data.
[0014] Furthermore, an integrated learning model is constructed based on the above-screened data, and the evaluation performance of different models is compared. The optimal model is selected as the corrosion rate prediction model, including:
[0015] Mean absolute error, mean square error, root mean square error, and goodness of fit R 2 The evaluation performance of six models including random forest (RF), AdaBoost, gradient boosted regression tree, XGBoost, CatBoost and extra tree regression model on oil and gas pipeline data was evaluated, and the extra tree regression model was used as the final corrosion rate prediction model.
[0016] Furthermore, based on the extra tree regression model, the interpretable method SHAP value is used to visualize the impact of model input features on the corrosion rate, and the impact of different input parameters on the corrosion rate is analyzed.
[0017] Furthermore, the SHAP value is used to quantify the impact of input features on model output; when SHAP is negative, the feature has a negative impact on the prediction, the model output value is reduced, and a lower internal erosion rate is resulted; when SHAP is positive, the feature has a positive impact on the prediction, resulting in a higher internal erosion rate.
[0018] With the same technical concept as the method, the present invention also provides an oil and gas pipeline corrosion rate prediction system based on interpretable ensemble learning, a data acquisition module, a feature screening module, an optimization module, a prediction module and an evaluation module;
[0019] The data acquisition module is used to obtain the oil and gas pipeline corrosion data from on-site surveys;
[0020] The feature screening module is used to perform feature engineering on the oil and gas pipeline corrosion data, remove features with a correlation with a corrosion rate less than a set value, and obtain feature-screened data;
[0021] The optimization module builds an integrated learning model based on the above-screened data, compares the evaluation performance of different models, and selects the optimal model as the corrosion rate prediction model;
[0022] The prediction module tests the test data set based on the optimal model selected above to predict the corrosion rate of oil and gas pipelines;
[0023] Based on the above integrated learning model, the evaluation module uses an interpretable method to visualize the impact of the model input features on the corrosion rate and obtain the impact of different input parameters on the corrosion rate.
[0024] Furthermore, the SHAP value in the evaluation module is used to quantify the impact of input features on model output; when SHAP is a negative value, the feature has a negative impact on the prediction, the model output value is reduced, and a lower internal corrosion rate is resulted; when the SHAP value is positive, the feature has a positive impact on the prediction, and a higher internal corrosion rate is resulted.
[0025] The present invention can also provide a computer device, including a processor and a memory, the memory is used to store a computer executable program, the processor reads the computer executable program from the memory and executes it, and when the processor executes the computer executable program, the oil and gas pipeline corrosion rate prediction method based on interpretable ensemble learning described in the present invention can be implemented.
[0026] At the same time, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the method for predicting the corrosion rate of an oil and gas pipeline based on interpretable ensemble learning of the present invention can be implemented.
[0027] Compared with the prior art, the present invention has at least the following beneficial effects: after feature engineering screening, the goodness of fit of the ensemble learning model of the present invention is improved from 0.699 to 0.933, and the model performance is improved by about 23%; the ensemble learning model is used to efficiently predict the corrosion rate of oil and gas pipelines. Even in the case of a small sample size, the model shows excellent performance, with a goodness of fit of up to 0.93, which fully proves the accuracy and reliability of its prediction. In order to deeply understand the impact of various corrosion factors on the corrosion rate of pipelines, the SHAP interpretability method is further introduced; SHAP provides an intuitive and comprehensive perspective to explore the contribution of different features to the corrosion rate; through SHAP analysis, we can clearly see how each corrosion factor affects the corrosion rate of pipelines, which not only helps us understand the logic behind the model prediction, but also provides targeted suggestions for the maintenance and maintenance of pipelines; it helps to deeply explore the intrinsic relationship between pipeline corrosion influencing factors and corrosion rate, and provide guidance for the study of corrosion mechanism; in general, the ensemble learning model not only performs well in predicting the corrosion rate of oil and gas pipelines, but also, by combining the SHAP method, can more deeply understand the specific impact of various factors on the corrosion rate. It provides strong data support and scientific basis for future pipeline maintenance and management. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 This is a framework diagram of the method of the present invention.
[0029] Figure 2 is the relative importance score of the 8 input features.
[0030] Figure 3 Comparison of the prediction results of 6 different ensemble learning models on the training set and test set.
[0031] Figure 4 is the SHAP value of all samples.
[0032] Figure 5 is the average SHAP value of the input features. DETAILED DESCRIPTION
[0033] The embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and a specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0034] The present invention provides an oil and gas pipeline corrosion rate prediction method based on explainable ensemble learning. Taking submarine oil and gas pipelines as an example, corrosion factor data related to the corrosion rate in the oil and gas pipelines are collected.
[0035] like Figure 1As shown, the present invention provides a method for predicting the corrosion rate of oil and gas pipelines based on interpretable ensemble learning, comprising the following steps:
[0036] Step 1: Collect existing literature data on submarine oil and gas pipeline corrosion factors and corrosion rates. The data set comes from a submarine oil and gas pipeline. The pipeline is 5.5 kilometers long and was put into operation in June 2009. The design life of the pipeline is 20 years. The inner pipe material is X65 steel and the outer pipe material is X56 steel. The inner diameter is DN200 and the outer diameter is DN300. 2 S content is greater than 20ppm, CO 2 The content is greater than 10%. The present invention has collected 60 sets of data in total, and the factors affecting the corrosion rate in the pipeline include the following eight aspects: 1) temperature, TM, ℃; 2) liquid retention, HOL; 3) pressure, PT, kPa; 4) carbon dioxide partial pressure, PCO2, kPa; 5) liquid flow rate, UL, m / s; 6) wall shear stress (liquid phase) TAUWWT, Pa; 7) wall shear stress (gas phase) TAUWG, Pa; 8) pH value. The corrosion rate of the pipeline under different conditions is determined by a professional organization.
[0037] Step 2: Perform feature engineering on the collected data, remove features with little correlation with the corrosion rate, and obtain data after feature screening. Feature engineering is used to identify and screen out input parameters that have a greater impact on the corrosion rate. The present invention uses the "SelectFromModel" function built into the Scikit-learn python module, uses a meta-transformer to select features according to the importance weights on the training set, and performs preliminary screening on the selected features. Figure 2 As shown in the figure, temperature (T) has the greatest impact on the corrosion rate, with an importance of more than 35%. This shows that this feature is extremely important for the internal corrosion rate of oil and gas pipelines. Pipeline pressure (PT) and carbon dioxide partial pressure (PCO 2 ) are the second and third most important features, with relative correlations of 22% and 21%, respectively. These results are consistent with basic experience that temperature, pipeline pressure and carbon dioxide partial pressure play a key role in the initiation, acceleration or reduction of internal corrosion in oil and gas pipelines. In addition, it can be seen from the figure that the importance of wall shear stress (gas phase) TAUWG is 8.5%, while the importance of other variables is lower, all below 5%. Finally, according to the degree of importance of different factors in the figure on corrosion, the present invention selects three key features of temperature, pipeline pressure and PCO2 partial pressure as input features for machine learning model training.
[0038] Step 3: After the above feature engineering, the filtered features are used for machine learning modeling. In order to select the optimal model, the present invention compares the evaluation performance of 6 different ensemble learning models on the oil and gas pipeline dataset. The evaluation results are as follows: Figure 3As shown. Among them, the six ensemble learning models are random forest (RF), AdaBoost, gradient boosted regression tree (GBR), XGBoost, CatBoost and extra tree regression model (ExtraTreeRegression), referred to as ETR. The blue points in the figure represent the training set data, and the red points represent the test set data. The horizontal axis is the experimental value of the internal corrosion rate of the oil and gas pipeline, and the vertical axis is the predicted value of the internal corrosion rate. The closer the data point is to the diagonal line, the closer the model prediction value is to the true value. In order to further quantitatively evaluate the prediction performance of different models on the training set and test set, the present invention adopts four statistical indicators: mean absolute error (MAE), mean square error (MSE), root mean square error (RMSE) and goodness of fit R 2 The smaller or closer to 0 the mean absolute error (MAE), mean square error (MSE), and root mean square error (RMSE) are, the better the R 2 The closer it is to 1, the better the prediction performance of the model. As can be seen from the figure, after feature engineering screening, compared with the other five models, the ETR model developed by the present invention has a higher goodness of fit on both the training set and the unknown test set, and the model prediction performance and generalization ability are the best.
[0039] Step 4. Based on the above-mentioned preferred integrated learning model ETR, an interpretable method is used to visualize the impact of the model input features on the corrosion rate, and the impact of different input parameters on the corrosion rate is analyzed. Although the existing machine learning models can obtain accurate prediction results, there is no in-depth analysis of the factors affecting the prediction results. Previous machine learning prediction models are usually unable to clearly explain how these prediction results are obtained, which makes the model difficult to understand. Exploring how different input features affect the overall prediction results is the primary task of understanding the model. In order to analyze the key factors affecting the corrosion rate, the present invention uses a post-interpretable method SHAP to explain the ETR model's prediction of the total data set, and the SHAP value is used to quantify the impact of input features on the model output. A negative SHAP value means that the feature has a negative impact on the prediction, resulting in a decrease in the model output value. On the contrary, if the SHAP value is positive, it means that there is a positive impact, which is more likely to lead to a higher internal corrosion rate.
[0040] Figure 4The overall distribution of SHAP values for all key feature samples is described, with colors representing feature values that have been scaled to the same range. Blue and red represent lower and higher feature values, respectively. As can be seen from the figure, temperature T has a significant effect on the internal corrosion rate, and lower temperature T values generally show positive SHAP, indicating that lower temperature T is more likely to increase the internal corrosion rate of oil and gas pipelines. Conversely, higher temperature T reduces the internal corrosion rate. Other features such as wall shear stress (liquid phase) and HOL (liquid retention) have less overall effect on the internal corrosion rate.
[0041] In order to describe the importance of input features, the present invention uses the average SHAP value for analysis. Figure 5 As shown in the figure, temperature is of the highest importance and has the highest average absolute SHAP value, which means that the average temperature T of all samples in the ExtraTreeRegression (ETR) model can increase the internal corrosion rate of oil and gas pipelines. The second is PT, with an average SHAP value of 0.025. PCO2, UL and PH are the other three main features, with SHAP values of 0.024, 0.022 and 0.021, respectively. Overall, T, PT and PCO2 are the three most important features affecting the internal corrosion rate of oil and gas pipelines, which is basically consistent with the results discussed in step 2.
[0042] With the same technical concept as the method, the present invention also provides an oil and gas pipeline corrosion rate prediction system based on interpretable ensemble learning, a data acquisition module, a feature screening module, an optimization module, a prediction module and an evaluation module;
[0043] The data acquisition module is used to obtain the oil and gas pipeline corrosion data from on-site surveys;
[0044] The feature screening module is used to perform feature engineering on the oil and gas pipeline corrosion data, remove features with a correlation with a corrosion rate less than a set value, and obtain feature-screened data;
[0045] The optimization module builds an integrated learning model based on the above-screened data, compares the evaluation performance of different models, and selects the optimal model as the corrosion rate prediction model;
[0046] The prediction module tests the test data set based on the optimal model selected above to predict the corrosion rate of oil and gas pipelines;
[0047] Based on the above integrated learning model, the evaluation module uses an interpretable method to visualize the impact of the model input features on the corrosion rate and obtain the impact of different input parameters on the corrosion rate.
[0048] The present invention can also provide a computer device, including a processor and a memory, the memory is used to store a computer executable program, the processor reads the computer executable program from the memory and executes it, and when the processor executes the computer executable program, it can implement the oil and gas pipeline corrosion rate prediction method based on interpretable ensemble learning described in the present invention.
[0049] On the other hand, the present invention provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method for predicting oil and gas pipeline corrosion rate based on interpretable ensemble learning described in the present invention can be implemented.
[0050] The computer device may be a laptop computer, a desktop computer or a workstation.
[0051] The processor may be a central processing unit (CPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), or an off-the-shelf field programmable gate array (FPGA).
[0052] The memory of the present invention may be an internal storage unit of a laptop computer, a desktop computer or a workstation, such as a memory or a hard disk; or an external storage unit, such as a mobile hard disk or a flash memory card.
[0053] Computer-readable storage media may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer-readable storage media may include: read-only memory (ROM), random access memory (RAM), solid-state drive (SSD) or optical disk, etc. Among them, random access memory may include resistance random access memory (ReRAM) and dynamic random access memory (DRAM).
Claims
1. A method for predicting oil and gas pipeline corrosion rate based on interpretable ensemble learning, characterized in that: The following steps are involved: Obtain oil and gas pipeline corrosion data from field surveys; Performing feature engineering on the oil and gas pipeline corrosion data, removing features with a correlation with a corrosion rate less than a set value, and obtaining feature-screened data; An integrated learning model is constructed based on the above-screened data, and the evaluation performance of different models is compared to select the optimal model as the corrosion rate prediction model; The optimal model selected above is used to test the test data set to predict the corrosion rate of oil and gas pipelines; Based on the extra tree regression model, an interpretable method is used to visualize the impact of model input features on the corrosion rate, and the impact of different input parameters on the corrosion rate is analyzed.
2. According to claim 1, a method for predicting oil and gas pipeline corrosion rate based on interpretable ensemble learning is characterized in that: The oil and gas pipeline corrosion data include pipeline length, temperature, liquid retention, carbon dioxide partial pressure, liquid flow rate, wall shear stress, pH value, and corrosion rate value inside the pipeline.
3. According to claim 1, a method for predicting oil and gas pipeline corrosion rate based on interpretable ensemble learning is characterized in that: The Pearson correlation coefficient was used to perform characteristic correlation analysis on the oil and gas pipeline corrosion data to obtain the screened data.
4. According to claim 1, a method for predicting oil and gas pipeline corrosion rate based on interpretable ensemble learning is characterized in that: Based on the above screened data, an integrated learning model is constructed, and the evaluation performance of different models is compared. The optimal model is selected as the corrosion rate prediction model, including: Mean absolute error, mean square error, root mean square error, and goodness of fit R 2 The evaluation performance of six models including random forest, AdaBoost, gradient boosted regression tree, XGBoost, CatBoost and extra tree regression model on oil and gas pipeline data was evaluated, and the extra tree regression model was used as the final corrosion rate prediction model.
5. According to claim 1, a method for predicting oil and gas pipeline corrosion rate based on interpretable ensemble learning is characterized in that: It also includes an additional tree regression model, using the interpretable method SHAP value to visualize the impact of model input features on corrosion rate, and analyzing the impact of different input parameters on corrosion rate.
6. According to claim 5, a method for predicting oil and gas pipeline corrosion rate based on interpretable ensemble learning is characterized in that: The SHAP value is used to quantify the impact of input features on model output; when SHAP is negative, the feature has a negative impact on the prediction, the model output value is reduced, and the internal erosion rate is lower; when the SHAP value is positive, the feature has a positive impact on the prediction, resulting in a higher internal erosion rate.
7. An oil and gas pipeline corrosion rate prediction system based on interpretable ensemble learning, characterized in that: Data acquisition module, feature screening module, optimization module, prediction module and evaluation module; The data acquisition module is used to obtain the oil and gas pipeline corrosion data from on-site surveys; The feature screening module is used to perform feature engineering on the oil and gas pipeline corrosion data, remove features with a correlation with a corrosion rate less than a set value, and obtain feature-screened data; The optimization module builds an integrated learning model based on the above-screened data, compares the evaluation performance of different models, and selects the optimal model as the corrosion rate prediction model; The prediction module tests the test data set based on the optimal model selected above to predict the corrosion rate of oil and gas pipelines; Based on the above integrated learning model, the evaluation module uses an interpretable method to visualize the impact of the model input features on the corrosion rate and obtain the impact of different input parameters on the corrosion rate.
8. The oil and gas pipeline corrosion rate prediction system based on interpretable ensemble learning according to claim 7 is characterized in that: The SHAP value described in the evaluation module is used to quantify the impact of input features on model output; when SHAP is negative, the feature has a negative impact on the prediction, the model output value is reduced, and a lower internal corrosion rate is caused; when the SHAP value is positive, the feature has a positive impact on the prediction, resulting in a higher internal corrosion rate.
9. A computer device, characterized in that: The invention comprises a processor and a memory, wherein the memory is used to store a computer executable program, the processor reads the computer executable program from the memory and executes it, and when the processor executes the computer executable program, the method for predicting the corrosion rate of an oil and gas pipeline based on interpretable ensemble learning as described in any one of claims 1 to 8 can be implemented.
10. A computer-readable storage medium, characterized in that: A computer program is stored in a computer-readable storage medium. When the computer program is executed by a processor, the method for predicting the corrosion rate of an oil and gas pipeline based on interpretable ensemble learning as described in any one of claims 1 to 8 can be implemented.
Citation Information
Cited By
Prediction method for corrosion rate in natural gas pipeline
CN119202558A
A method for predicting corrosion rate in natural gas pipelines
CN119202558B
Water supply pipeline corrosion risk evaluation method based on multi-source data and time sequence prediction
CN120562319A
Water supply pipeline corrosion risk assessment method based on multi-source data and time series prediction
CN120562319B
Method and device for evaluating corrosion risk of steel structure building, electronic equipment and medium
CN121350809A
