A method for predicting carbon steel corrosion rate

Through the integrated model of random forest and BP neural network, the uncertainty problem of carbon steel corrosion rate prediction is solved, high-precision prediction under diverse environmental conditions is achieved, and the accuracy of the service life assessment of carbon steel structures is improved.

CN114121174BActive Publication Date: 2024-09-20WUHAN RES INST OF MATERIALS PROTECTION +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111373441.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-19
Publication Date
2024-09-20
Estimated Expiration
2041-11-19

AI Technical Summary

Technical Problem

It is difficult to effectively predict the corrosion rate of carbon steel with existing technology, especially under diverse and complex environmental conditions, making it difficult to evaluate the service life of carbon steel structures.

Method used

An integrated model based on random forest and BP neural network is used to carry out full-factor data mining through historically accumulated natural exposure test data of carbon steel atmospheric environment. Random forest is used for initial prediction and automatic extraction of important characteristic factors, and BP neural network is used for accurate Predicting carbon steel corrosion rates.

Benefits of technology

It improves the accuracy and stability of carbon steel corrosion rate prediction, avoids the defects of manually setting carbon steel corrosion factors and solidification mathematical models, and achieves fast and accurate corrosion rate prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114121174B
    Figure CN114121174B
Patent Text Reader

Abstract

The present invention discloses a method for predicting the corrosion rate of carbon steel. The method comprises the following steps: constructing the initial training and testing samples of the model from the given historically accumulated natural environment corrosion data; using the genetic algorithm to tune the two parameters of the number of base classifiers and the maximum tree depth in the random forest, thereby modeling and saving the optimal random forest prediction model; using the corrosion prediction results of the initial data samples from the random forest and the selection of important features to construct the training and testing samples of the BP neural network model; initializing the BP neural network model; using the given training and testing samples to optimize, train and test the BP neural network to obtain the optimal neural network prediction model; inputting the generation prediction data into the integrated random forest and BP neural network prediction model to obtain the carbon steel corrosion prediction result. The present invention solves the problem that the traditional prediction results are not stable enough and have low precision, and improves the robustness and prediction accuracy of the prediction of the carbon steel corrosion rate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of natural environment corrosion of metal materials, relates to a carbon steel corrosion evaluation technology, and specifically relates to a carbon steel corrosion rate prediction method based on a random forest and BP neural network integrated model. Background Art

[0002] Carbon steel is widely used in bridges, vehicles, ships, buildings, pressure vessels, special equipment and other fields. Its environmental adaptability has an important safety impact on people's production and life. During service, carbon steel is continuously subjected to the combined effects of environmental factors, and its corrosion is difficult to avoid. The corrosion rate is seriously dependent on the type and conditions of the service environment. As a structural material, carbon steel is widely used in almost all climate types in the world. The service areas are widely distributed, the environmental types are diverse, and the climate is complex and changeable. Since these environmental factors are often uncertain, it is difficult to give a definite expression to describe the corrosion process of carbon steel, which makes it difficult to evaluate the service life of carbon steel structures.

[0003] Since the mid-nineteenth century, countries around the world have conducted extensive natural environment corrosion tests on materials around the world and accumulated a large amount of material corrosion data. In order to reveal the laws of material corrosion, analyze the corrosion mechanism of materials, and predict material corrosion failure, researchers have conducted continuous research on the accumulated corrosion data and established power exponential models and dose response models. In recent years, with the rise of data mining technology, gray theory, neural networks, support vector machines, extreme learning machines, random forests, genetic algorithms and other methods have been used for material corrosion modeling and prediction.

[0004] The corrosion of carbon steel is closely related to the service environment. In order to further reveal the corrosion law of carbon steel in the natural atmospheric environment, the present invention conducts full-factor data mining through the historical accumulation of carbon steel atmospheric environment natural exposure test data. The data environmental factor items include the geographical information of the test point (longitude, latitude, altitude), meteorological factors (temperature, humidity, rainfall, total radiation, sunshine time, atmospheric pressure, wetting time), corrosive pollutant information (NO 2 , H 2 S. NH 3 , sulfation rate, sea salt particles, water-soluble natural precipitation, water-insoluble natural precipitation, rainwater pH, rainwater Cl - 、Rainwater SO 4 2-), material information, test cycle, corrosion information (corrosion thickness loss, corrosion weight loss). In order to further reduce the prediction error of the model, an integrated model of the two methods is developed based on random forest and neural network. Random forest can better tolerate outliers and noise in the data and is not prone to overfitting of small sample data, and it can automatically assign weights to input feature variables; BP neural network is a back propagation network, which has the ability to fit nonlinear continuous functions through input and output mapping. Therefore, the carbon steel corrosion rate prediction method based on the random forest and BP neural network integrated model can avoid the defects of manually setting carbon steel corrosion factors and establishing a solidified mathematical model expression to determine the corrosion rate of carbon steel, while accurately and quickly predicting the corrosion rate of carbon steel. Summary of the invention

[0005] The purpose of the present invention is to propose a carbon steel corrosion rate prediction method to improve the problems existing in the traditional prediction model, avoid the defects of manually setting carbon steel corrosion factors and establishing a solidified mathematical model expression to determine the carbon steel corrosion rate. By using the random forest method, the initial prediction of the carbon steel corrosion rate is realized in the full factor data, and the important characteristic factors are automatically extracted, and the BP neural network model is constructed to finally accurately and quickly predict the carbon steel corrosion rate.

[0006] The technical solution adopted by the present invention to achieve its technical problem includes the following steps:

[0007] Step 1: Merge, convert, and divide the historically accumulated carbon steel atmospheric environment natural exposure experimental data to form an initial data set for studying the corrosion rate of carbon steel. The initial data set is divided into initial training samples and initial test samples.

[0008] Step 2: Build a random forest prediction model. Set the model structure and use the genetic algorithm (GA) to tune the number of base classifiers and the maximum tree depth. Use the coefficient of determination (R 2 ) as the objective function to select the optimal parameter combination and save the random forest model with the best prediction performance .

[0009] Step 3: Use the random forest prediction model saved in step 2 The training samples and test samples of the BP neural network are constructed using the initial data set in step 1.

[0010] Step 4: Construct a BP neural network prediction model and set the model structure and initial parameter values, including determining the number of neurons in the input layer, hidden layer, and output layer, as well as the use of activation functions for neurons in each layer.

[0011] Step 5: Use the training samples and test samples constructed in step 3 to train and test the BP neural network prediction model to obtain the optimal BP neural network prediction model.

[0012] Step 6: Use the random forest model saved in step 2 The BP neural network prediction model saved in step 5 is integrated to predict the corrosion rate of carbon steel.

[0013] In step 1, the specific steps of obtaining the initial data set include:

[0014] Step 1.1: Data merging: The carbon steel atmospheric environment natural exposure test data from different data sources are merged to form a full-factor initial data set containing environmental factors, corrosive pollutant information, material information, test cycle and corrosion information, and the corrosion information is set as the independent variable and the remaining factors are the dependent variables.

[0015] Step 1.2: Data conversion: First, the material information characteristic variables in the initial data set are converted into numerical data using hot encoding; further, in order to prevent the influence of dimension and speed up the convergence of the model, the dependent variable factors in the initialization data set are normalized;

[0016] Step 1.3: Data division: The processed initial data set is randomly divided into two groups, 80% of the data is used as the initial training samples, and 20% of the data is used as the initial test samples.

[0017] In step 1, the environmental factors include longitude, latitude, and altitude; the meteorological factors include temperature, humidity, rainfall, total radiation, sunshine time, atmospheric pressure, and wetting time; the corrosive pollutant information includes NO 2 , H 2 S. NH 3 , sulfation rate, sea salt particles, water-soluble natural precipitation, water-insoluble natural precipitation, rainwater pH, rainwater Cl - 、Rainwater SO4 2- ; The material information is material type information; the corrosion information includes corrosion thickness loss and corrosion weight loss.

[0018] Next, in step 1, the method for normalizing the dependent variable factors in the initialized data set is as follows:

[0019] Normalize the sample dependent variable values ​​to The expression of parameter normalization is: ,in and Respectively represent the sample values ​​after conversion and before conversion, Indicates the maximum value of the data sequence. Indicates the minimum value of the data sequence.

[0020] Taking one step further, in step 2, the specific steps of constructing the random deep forest prediction model are:

[0021] Step 2.1: Use the initial training samples in step 1 as the random forest training set, and the initial test samples as the test set; in the full-factor data, use the corrosion information as the target output, and the remaining feature information as the input of the random forest algorithm model;

[0022] Step 2.2: The parameter selection of the random forest algorithm directly affects the prediction accuracy. The genetic algorithm (GA) is used to tune the number of base classifiers and the maximum tree depth in the random forest model. 2 As the objective function, new parameter combinations are generated through operations such as selection, crossover, and genetic mutation, and the best parameter combination and random forest prediction model are finally saved. .

[0023] Proceed one step further, in step 2, the specific steps are as follows:

[0024] Step 2.2.1: Initialize the maximum iteration population to G 0 , the expected objective function value is

[0025] Step 2.2.2, use parameter-free binary coding to initialize the gene sequence of the number of base classifiers and the maximum tree depth parameter group individuals;

[0026] Step 2.2.3, randomly initialize 10 individuals to generate the initial population G=0;

[0027] Step 2.2.4: Use the population individuals to build a random forest model and train it with the training data set;

[0028] Step 2.2.5. Calculate the coefficient of determination R using the test data set 2 is the objective function value ;

[0029] Step 2.2.6, judgment Or maximum population iteration , if true, go to step 2.2.11, otherwise go to step 2.2.7;

[0030] Step 2.2.7, calculate the fitness value of each individual;

[0031] Step 2.2.8, select and save the best individual and objective function value;

[0032] Step 2.2.9: Perform genetic operations, including natural selection, cross breeding, and gene mutation;

[0033] Step 2.2.10: Generate the next generation population G = G+1 through the operation of step 2.2.9, and return to step 2.2.4;

[0034] Step 2.2.11, end population reproduction and determine the optimal parameter combination, which includes the number of base classifiers, the maximum tree depth and the objective function value;

[0035] Step 2.2.12: Save the optimal parameter combination to establish a random forest prediction model .

[0036] Preferably, in step 2.2.1, the maximum iterative population is G 0 The value range is 8-12, the optimal value is 10; the expected objective function value is The value range is 0.8-0.96, and the optimal value is 0.9.

[0037] Preferably, in step 2.2.2, the number of base classifiers is encoded using K1-bit binary code, and the code value is enlarged by K2 times; the maximum tree depth is encoded using K3-bit binary code, where the larger the K1 and K3, the higher the accuracy, but the greater the amount of calculation, so considering comprehensive factors, generally K1 ranges from 5-10, K2 ranges from 8-20, and K3 ranges from 3-8. For example, when K1=7 and K2=10, the number of base classifiers ranges from [10,20,...,1280]; when K3=4, the maximum tree depth ranges from [1,2,...,16].

[0038] Next, in step 3, the steps of constructing the training sample and the test sample of the BP neural network prediction model are as follows:

[0039] Step 3.1: The random forest model constructs new feature input variables for the neural network, based on the best random forest prediction model saved in step 2 , use the initial training sample and initial test sample in step 1 to input into the random forest prediction model Get initial prediction results for carbon steel corrosion ; and random forests can automatically assign different weights to important feature variables The mechanism of , automatically select important characteristic variables from the full factor variables of the initial data; the selection criteria are as follows: =0, discard the feature, otherwise keep the feature. This effectively simplifies the feature subset and reduces the impact of redundant features;

[0040] Step 3.2: Given the BP neural network model training sample feature variables , test sample characteristic variables ,in and Respectively represent the random forest prediction model used by the initial training sample and the initial test sample Get the prediction results, Indicates the selected i feature variables, m Indicates the number of characteristic variables in the initial data.

[0041] Next, in step 4, the specific steps of constructing the BP neural network prediction model are:

[0042] Step 4.1: To effectively integrate the random forest prediction model, the number of neurons in the input layer changes dynamically, which is determined by the number of feature input variables constructed by the random forest model in step S3;

[0043] Step 4.2: Use the corrosion loss rate of carbon steel as the output layer neuron;

[0044] Step 4.3: By empirical formula Determine the number of hidden layer neurons ,in represents the number of training set samples, represents the number of neurons in the input layer, represents the number of neurons in the output layer, represents the empirical parameter of any variable, with a value range of [2,10] and an initial iteration of 2;

[0045] Step 4.4: Set the neuron's activation function to , the activation function of the hidden layer neurons is Tanh( x )= , the output layer activation function is Sigmoid( x )= ,in e is the natural base, x is a variable.

[0046] Next, the specific steps of optimizing, training and testing the BP neural network prediction model in step 5 are as follows:

[0047] Step 5.1: Set initial training parameters and maximum number of iterations p , allowable target error , learning rate l ;

[0048] Step 5.2: Input the training samples obtained from step 3 into the neural network prediction model, use the mean square error as the objective function, and calculate the current iteration error ,in and are the response output value and expected measured value of the i-th neuron in the output layer, respectively. n represents the number of training samples; when Or when the maximum number of iterations is reached, the current optimal weights, that is, the current optimal network model, are saved; otherwise, the weights are continuously adjusted using the principle of neural network back propagation;

[0049] Step 5.3: Use the test sample provided in step 3 to test the accuracy of the saved optimal neural network prediction model, using the mean absolute percentage error and the coefficient of determination Two indicators are used to determine the prediction accuracy of the model.

[0050] Preferably, in step 5.1, the maximum number of iterations p =100, allowable target error , learning rate l =0.004.

[0051] Preferably, in step 5.1, the optimal weights are the weights between the input layer, the hidden layer, and the output layer during the network training process.

[0052] Next, in step 6, the specific steps of using the random forest model and the BP neural network model integration to predict the corrosion rate of carbon steel are:

[0053] The carbon steel corrosion rate is predicted by integrating the random forest model and BP neural network model tested in step 2 and step 5. The non-numeric variables in the data are first converted to numeric types, and then the converted data are normalized to between [-1, 1] and then input into the saved random forest model to obtain the initial prediction value of the random forest. , and the important features selected ; The initial prediction value of random forest and selected important features As the input of the neural network saved after the test, the value calculated by the network is the predicted value of the corrosion rate of carbon steel .

[0054] Beneficial effects of the present invention:

[0055] (1) The present invention integrates the random forest and BP neural network models, which can better solve the problem of unstable and low-precision traditional prediction results, and improve the robustness and prediction accuracy of carbon steel corrosion rate prediction.

[0056] (2) This prediction method has strong generalization ability and broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 It is an overall flow chart of carbon steel corrosion rate prediction based on random forest and BP neural network integrated model constructed in an embodiment of the present invention;

[0058] Figure 2 It is a flow chart for tuning the number of random forest base classifiers and the maximum tree depth parameters based on a genetic algorithm constructed in an embodiment of the present invention;

[0059] Figure 3 It is a BP neural network structure diagram constructed in an embodiment of the present invention;

[0060] Figure 4 It is a flow chart of optimization, training and testing of the BP neural network prediction model constructed in an embodiment of the present invention;

[0061] Figure 5 It is a comparison diagram between the predicted samples and the actual samples in the embodiment of the present invention. DETAILED DESCRIPTION

[0062] The embodiments of the present invention are described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0063] refer to Figure 1 , a method for predicting the corrosion rate of carbon steel provided by an embodiment of the present invention comprises the following steps:

[0064] Step 1: Merge, convert, and divide the historical carbon steel atmospheric environment natural exposure experimental data to form the initial training samples and initial test samples for studying the corrosion rate of carbon steel. The specific implementation steps are as follows:

[0065] 1) Data integration: The carbon steel atmospheric environment natural exposure test data from different data sources are merged to form a data set containing environmental factors (longitude, latitude, altitude), meteorological factors (temperature, humidity, rainfall, total radiation, sunshine time, atmospheric pressure, wetting time), corrosive pollutant information (NO 2 , H 2 S. NH 3 , sulfation rate, sea salt particles, water-soluble natural precipitation, water-insoluble natural precipitation, rainwater pH, rainwater Cl - 、Rainwater SO 4 2- ), material information, test cycle and corrosion information (corrosion thickness loss, corrosion weight loss).

[0066] 2) Data conversion: First, the material information feature variables in the initial data set are converted into numerical data using the unique hot encoding method. There are K types of carbon steel materials in the merged data set. The material parameters are determined to have K-bit encoding. The i-th bit of the i-th material is marked as 1, and the remainder is marked as 0. The results after conversion are shown in Table 1:

[0067] Table 1 Conversion of carbon steel material information characteristic values

[0068]

[0069] In order to prevent the influence of dimension and speed up the convergence of the model, the dependent variable factors in the initialization data set are normalized and the sample dependent variable values ​​are normalized to The expression of parameter normalization is: ,in and Respectively represent the sample values ​​after conversion and before conversion, Indicates the maximum value of the data sequence. Indicates the minimum value of the data sequence.

[0070] 3) Data division: The processed initial data set is randomly divided into two groups, 80% of the data is used as the initial training samples, and 20% of the data is used as the initial test samples.

[0071] Step 2: Build a random forest prediction model. Set the model structure and use the genetic algorithm (GA) to optimize the number of base classifiers and the maximum tree depth. Use the coefficient of determination (R 2 ) as the objective function to select the optimal parameter combination and save the random forest model with better prediction performance.

[0072] 1) The initial training samples divided in step 1 are used as the training set of the random forest, and the initial test samples are used as the test set; in the full-factor data, the corrosion information is used as the target output, and the remaining feature information is used as the input of the random forest algorithm model;

[0073] 2) The selection of random forest algorithm parameters directly affects the prediction accuracy, refer to Figure 2 The genetic algorithm (GA) is used to tune the two parameters of the number of base classifiers and the maximum tree depth in the random forest model.

[0074] (1) Initialize the maximum iterative population to G 0 =10, the expected objective function value is 0 =0.9, the specific steps are:

[0075] (2) Use parameter-free binary coding to initialize the gene sequence of the number of base classifiers and the maximum tree depth parameter group individuals. The number of base classifiers is encoded using 7-bit binary coding, and the coding value is expanded by 10 times to obtain a value range of [10, 20, ..., 1280]; the maximum tree depth is encoded using 4-bit binary coding, and the value range is [1, 2, ..., 16];

[0076] (3) Randomly initialize 10 individuals to generate the initial population G = 0;

[0077] (4) Use the population individuals to build a random forest model and train it with the training data set;

[0078] (5) Calculate the coefficient of determination R using the test data set 2 is the objective function value ;

[0079] (6) Judgment Or maximum population iteration , if true, execute (10), otherwise execute (7);

[0080] (7) Calculate the fitness value of each individual;

[0081] (8) Select and save the best individual and objective function value;

[0082] (9) Perform genetic operations, including natural selection, cross breeding, and gene mutation;

[0083] (10) Generate the next generation population G = G + 1 through the operation of (9), and return to (4);

[0084] (11) End population reproduction and determine the optimal parameter combination;

[0085] (12) Save the optimal parameter combination and random forest prediction model ( ).

[0086] The optimal parameter combination obtained by genetic algorithm is shown in Table 2:

[0087] Table 2 Optimal number of base classifiers and maximum tree depth of random forest model

[0088]

[0089] Step 3: Use the random forest prediction model saved in step 2 and the initial data set in step 1 to construct training samples and test samples of the BP neural network.

[0090] 1) The random forest model constructs new feature input variables for the neural network, and saves the optimal random forest prediction model in step 2 , use the initial training sample and initial test sample in step 1 to input into the random forest prediction model Get initial prediction results for carbon steel corrosion ; and random forests can automatically assign different weights to important feature variables The mechanism of , automatically select important characteristic variables from the full factor variables of the initial data; the selection criteria are as follows: =0, discard the feature, otherwise keep the feature. This effectively simplifies the feature subset and reduces the impact of redundant features;

[0091] 2) Given the BP neural network model training sample feature variables , test sample characteristic variables in and Respectively represent the random forest prediction model used by the initial training sample and the initial test sample Get the prediction results, Indicates the selected i feature variables, m Indicates the number of characteristic variables in the initial data.

[0092] Step 4: Reference Figure 3 , build a BP neural network prediction model, set the model structure and initial parameter values, including determining the number of neurons in the input layer, hidden layer and output layer, and the use of activation functions for neurons in each layer.

[0093] 1) To effectively integrate the random forest prediction model, the number of neurons in the input layer changes dynamically, which is determined by the number of feature input variables constructed by the random forest model in step 3; that is, the neural network structure Figure 3 In R rf is the initial prediction value of random forest, T 1 、T 2 、...、T m Important feature values ​​selected for random forest;

[0094] 2) Prediction of carbon steel corrosion loss rate As output layer neurons;

[0095] 3) Through empirical formula Determine the number of hidden layer neurons ,in represents the number of training set samples, represents the number of neurons in the input layer, represents the number of neurons in the output layer, represents any variable empirical parameter, with a value range of [2,10], and the initial iteration is set to 2;

[0096] 4) Set the neuron's activation function to , the activation function of the hidden layer neurons is Tanh( x )= , the output layer activation function is Sigmoid( x )= .

[0097] Step 5: Reference Figure 4 , use the training samples and test samples constructed in step three to train and test the neural network model to obtain the optimal BP neural network prediction model.

[0098] 1) Set the initial training parameters and the maximum number of iterations p =100, allowable target error , learning rate l =0.004;

[0099] 2) Input the training samples obtained in step 3 into the neural network prediction model, use the mean square error as the objective function, and calculate the current iteration error ,in and are the response output value and expected measured value of the i-th neuron in the output layer, respectively. n represents the number of training samples; when Or when the maximum number of iterations is reached, save the current optimal model ; Otherwise, the error gradient is calculated using the back propagation principle of the neural network, and the weights between network layers are continuously adjusted;

[0100] 3) Use the test samples provided in step 3 to test the accuracy of the saved optimal neural network prediction model, using the mean absolute percentage error and the coefficient of determination Two indicators are used to determine the prediction accuracy of the model.

[0101] Step 6: Use the random forest model that passed the test in steps 2 and 5 And BP neural network model The ensemble predicts the corrosion rate of carbon steel. For 21 prediction samples, the non-numeric variables in the data are first converted to numeric data, and then the converted data is normalized to [-1, 1] and then input into the saved random forest model. Get the initial prediction value of random forest , and important features of random forest for prediction sample selection ; The initial prediction value of random forest and selected important features As a neural network model saved after passing the test The input characteristic variable, the value calculated by the network is the predicted value of carbon steel corrosion rate The prediction results are shown in reference Figure 5 ,in MAPE The value of is 7.650, R 2 The value of is 0.985.

[0102] The carbon steel corrosion rate prediction method based on the random forest and BP neural network integrated model of the present invention can better solve the problems of unstable and low precision of traditional prediction results, improve the robustness and prediction accuracy of carbon steel corrosion rate prediction, and this prediction method has strong generalization ability and broad application prospects.

[0103] The above embodiments are only used to illustrate the present invention, but not to limit the present invention. Although the present invention is described in detail with reference to the embodiments, it should be understood by those skilled in the art that various combinations, modifications or equivalent substitutions of the technical solutions of the present invention do not depart from the spirit and scope of the technical solutions of the present invention, and should be included in the scope of the claims of the present invention.

Claims

1. A method for predicting carbon steel corrosion rate, characterized in that: The specific steps are as follows: Step 1: Merge, convert, and divide the historically accumulated carbon steel atmospheric environment natural exposure experimental data to form an initial data set for studying the corrosion rate of carbon steel. The initial data set is divided into an initial training sample and an initial test sample. Step 2: Build a random forest prediction model, set the model structure, and use genetic algorithms to optimize the number of base classifiers and the maximum tree depth of the random forest model. 2 Select the optimal parameter combination as the objective function and save the random forest model with the best prediction performance ; Step 3: Use the random forest model saved in step 2 Construct training samples and test samples of BP neural network with the initial data set in step 1; Step 4: Construct a BP neural network prediction model, set the model structure and initial parameter values, including determining the number of neurons in the input layer, hidden layer, and output layer, as well as the use of the neuron excitation function in each layer, and use the empirical formula Determine the number of hidden layer neurons ,in represents the number of training set samples, represents the number of neurons in the input layer, represents the number of neurons in the output layer, represents any variable empirical parameter, the activation function of the hidden layer neurons is the Tanh function, and the activation function of the output layer is the Sigmoid function; Step 5: Use the training samples and test samples constructed in step 3 to train and test the BP neural network prediction model to obtain the optimized BP neural network prediction model; Step 6: Use the random forest model saved in step 2 The BP neural network prediction model saved in step 5 is integrated to predict the corrosion rate of carbon steel; In step 2, the specific steps of constructing the random forest prediction model include: Step 2.1: Use the initial training samples divided in step 1 as the training set of the random forest, and the initial test samples as the test set; in the full-factor data, use the corrosion information as the target output, and the remaining feature information as the input of the random forest algorithm model; Step 2.2: The selection of random forest algorithm parameters directly affects the prediction accuracy. The genetic algorithm is used to optimize the number of base classifiers and the maximum tree depth in the random forest model. 2 As the objective function, new parameter combinations are generated through selection, crossover, and mutation genetic operations, and the best parameter combination and random forest prediction model are finally saved. ; The specific steps of step 2.2 are as follows: Step 2.2.1, initialize the maximum iteration population to G0, and the expected objective function value is Step 2.2.2, use parameter-free binary coding to initialize the gene sequence of the number of base classifiers and the maximum tree depth parameter group individuals; Step 2.2.3, randomly initialize 10 individuals to generate the initial population G=0; Step 2.2.4: Use the population individuals to build a random forest model and train it with the training data set; Step 2.2.

5. Calculate the coefficient of determination R using the test data set 2 is the objective function value ; Step 2.2.6, judgment Or maximum population iteration , if true, go to step 2.2.11, otherwise go to step 2.2.7; Step 2.2.7, calculate the fitness value of each individual; Step 2.2.8, select and save the best individual and objective function value; Step 2.2.9: Perform genetic operations, including natural selection, cross breeding, and gene mutation; Step 2.2.10: Generate the next generation population G = G+1 through the operation of step 2.2.9, and return to step 2.2.4; Step 2.2.11, end population reproduction and determine the optimal parameter combination, which includes the number of base classifiers, the maximum tree depth and the objective function value; Step 2.2.12: Save the optimal parameter combination to establish a random forest prediction model ; In step 3, the specific steps of constructing BP neural network training samples and test samples include: Step 3.1: The random forest model constructs new feature input variables for the neural network, and saves the optimal random forest prediction model in step 2. , use the initial training sample and initial test sample in step 1 to input into the random forest prediction model Get initial prediction results for carbon steel corrosion ; and random forests can automatically assign different weights to important feature variables The mechanism of , automatically select important characteristic variables from the full factor variables of the initial data; the selection criteria are as follows: =0, discard the feature, otherwise keep the feature; Step 3.2: Given the BP neural network model training sample feature variables , test sample characteristic variables ,in and Respectively represent the random forest prediction model used by the initial training sample and the initial test sample Get the prediction results, Indicates the selected i feature variables, m Indicates the number of characteristic variables in the initial data; In step 5, the specific steps of BP neural network training and testing include: Step 5.1: Set the initial training parameters and the maximum number of iterations p , allowable target error , learning rate l ; Step 5.2: Input the training samples obtained in step 3 into the BP neural network prediction model, take the mean square error as the objective function, and calculate the current iteration error. ,in and are the response output value and expected measured value of the i-th neuron in the output layer, respectively. n represents the number of training samples; when Or when the maximum iteration is reached, the current optimal weights, that is, the current optimal network model, are saved; otherwise, the weights are continuously adjusted using the principle of neural network back propagation; Step 5.3: Use the test samples provided in step 3 to test the accuracy of the saved optimal BP neural network prediction model, using the mean absolute percentage error and the coefficient of determination Two indicators are used to determine the prediction accuracy of the model.

2. The method for predicting carbon steel corrosion rate according to claim 1, characterized in that: In step 1, the specific steps of obtaining the initial data set include: Step 1.1, data merging: The carbon steel atmospheric environment natural exposure test data from different data sources are merged to form a full-factor initial data set containing environmental factors, meteorological factors, corrosive pollutant information, material information, test cycle and corrosion information, and the corrosion information is set as the independent variable, and the other factors are the dependent variables; Step 1.2, data conversion: First, the material information characteristic variables in the initial data set are converted into numerical data using hot encoding; the dependent variable factors in the initial data set are normalized; Step 1.3, data division: The processed initial data set is randomly divided into two groups, 80% of the data is used as the initial training samples, and 20% of the data is used as the initial test samples.

3. The method for predicting carbon steel corrosion rate according to claim 2, characterized in that: In step 1, the environmental factors include longitude, latitude, and altitude; the meteorological factors include temperature, humidity, rainfall, total radiation, sunshine time, atmospheric pressure, and wetting time; the corrosive pollutant information includes NO2, H2S, NH3, sulfation rate, sea salt particles, water-soluble natural precipitation, water-insoluble natural precipitation, rainwater pH, rainwater Cl - 、Rainwater SO4 2- ; The material information is material type information; the corrosion information includes corrosion thickness loss and corrosion weight loss.

4. The method for predicting carbon steel corrosion rate according to claim 2, characterized in that: In step 1.2, the specific method of normalization is: normalize the sample dependent variable value to The expression of parameter normalization is: ,in and Respectively represent the sample values ​​after conversion and before conversion, Indicates the maximum value of the data sequence. Indicates the minimum value of the data sequence.

5. The method for predicting carbon steel corrosion rate according to claim 1, characterized in that: In step 4, the BP neural network prediction model construction and parameter initialization steps include: Step 4.1: To effectively integrate the random forest prediction model, the number of neurons in the input layer changes dynamically, which is determined by the number of feature input variables constructed by the random forest model in step 3; Step 4.2, using the corrosion loss rate of carbon steel as the output layer neuron; Step 4.3: Use empirical formula Determine the number of hidden layer neurons ,in represents the number of training set samples, represents the number of neurons in the input layer, represents the number of neurons in the output layer, represents any variable empirical parameter, with a value range of [2,10]; Step 4.4: Set the neuron's activation function to , the activation function of the hidden layer neurons is Tanh( x )= , the output layer activation function is Sigmoid( x )= ,in e is the natural base, x is a variable.

6. The method for predicting carbon steel corrosion rate according to claim 1, characterized in that: In step 6, the specific steps of using the random forest model and the BP neural network model to integrate and predict the corrosion rate of carbon steel include: Select some samples from the initial data set as prediction samples, predict the prediction samples, first convert the non-numeric variables in the prediction sample data into numeric data, then normalize the converted data to between [-1,1], and then input it into the saved random forest model Get the initial prediction value of random forest , and important features of random forest for prediction sample selection ; The initial prediction value of random forest and selected important features As a neural network model saved after passing the test The input characteristic variable, the value calculated by the network is the predicted value of carbon steel corrosion rate .