Environmental parameter evolution analysis method based on sparrow search algorithm optimization
By using a method optimized based on the sparrow search algorithm, combined with support vector machine, random forest and neural network, a CH4 and CO2 flux evolution analysis model was constructed. This solves the problem that existing technologies are difficult to accurately predict gas flux evolution in complex environments, and achieves higher prediction accuracy and stability.
Patent Information
- Application Number
- CN202511617705.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-06
- Publication Date
- 2026-01-27
AI Technical Summary
Existing technologies struggle to accurately predict the evolution of methane (CH4) and carbon dioxide (CO2) gas fluxes under complex environmental conditions. Traditional methods cannot effectively capture the nonlinear relationship between temperature, time, and gas flux, and lack dynamic prediction capabilities.
We adopted a method based on the sparrow search algorithm for optimization, combined with support vector machine (SVM), random forest (RF) and neural network (DNN) for model training, optimization and interpretability analysis, to construct CH4 and CO2 flux evolution analysis models, and selected the optimal model through parallel training and parameter optimization.
It accurately captures the different evolution patterns of the two gas fluxes, improves the model's predictive performance and stability, provides higher fitting accuracy and lower relative standard error, and enhances the interpretability of the prediction model.
Smart Images

Figure CN121412958A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of environmental parameter evolution analysis technology, and specifically to an environmental parameter evolution analysis method based on the sparrow search algorithm. Background Technology
[0002] Greenhouse gas emission monitoring is a crucial foundation for climate change research and environmental regulation. Methane (CH4) and carbon dioxide (CO2), as the most significant greenhouse gases, exhibit flux evolution patterns influenced by a complex interplay of environmental factors, including temperature and time. Traditional environmental parameter monitoring and analysis methods suffer from the following limitations: univariate statistical methods struggle to capture the complex nonlinear relationships between temperature, time, and gas flux; existing models lack sufficient accuracy in predicting the evolutionary trends of CH4 and CO2 fluxes, and are deficient in dynamic forecasting capabilities; the driving mechanisms for different gas fluxes vary, but traditional methods cannot effectively distinguish these differences, and prediction models based on empirical formulas exhibit poor adaptability, failing to address flux changes under diverse environmental conditions.
[0003] Therefore, the aforementioned deficiencies in existing technologies severely restrict the accurate analysis and prediction of environmental gas flux evolution, making it difficult to adapt to complex environmental conditions and accurately predict the evolution of various gas fluxes. Summary of the Invention
[0004] The purpose of this invention is to provide an environmental parameter evolution analysis method based on the sparrow search algorithm to solve the technical problem in the prior art of being unable to adapt to complex environmental conditions and accurately predict the evolution of various gas fluxes.
[0005] To solve the above-mentioned technical problems, the present invention specifically provides the following technical solution:
[0006] An environmental parameter evolution analysis method based on a sparrow search algorithm includes the following steps:
[0007] The ambient temperature, CH4 flux, and CO2 flux data were recorded over a period of time using a flux monitoring system.
[0008] The recording time, ambient temperature, and CH4 flux data were used to construct a CH4 flux evolution analysis dataset, and the recording time, ambient temperature, and CO2 flux data were used to construct a CO2 flux evolution analysis dataset.
[0009] The CH4 flux evolution analysis model was obtained by using Support Vector Machine (SVM), Random Forest (RF), and Distributed Neural Network (DNN) based on the CH4 flux evolution analysis dataset for model training, optimization, screening, and interpretability analysis.
[0010] The CO2 flux evolution analysis model was obtained by using Support Vector Machine (SVM), Random Forest (RF), and Distributed Neural Network (DNN) based on the CO2 flux evolution analysis dataset for model training, optimization, screening, and interpretability analysis.
[0011] As a preferred embodiment of the present invention, the method for constructing the CH4 flux evolution analysis model includes:
[0012] The CH4 flux evolution analysis dataset is divided into training set, test set and prediction set according to a preset ratio;
[0013] On the training set, support vector machine (SVM), random forest (RF), and neural network (DNN) are trained to obtain the SVM-CH4 flux prediction model, RF-CH4 flux prediction model, and DNN-CH4 flux prediction model.
[0014] On the test set, the hyperparameters of the SVM-CH4 flux prediction model, RF-CH4 flux prediction model and DNN-CH4 flux prediction model were optimized to obtain the SSA-SVM-CH4 flux prediction model, SSA-RF-CH4 flux prediction model and SSA-DNN-CH4 flux prediction model.
[0015] On the prediction set, the optimal model among the SSA-SVM-CH4 flux prediction model, SSA-RF-CH4 flux prediction model, and SSA-DNN-CH4 flux prediction model is selected, and the optimal model is interpreted to obtain the CH4 flux evolution analysis model.
[0016] As a preferred embodiment of the present invention, the method for optimizing the hyperparameters of the SVM-CH4 flux prediction model, the RF-CH4 flux prediction model, and the DNN-CH4 flux prediction model includes:
[0017] On the test set, the Sparrow Search Algorithm (SSA) was used to iteratively optimize the hyperparameters of the SVM-CH4 flux prediction model (penalty parameter C and RBF kernel parameter gamma), the hyperparameters of the RF-CH4 flux prediction model (number of decision trees n_estimators, number of randomly selected features in each decision tree max_features, maximum tree depth max_depth), and the network structure parameters and model training parameters of the DNN-CH4 flux prediction model. This yielded SSA-SVM-CH4 flux prediction model, SSA-RF-CH4 flux prediction model, and SSA-DNN-CH4 flux prediction model with optimal hyperparameter values.
[0018] As a preferred embodiment of the present invention, the method for selecting the optimal model among the SSA-SVM-CH4 flux prediction model, the SSA-RF-CH4 flux prediction model, and the SSA-DNN-CH4 flux prediction model includes:
[0019] On the prediction set, the goodness of fit between the model predictions and the true values of the SSA-SVM-CH4 flux prediction model, the SSA-RF-CH4 flux prediction model, and the SSA-DNN-CH4 flux prediction model are evaluated, along with the relative standard error RSEM and the correlation coefficient R.
[0020] The optimal model is selected based on the degree of fit between the model's predicted values and the true values, the relative standard error (RSEM), and the correlation coefficient (R).
[0021] As a preferred embodiment of the present invention, the method for interpreting the optimal model among the SSA-SVM-CH4 flux prediction model, SSA-RF-CH4 flux prediction model, and SSA-DNN-CH4 flux prediction model includes:
[0022] The feature contributions of ambient temperature and recording time in the SSA-SVM-CH4 flux prediction model, SSA-RF-CH4 flux prediction model and SSA-DNN-CH4 flux prediction model were analyzed by SHAP. The results showed that the feature contribution of recording time was the highest and the feature contribution of ambient temperature was the lowest.
[0023] The correlation between ambient temperature, recording time, CH4 flux and CO2 flux was analyzed to form a scatter plot matrix and a correlation heatmap. The results showed that CH4 flux had the highest correlation with time and was positively correlated.
[0024] As a preferred embodiment of the present invention, the method for constructing the CO2 flux evolution analysis model includes:
[0025] The CO2 flux evolution analysis dataset is divided into training set, test set and prediction set according to a preset ratio;
[0026] On the training set, support vector machine (SVM), random forest (RF), and neural network (DNN) are trained to obtain the SVM-CO2 flux prediction model, the RF-CO2 flux prediction model, and the DNN-CO2 flux prediction model.
[0027] On the test set, the hyperparameters of the SVM-CO2 flux prediction model, RF-CO2 flux prediction model and DNN-CO2 flux prediction model were optimized to obtain the SSA-SVM-CO2 flux prediction model, SSA-RF-CO2 flux prediction model and SSA-DNN-CO2 flux prediction model.
[0028] On the prediction set, the optimal model among the SSA-SVM-CO2 flux prediction model, SSA-RF-CO2 flux prediction model, and SSA-DNN-CO2 flux prediction model is selected, and the optimal model is interpreted to obtain the CO2 flux evolution analysis model.
[0029] As a preferred embodiment of the present invention, the method for optimizing the hyperparameters of the SVM-CO2 flux prediction model, the RF-CO2 flux prediction model, and the DNN-CO2 flux prediction model includes:
[0030] On the test set, the Sparrow Search Algorithm (SSA) was used to iteratively optimize the hyperparameters of the SVM-CO2 flux prediction model (penalty parameter C and gamma of the RBF kernel function), the hyperparameters of the RF-CO2 flux prediction model (number of decision trees n_estimators, number of randomly selected features in each decision tree max_features, maximum depth of the tree max_depth), and the network structure parameters and model training parameters of the DNN-CO2 flux prediction model. This yielded the SSA-SVM-CO2 flux prediction model, the SSA-RF-CO2 flux prediction model, and the SSA-DNN-CO2 flux prediction model with optimal hyperparameter values.
[0031] As a preferred embodiment of the present invention, the method for selecting the optimal model among the SSA-SVM-CO2 flux prediction model, the SSA-RF-CO2 flux prediction model, and the SSA-DNN-CO2 flux prediction model includes:
[0032] On the prediction set, the goodness of fit between the model predictions and the true values of the SSA-SVM-CO2 flux prediction model, the SSA-RF-CO2 flux prediction model, and the SSA-DNN-CO2 flux prediction model are evaluated, along with the relative standard error RSEM and the correlation coefficient R.
[0033] The optimal model is selected based on the degree of fit between the model's predicted values and the true values, the relative standard error (RSEM), and the correlation coefficient (R).
[0034] As a preferred embodiment of the present invention, the method for interpreting the optimal model among the SSA-SVM-CO2 flux prediction model, the SSA-RF-CO2 flux prediction model, and the SSA-DNN-CO2 flux prediction model includes:
[0035] The feature contributions of ambient temperature and recording time in the SSA-SVM-CO2 flux prediction model, SSA-RF-CO2 flux prediction model and SSA-DNN-CO2 flux prediction model were analyzed by SHAP. The results showed that the feature contribution of recording time was the highest and the feature contribution of ambient temperature was the lowest.
[0036] The correlation between ambient temperature, recording time, CH4 flux and CO2 flux was analyzed to form a scatter plot matrix and a correlation heatmap. The results showed that CH4 flux had the highest correlation with time and was positively correlated.
[0037] As a preferred embodiment of the present invention, the algorithm flow of the sparrow search algorithm includes:
[0038] Step 1: Establish a population X consisting of n sparrows. The expression for population X is:
[0039] ;
[0040] Where d is the number of hyperparameters to be optimized. Let n be the position of the nth sparrow in dimension d;
[0041] Step 2: Set fitness value The fitness value represents an individual sparrow's ability to find food. The expression is:
[0042] ;
[0043] in, For the fitness function, Let be the fitness value of the nth sparrow. Let n be the position vector of the nth sparrow;
[0044] Step 3: Based on population X and fitness value The location update formula for the discoverer is set as follows:
[0045] ;
[0046] in, For the number of iterations, The maximum number of iterations, , They were respectively in the second sequence During the nth iteration, the 1st The sparrow that was the discoverer was in the first The position of the dimension It is a random number in [0,1]. This is the warning value, and its range is [0,1]. The safe value is [0.5, 1], Q is a random number that follows a normal distribution, and L is a 1×d matrix with all elements being 1;
[0047] Step 4: Based on population X and fitness value The location update formula for discoverers is set as follows:
[0048] ;
[0049] in, In the first In the next iteration, the sparrow, as the discoverer, is in the best position. Let A be the worst possible position for the sparrow that discovers the sparrow, and let A be a 1×d matrix where each element is randomly assigned a value of 1 or -1. ;
[0050] Step 5: Set the number of scout sparrows to 10% to 20% of the total population. Their initial positions are randomly generated within the population. The behavioral expression for scout alerts is:
[0051] ;
[0052] in, Let t be the current globally optimal sparrow position in the t-th iteration, β be a control parameter, a random number following a standard normal distribution, K be a uniform random number with a value range of [-1, 1], and ε be a small constant to avoid the denominator being zero; The fitness value of the sparrow acting as a scout. The sparrow in the best position in the whole game fitness value, Sparrow in the worst position globally The fitness value.
[0053] Compared with the prior art, the present invention has the following advantages:
[0054] This invention accurately captures the different evolutionary patterns of the two gases by constructing independent evolutionary analysis models for CH4 and CO2 respectively. Furthermore, by training and optimizing the parameters of three machine learning models based on different principles in parallel, it ensures that the optimal model selected in the end has the best generalization ability and stability. Attached Figure Description
[0055] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely exemplary, and those skilled in the art can derive other embodiments based on the provided drawings without creative effort.
[0056] Figure 1 A flowchart of the method for analyzing particulate organic carbon composition based on remote sensing inversion provided in an embodiment of the present invention;
[0057] Figure 2 A flux monitoring data graph provided for an embodiment of the present invention;
[0058] Figure 3 This is a performance comparison chart of the CH4 flux prediction models provided in the embodiments of the present invention;
[0059] Figure 4 This is a data scatter plot matrix provided in an embodiment of the present invention;
[0060] Figure 5 Data correlation heatmap provided for embodiments of the present invention;
[0061] Figure 6 A feature contribution map of the CH4 flux prediction model provided in this embodiment of the invention;
[0062] Figure 7 This is a performance comparison chart of the CO2 flux prediction models provided in the embodiments of the present invention;
[0063] Figure 8 The feature contribution diagram of the CO2 flux prediction model provided in the embodiments of the present invention. Detailed Implementation
[0064] The technical solutions of the embodiments 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, and 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.
[0065] like Figure 1 As shown, this invention provides a method for environmental parameter evolution analysis based on a sparrow search algorithm, comprising the following steps:
[0066] The ambient temperature, CH4 flux, and CO2 flux data were recorded over a period of time using a flux monitoring system.
[0067] The recording time, ambient temperature, and CH4 flux data were used to construct a CH4 flux evolution analysis dataset, and the recording time, ambient temperature, and CO2 flux data were used to construct a CO2 flux evolution analysis dataset.
[0068] The CH4 flux evolution analysis model was obtained by using support vector machine (SVM), random forest (RF), and neural network (DNN) based on the CH4 flux evolution analysis dataset for model training, optimization, screening, and interpretability analysis.
[0069] We used Support Vector Machine (SVM), Random Forest (RF), and Distributed Neural Network (DNN) to train, optimize, screen, and analyze the interpretability of the CO2 flux evolution analysis dataset, resulting in a CO2 flux evolution analysis model.
[0070] This invention utilizes machine learning models (SVM, RF, DNN) as powerful nonlinear function approximators. Based on this characteristic, their goal is to learn the mapping relationship from a two-dimensional feature space (ambient temperature, recording time) to a one-dimensional target space (CH4 flux, CO2 flux), thereby constructing independent evolutionary analysis models for CH4 and CO2 respectively, accurately capturing the different evolutionary patterns of the two gas fluxes.
[0071] This invention employs a sparrow search algorithm to perform parallel optimization of three models: SVM, RF, and DNN, obtaining the optimal hyperparameter combination on the test set. The optimized model exhibits higher goodness of fit and lower relative standard error on the prediction set, demonstrating the effectiveness of SSA in improving model prediction performance. It also yields the best-performing CH4 flux and CO2 flux prediction models.
[0072] Moreover, this parallel training and optimization of three machine learning models based on different principles ensures that the final selected optimal model has the best generalization ability and stability. This multi-model competition mechanism avoids the specific biases that may exist in a single model.
[0073] This invention, through the combined application of SHAP analysis and correlation heatmaps, not only quantifies the importance of each feature, but also reveals the intrinsic correlation between gas flux and environmental factors such as time and temperature, providing a theoretical basis for model prediction results and improving the interpretability of the prediction model.
[0074] The methods for constructing CH4 flux evolution analysis models include:
[0075] The CH4 flux evolution analysis dataset is divided into training set, test set and prediction set according to a preset ratio;
[0076] On the training set, support vector machine (SVM), random forest (RF), and neural network (DNN) are trained to obtain the SVM-CH4 flux prediction model, RF-CH4 flux prediction model, and DNN-CH4 flux prediction model.
[0077] On the test set, the hyperparameters of the SVM-CH4 flux prediction model, RF-CH4 flux prediction model and DNN-CH4 flux prediction model were optimized to obtain the SSA-SVM-CH4 flux prediction model, SSA-RF-CH4 flux prediction model and SSA-DNN-CH4 flux prediction model.
[0078] On the prediction set, the optimal model among the SSA-SVM-CH4 flux prediction model, SSA-RF-CH4 flux prediction model, and SSA-DNN-CH4 flux prediction model is selected, and the optimal model is interpreted to obtain the CH4 flux evolution analysis model.
[0079] Methods for optimizing the hyperparameters of SVM-CH4 flux prediction models, RF-CH4 flux prediction models, and DNN-CH4 flux prediction models include:
[0080] On the test set, the Sparrow Search Algorithm (SSA) was used to iteratively optimize the hyperparameters of the SVM-CH4 flux prediction model (penalty parameter C and RBF kernel parameter gamma), the hyperparameters of the RF-CH4 flux prediction model (number of decision trees n_estimators, number of randomly selected features in each decision tree max_features, maximum tree depth max_depth), and the network structure parameters and model training parameters of the DNN-CH4 flux prediction model. This yielded SSA-SVM-CH4 flux prediction model, SSA-RF-CH4 flux prediction model, and SSA-DNN-CH4 flux prediction model with optimal hyperparameter values.
[0081] Methods for selecting the optimal model among SSA-SVM-CH4 flux prediction models, SSA-RF-CH4 flux prediction models, and SSA-DNN-CH4 flux prediction models include:
[0082] On the prediction set, the goodness of fit between the model predictions and the true values of the SSA-SVM-CH4 flux prediction model, the SSA-RF-CH4 flux prediction model, and the SSA-DNN-CH4 flux prediction model are evaluated, along with the relative standard error RSEM and the correlation coefficient R.
[0083] Based on the degree of fit between the model's predicted values and the true values, the relative standard error (RSEM), and the correlation coefficient (R), the model with the highest degree of fit and the smallest error is selected as the optimal model.
[0084] Methods for interpreting the optimal models among the SSA-SVM-CH4 flux prediction models, SSA-RF-CH4 flux prediction models, and SSA-DNN-CH4 flux prediction models include:
[0085] The feature contributions of ambient temperature and recording time in the SSA-SVM-CH4 flux prediction model, SSA-RF-CH4 flux prediction model and SSA-DNN-CH4 flux prediction model were analyzed by SHAP. The results showed that the feature contribution of recording time was the highest and the feature contribution of ambient temperature was the lowest.
[0086] The correlation between ambient temperature, recording time, CH4 flux and CO2 flux was analyzed to form a scatter plot matrix and a correlation heatmap. The results showed that CH4 flux had the highest correlation with time and was positively correlated.
[0087] Methods for constructing CO2 flux evolution analysis models include:
[0088] The CO2 flux evolution analysis dataset is divided into training set, test set and prediction set according to a preset ratio;
[0089] On the training set, support vector machine (SVM), random forest (RF), and neural network (DNN) are trained to obtain the SVM-CO2 flux prediction model, the RF-CO2 flux prediction model, and the DNN-CO2 flux prediction model.
[0090] On the test set, the hyperparameters of the SVM-CO2 flux prediction model, RF-CO2 flux prediction model and DNN-CO2 flux prediction model were optimized to obtain the SSA-SVM-CO2 flux prediction model, SSA-RF-CO2 flux prediction model and SSA-DNN-CO2 flux prediction model.
[0091] On the prediction set, the optimal model among the SSA-SVM-CO2 flux prediction model, SSA-RF-CO2 flux prediction model, and SSA-DNN-CO2 flux prediction model is selected, and the optimal model is interpreted to obtain the CO2 flux evolution analysis model.
[0092] Methods for optimizing the hyperparameters of SVM-CO2 flux prediction models, RF-CO2 flux prediction models, and DNN-CO2 flux prediction models include:
[0093] On the test set, the Sparrow Search Algorithm (SSA) was used to iteratively optimize the hyperparameters of the SVM-CO2 flux prediction model (penalty parameter C and gamma of the RBF kernel function), the hyperparameters of the RF-CO2 flux prediction model (number of decision trees n_estimators, number of randomly selected features in each decision tree max_features, maximum depth of the tree max_depth), and the network structure parameters and model training parameters of the DNN-CO2 flux prediction model. This yielded the SSA-SVM-CO2 flux prediction model, the SSA-RF-CO2 flux prediction model, and the SSA-DNN-CO2 flux prediction model with optimal hyperparameter values.
[0094] Methods for selecting the optimal model among SSA-SVM-CO2 flux prediction models, SSA-RF-CO2 flux prediction models, and SSA-DNN-CO2 flux prediction models include:
[0095] On the prediction set, the goodness of fit between the model predictions and the true values of the SSA-SVM-CO2 flux prediction model, the SSA-RF-CO2 flux prediction model, and the SSA-DNN-CO2 flux prediction model are evaluated, along with the relative standard error RSEM and the correlation coefficient R.
[0096] The optimal model is selected based on the degree of fit between the model's predicted values and the true values, the relative standard error (RSEM), and the correlation coefficient (R).
[0097] Methods for interpreting the optimal models among the SSA-SVM-CO2 flux prediction models, SSA-RF-CO2 flux prediction models, and SSA-DNN-CO2 flux prediction models include:
[0098] The feature contributions of ambient temperature and recording time in the SSA-SVM-CO2 flux prediction model, SSA-RF-CO2 flux prediction model and SSA-DNN-CO2 flux prediction model were analyzed by SHAP. The results showed that the feature contribution of recording time was the highest and the feature contribution of ambient temperature was the lowest.
[0099] The correlation between ambient temperature, recording time, CH4 flux and CO2 flux was analyzed to form a scatter plot matrix and a correlation heatmap. The results showed that CH4 flux had the highest correlation with time and was positively correlated.
[0100] Among them, the kernel functions of Support Vector Machines (SVM) mainly fall into three categories: polynomial kernel functions, radial basis functions (RBF), and sigmoid functions. This invention uses the radial basis function (RBF), whose expression is: .
[0101] The core approach of using SVM to solve problems encountered in regression fitting has shifted from finding the optimal plane to finding an optimal surface that minimizes the error between all original data and the target classification surface.
[0102] Generally, we assume the dataset contains l training samples. ,in , , This is the corresponding output value.
[0103] Let the regression polynomial established in the new space be: ;
[0104] in, Let ε be a linear loss function in a multinomial nonlinear function mapping expression. ;
[0105] Where f(x) is the predicted value of the objective function; y is the true value. This means that if the difference between the objective expression f(x) and the true value y is less than or equal to ε, then the value of the loss function is equal to 0.
[0106] Slack variables were introduced The mathematical expression for SVM is:
[0107] ;
[0108] Where C is the penalty value, the larger C is, the larger the penalty function is for samples with training error greater than ε, and ε represents the upper limit of the objective function error. The smaller ε is, the smaller the objective function error is.
[0109] Use the Largerange function to solve for the dual form of the above equation:
[0110] ;
[0111] in, This is the kernel function.
[0112] Let the optimal solution obtained by the above equation be Then we can obtain the expressions for w* and b*. Therefore, the regression function is: .
[0113] Random Forest (RF), proposed by Leo Breiman in 2001, is an improvement on Bagging and consists of a large number of decision trees. RF can meet the needs of classification and regression. For classification, voting determines the prediction result of each decision tree, and the class with the most votes is selected. For regression, the mean of all decision trees is selected as the prediction result.
[0114] The RF regression model can be mathematically interpreted as follows: Given a specific dataset, X is the independent variable (input data), and Y is the dependent variable to be predicted (output data). Assuming that the distributions of (X,Y) are independent, a training set is randomly generated from (X,Y), and the prediction result is denoted as g(X). Then, its mean squared generalization error is expressed as: ;
[0115] Assuming there are h decision trees, what is the predicted value of h decision trees? The average value is the prediction result of random forest regression. If Then the following formula holds true: ;
[0116] In the above formula The generalization error is represented by PE. ** When h is infinitely large, the average generalization error of a single decision tree is denoted as PE. * PE * satisfy: ;
[0117] The above equation satisfies: ;
[0118] in This represents the weighted correlation coefficient between the residuals. The final regression function for the randomization function is: ;
[0119] The construction steps or process of this algorithm are as follows:
[0120] Step 1: Use the Bootstrap resampling method to randomly select n samples with replacement from the dataset, repeating this sampling K times to obtain K training sample sets, which are independent and identically distributed. Simultaneously, the samples not selected in the K samplings are grouped into K out-of-bag (OOB) data sets, becoming the K test sample sets.
[0121] Step 2: Construct a decision tree using the K training samples extracted in Step 1. A random subspace method is used to select the node feature variables of the decision tree; that is, when a sample has n features, m features are randomly selected from each node of the decision tree. Then, the information values contained in these features are calculated, and the most representative feature and its corresponding value are selected from the m features for node splitting.
[0122] Step 3: Each tree will grow to its maximum extent until the number of samples in a node is less than the originally set threshold or the minimum mean square error is less than the set threshold, at which point the decision tree terminates.
[0123] Step 4: Based on the above steps, K decision trees were obtained. Combining these K decision trees can construct a random forest regression model. Then, inputting the data will yield... ,Will average As a prediction result of the random forest regression model.
[0124] After generating pre-pruned decision trees, feature importance can be obtained using the Gini index of each decision tree in the random forest. Let G be the Gini index, and if dataset A has M classes in a classification problem, the probability that a subset belongs to the Mth class is... Then the Gini index is: ;
[0125] In a decision tree, the change in the Gini index before and after pruning a certain internal node is denoted as V. Suppose that after pruning, two new nodes appear, and the Gini indexes of these two new nodes are denoted as . Then we have the following formula: ;
[0126] Let feature N be in the decision tree. Let S be the set of nodes that appear in the decision tree. Then, the feature N in the decision tree... The importance of is recorded as follows: ;
[0127] If there are K decision trees in a random forest, then the Gini score of feature N in the random forest algorithm is: ;
[0128] Finally, after normalizing the Gini indices obtained from different features, the importance ranking of the different features is obtained by sorting them.
[0129] Neural networks are products derived from the analysis, abstraction, and imitation of the operation of biological neural networks. They are network structures that connect a large number of individual neurons according to certain rules, forming a network capable of processing information in parallel. They belong to a type of intelligent mathematical operation model. This model was first proposed by an American psychologist who analyzed the characteristics of biological neurons and, after combining them with mathematical theory, proposed the first mathematical model of an artificial neuron.
[0130] A neural network consists of a large number of processing units called neurons (corresponding to nerve cells in the human brain). The function of a neuron is to calculate the inner product of the input vector and the weight vector, and then pass it through a nonlinear transfer function to obtain a scalar result.
[0131] ;
[0132] ;
[0133] Commonly used activation functions include:
[0134] (1) Sigmoid function: ;
[0135] (2) tanh function: ;
[0136] (3) ReLU function: ;
[0137] (4) Leaky ReLU function: ;
[0138] Taking a neural network model containing an input layer, two hidden layers, and an output layer as an example, the first... The linear coefficient from the i-th neuron in layer 1 to the j-th neuron in layer 1 is defined as... The bias of the j-th neuron in the l-th layer is defined as The bias of the j-th neuron in the l-th layer is defined as The output of the first hidden layer is calculated as shown in the following equation:
[0139] ;
[0140] Suppose that the activation function we choose is The output of the j-th neuron in the (l+1)-th layer is defined as Then the input to the second hidden layer is:
[0141] ;
[0142] The output calculation for the second hidden layer is shown in the following formula:
[0143] ;
[0144] The input to the output layer is: ;
[0145] The output of the output layer is then: ;
[0146] The general expression for the loss function of a neural network is: The loss function is used to measure the degree of inconsistency between the true value y and the predicted value f(x), and generally, a smaller value is better. A small loss function indicates that the machine learning model closely approximates the true distribution of the data, indicating good model performance; a large loss function indicates that the machine learning model deviates significantly from the true distribution of the data, indicating poor model performance. For regression problems, the loss function is: ;
[0147] in, y represents the predicted result, and y represents the actual result.
[0148] Gradient descent is one of the most commonly used optimization algorithms and currently the most frequently used method for optimizing neural networks. It is an algorithm that reaches the minimum value of a function through iterative steps. To find a local minimum of a function using gradient descent, steps can be taken that are proportional to the negative value of the function's gradient (or approximate gradient) at the current point.
[0149] The gradient represents the directional derivative of a function at a given point, where the directional derivative along that direction reaches its maximum value; in other words, it is the derivative of the function at the current position. ;
[0150] In the formula, As the independent variable, For about The function, Let represent the gradient. Then the independent variable parameter in the i-th step should be equal to: ;
[0151] η is the learning rate. When the learning rate is too low, many steps are needed to converge. Conversely, when the learning rate is too high, gradient descent will fail to reach the minimum value.
[0152] The learning process of BP neural network reservoir modeling consists of two stages: The first stage is forward propagation, which involves inputting known reservoir geological information as training samples. Using the established network structure and the thresholds and weights obtained from the previous training step, the output of each neuron is calculated from the first layer onwards. This process processes the input geological variable data and outputs the results. The second stage is backpropagation, where the output error is propagated back through the hidden layers to the input layers, distributing the error to all units in each layer. This yields the error signal for each unit, which serves as the basis for adjusting the weights. Specifically, by comparing the deviation between the actual output and the expected parameters, the network error is determined and propagated back to the reservoir attribute data processing units, thus readjusting their connections. This process of forward and backward propagation of signals and adjustment of layer weights is repeated continuously. This continuous adjustment of weights is the network's learning and training process. This continues until the network's output error is reduced to an acceptable level or until a predetermined number of training iterations are completed.
[0153] Assumption It is known that the following can be calculated using the chain rule:
[0154] ;
[0155] and ;
[0156] Therefore, as long as the error of the l-th layer is known... Then you can calculate , , , and Used to update the parameters w and b of the l-th layer. It is passed to the (l-1)th layer to further calculate the derivatives of the parameters of the (l-1)th layer.
[0157] In the Sparrow Search Algorithm (SSA), sparrows can be categorized into three types: leaders, followers, and alerters. Within the population, leaders play a role in finding resources, providing clues such as foraging areas and directions. Followers, with their keen observation skills, capture the leader's movements to obtain food. Sparrows primarily utilize both leader and follower strategies for foraging, maintaining a cooperative yet competitive relationship. Alerters typically reside on the periphery of the population, where they are more vulnerable to predators, thus requiring them to constantly adjust their position to secure safer areas. Based on this brief overview, the following principles can be summarized:
[0158] (1) Resource reserve principle: Leaders usually control more food resources and are responsible for finding more favorable areas for the population, that is, areas with abundant food, and contacting followers to provide relevant foraging areas and directions.
[0159] (2) The principle of constant proportion: As long as a better resource is found, every sparrow can become a leader. However, the overall proportion of the two remains constant. That is to say, for every sparrow whose status changes to a leader, there must be another sparrow whose status changes to a follower. In other words, the status of leaders and followers is in a dynamic switching process.
[0160] (3) Warning and escape principle: If a sparrow discovers a predator, it will issue a warning. Once the warning value exceeds the warning threshold, the followers will escape to other safe areas to forage under the guidance of the leader.
[0161] (4) The principle of surveillance and plunder: When sparrows are foraging, they will always find the discoverer with the best food resources and obtain food from that area or forage around the leader. At the same time, if the followers want to improve their foraging rate, they will monitor the leader in real time in order to plunder food resources.
[0162] (5) The principle of flying towards the best: The scarcer the resources available to followers, the worse their foraging locations will be within the population. Some followers who are starving are more likely to fly to areas with more resources to forage.
[0163] (6) Early warning and transfer principle: When sensing a dangerous atmosphere, the sparrow individuals on the periphery will immediately transfer to a safe position, while the individuals in the middle of the population will adopt a random movement strategy to approach other individuals.
[0164] The process of the sparrow search algorithm includes:
[0165] The first step: Establish a population X composed of n sparrows. The expression of population X is:
[0166] ;
[0167] where d is the number of hyperparameters to be optimized, is the position of the nth sparrow in the dth dimension;
[0168] The second step: Set the fitness value represents the ability of the sparrow individual to find food. The fitness value The expression is:
[0169] ;
[0170] where, is the fitness function, is the fitness value of the nth sparrow, is the position vector of the nth sparrow;
[0171] The third step: According to the population X and the fitness value , set the position update formula of the discoverer as:
[0172] ;
[0173] where, is the number of iterations, is the maximum number of iterations, , are respectively at the th, th iteration, the position of the th sparrow as the discoverer in the th dimension, is a random number in [0, 1]. is the early warning value, and its value range is [0, 1], is the safety value, and its value range is [0.5, 1]. Q is a random number subject to a normal distribution, and L is a 1×d matrix with all elements being 1;
[0174] When the situation of R2 < ST occurs, it means that the foraging environment is safe at this time and no predators are found, and the discoverer can perform a large number of search operations;
[0175] When R2>ST occurs, it means that an individual in the sparrow population has already discovered the predator and sounded the alarm. At this time, all sparrows will take anti-predation behavior and quickly move to other safe places to continue foraging.
[0176] Step 4: Based on population X and fitness value The location update formula for discoverers is set as follows:
[0177] ;
[0178] in, In the first In the next iteration, the sparrow, as the discoverer, is in the best position. Let A be the worst possible position for the sparrow that discovers the sparrow, and let A be a 1×d matrix where each element is randomly assigned a value of 1 or -1. ;
[0179] When it appears In this case, it indicates that the entrant with low fitness has not found food in the current state and needs to go to other areas to forage in order to improve its survival rate.
[0180] Step 5: Set the number of scout sparrows to 10% to 20% of the total population. Their initial positions are randomly generated within the population. The behavioral expression for scout alerts is:
[0181] ;
[0182] in, Let t be the current globally optimal sparrow position in the t-th iteration, β be a control parameter, a random number following a standard normal distribution, K be a uniform random number with a value range of [-1, 1], and ε be a small constant to avoid the denominator being zero; The fitness value of the sparrow acting as a scout. The sparrow in the best position in the whole game fitness value, Sparrow in the worst position globally The fitness value.
[0183] When f appears i =f g In this situation, it indicates that the sparrow in question is in the optimal position globally and will move closer to other sparrows to reduce the risk of being preyed upon.
[0184] When f appears i >f gIn this situation, it indicates that the sparrow in question is on the edge of the population and is more vulnerable to predators, and will quickly move to the current optimal position.
[0185] The network structure parameters include the number and type of intermediate layers (fully connected, dropout layers, normalized layers, convolutional layers, etc.), the number of neurons per layer, and the activation function. The model training parameters include the loss function, optimization method, batch size, number of iterations, learning rate, regularization method and coefficients, and initialization method.
[0186] Methods for optimizing the penalty parameter C and the gamma parameter of the RBF kernel function in Support Vector Machines (SVM) using the sparrow search algorithm include:
[0187] Each sparrow's position is represented as a (C, gamma) combination. The initial position is randomly generated within a preset range. The fitness value of the population is calculated using the relative standard error RSEM or the correlation coefficient R2 as the fitness function. The population size and maximum number of iterations of the sparrow search algorithm SSA are set.
[0188] During the iteration process of the Sparrow Search Algorithm (SSA):
[0189] Update the position of the leading sparrow based on the discoverer's updated formula, and explore new (C, gamma) combinations;
[0190] The position of the following sparrow is updated according to the formula for updating the position of the introducer, so as to move closer to the high-quality solution;
[0191] The position of the early warning sparrow is updated based on the behavior formula of the reconnaissance and early warning system to avoid getting trapped in local optima.
[0192] The fitness values of all sparrows are recalculated after each iteration;
[0193] The sparrow position with the highest fitness that reaches the maximum number of iterations is taken as the optimal combination solution (C, gamma).
[0194] Methods for optimizing the number of decision trees (n_estimators), the number of randomly selected features (max_features) for each decision tree, and the maximum depth (max_depth) in Random Forest (RF) using the Sparrow Search algorithm include:
[0195] Each sparrow's position is represented as a (n_estimators, max_features, max_depth) combination. The initial position is randomly generated within a preset range. The fitness value of the population is calculated using the relative standard error RSEM or the correlation coefficient R2 as the fitness function. The population size and maximum number of iterations of the sparrow search algorithm SSA are set.
[0196] During the iteration process of the Sparrow Search Algorithm (SSA):
[0197] Update the position of the leading sparrow according to the discoverer's update formula, and explore new combinations of (n_estimators, max_features, max_depth);
[0198] The position of the following sparrow is updated according to the formula for updating the position of the introducer, so as to move closer to the high-quality solution;
[0199] The position of the early warning sparrow is updated based on the behavior formula of the reconnaissance and early warning system to avoid getting trapped in local optima.
[0200] The fitness values of all sparrows are recalculated after each iteration;
[0201] The position of the sparrow with the highest fitness that reaches the maximum number of iterations is taken as the optimal combination solution of (n_estimators, max_features, max_depth).
[0202] The methods for optimizing network structure parameters and model training parameters in a neural network (DNN) using the sparrow search algorithm include:
[0203] Each sparrow's position is represented as a combination of (network structure parameters, model training parameters). The initial position is randomly generated within a preset range. The fitness value of the population is calculated using the relative standard error RSEM or the correlation coefficient R2 as the fitness function. The population size and maximum number of iterations of the sparrow search algorithm SSA are set.
[0204] During the iteration process of the Sparrow Search Algorithm (SSA):
[0205] Update the position of the leading sparrow according to the discovery formula, and explore new combinations of (network structure parameters, model training parameters);
[0206] The position of the following sparrow is updated according to the formula for updating the position of the introducer, so as to move closer to the high-quality solution;
[0207] The position of the early warning sparrow is updated based on the behavior formula of the reconnaissance and early warning system to avoid getting trapped in local optima.
[0208] The fitness values of all sparrows are recalculated after each iteration;
[0209] The sparrow position with the highest fitness that reaches the maximum number of iterations is taken as the optimal combination of (network structure parameters, model training parameters).
[0210] This invention cleverly balances global search and local exploitation capabilities through the SSA algorithm. Its watchdog mechanism effectively avoids getting trapped in local optima, which is difficult to achieve with traditional optimization methods. The resulting hyperparameters (such as the complex three-layer neuron structure in the DNN stress model) are often difficult to design manually, fully tapping the potential performance of the machine learning model.
[0211] This invention automates the entire process from model training and hyperparameter optimization to performance comparison. By setting the population and number of iterations of the SSA (Self-Assessing and Optimizing) model, parallel optimization and evaluation of three machine learning models can be automatically completed, significantly reducing manual intervention and computational time costs. This makes it possible to quickly select the optimal prediction model for a specific environmental parameter evolution analysis task, thus improving analysis efficiency.
[0212] Example: This invention establishes an optimal machine learning model for learning the changing patterns of ecological evolution parameters, enabling predictive analysis of environmental parameters (CH4 and CO2 fluxes), as detailed below:
[0213] The flux monitoring system recorded ambient temperature, CH4 flux, and CO2 flux data at the top of the hour on the 15th of each of the 11 months from January to February and April to December 2020. Temperature initially increased and then decreased over time; CH4 flux fluctuated significantly with only a slight upward trend; and CO2 flux decreased over time. Figure 2 As shown.
[0214] Regarding the prediction of CH4 flux:
[0215] First, the data is divided into training, testing, and prediction sets in a ratio of 0.8, 0.1, and 0.1, respectively. The training set is used to train the machine learning model, the testing set is used to calculate the fit index of the SSA model and optimize the model parameters, and the prediction set is used for on-site prediction.
[0216] The SVM, RF, and DNN models are coupled into the SSA optimization algorithm, with a population size of 30 and a maximum number of iterations of 30. For the SVM model, c ∈ [0.01, 30] and gamma ∈ [0.01, 100]; for the RF model, n_estimators ∈ [0.01, 30] and max_features ∈ [0.01, 100]; for the DNN model, the learning rate η ∈ [0.001 0.01], the maximum number of iterations Epoch ∈ [10, 100], and the neural network has two hidden layers with the number of neurons num ∈ [1-100]. The batch size for the DNN model is set to 32, and the optimization algorithm is Adam.
[0217] The change in the fit index during the SSA optimization of hyperparameters for SVM, RF, and DNN models is as follows: Figure 3As shown in Figure a, the vertical axis represents the Fitness Value, and the horizontal axis represents the number of iterations. The SVM model's hyperparameters reached their minimum value of 0.817631 after 6 iterations, with optimal variables c = 30.0 and gamma = 100.0. The RF model's hyperparameters reached their minimum value of 0.129457 after 6 iterations, with optimal variables n_estimators = 6 and max_features = 1. The DNN model's hyperparameters reached their minimum value of 0.838134 after 3 adjustments. The optimal variable learning rate was 0.00905586, the number of iterations was 91, the number of neurons in the first hidden layer was 63, and the number of neurons in the second hidden layer was 88.
[0218] The prediction set data is input into the optimized SVM, RF, and DNN models, namely SSA-SVM-CH4, SSA-RF-CH4, and SSA-DNN-CH4, and the prediction results are as follows. Figure 3 As shown in Figure b, the SSA-RF-CH4 model has the best prediction performance, followed by the SSA-DNN-CH4 model, while the SSA-SVM-CH4 model has the worst performance. The SSA-RF-CH4 and SSA-DNN-CH4 models predict CH4 flux fluctuations with smaller fluctuations.
[0219] Table 1 shows the RMSE and R values of the prediction results for the SSA-SVM-CH4, SSA-RF-CH4, and SSA-DNN-CH4 models. Among the three machine learning models, the SSA-RF-CH4 model has the lowest RMSE, followed by SSA-DNN-CH4, and SSA-SVM-CH4 has the highest. The correlation coefficients of the three models are all relatively low, with the highest not exceeding 0.15. Considering both the correlation coefficient R and RMSE, the SSA-RF-CH4 model is the best.
[0220] Through the scatter plot matrix of flux monitoring data (such as...) Figure 4 (as shown) and correlation heatmaps (such as) Figure 5 As shown in the figure, CH4 flux has a high correlation with time, showing a positive correlation; CO2 flux has a high correlation with time, showing a negative correlation; and the correlation between CH4 flux and CO2 flux is poor.
[0221] Furthermore, by analyzing the contribution of the input parameters, it can be concluded that (e.g.) Figure 6 As shown in the figure, among the characteristic parameters, the time feature has the highest contribution, reaching 0.56, while the temperature feature contributes 0.44.
[0222] This shows that the contribution of time-related characteristics is the highest, while the contribution of environmental temperature is the lowest. This aligns with the physical laws governing the evolution of environmental gas fluxes: greenhouse gas flux changes are a typical time-accumulated process, with the time factor representing long-term dynamic processes such as microbial community succession, the progress of organic matter decomposition, and the cumulative effects of environmental conditions. On sufficiently long timescales, the impact of these slowly changing biogeochemical processes on gas fluxes far exceeds that of instantaneous temperature fluctuations; therefore, time becomes the dominant factor driving gas flux changes.
[0223] Similarly, CH4 flux showed the strongest and most positive correlation with time, which aligns with the contribution analysis results, indicating a clear increasing trend in CH4 flux over time within the observation window. This may stem from mechanisms such as the continuous proliferation of methanogenic communities, the gradual decomposition of organic substrates, or directional changes in environmental conditions. The lowest contribution from ambient temperature, along with a weaker correlation, suggests that temperature is not a limiting factor under the current observation conditions, possibly due to the limited range of temperature variations or the masking effect of other environmental factors.
[0224] The high consistency between the SHAP contribution and the correlation analysis fully validates the interpretability of predicting gas flux evolution using parameters such as recording time and ambient temperature. The model not only accurately captures the temporal variation of gas flux but also scientifically identifies the relative importance of different environmental factors, providing reliable data support for understanding the driving mechanisms of greenhouse gas emissions.
[0225] Table 1. Model prediction results and monitoring data for CH4 flux: RMSE and R: Evaluation indicators <![CDATA[SSA-SVM-CH4]]> <![CDATA[SSA-RF-CH4]]> <![CDATA[SSA-DNN-CH4]]> RMSE 0.1117 0.0657 0.0710 R 0.1198 0.1199 0.1227
[0226] Therefore, the SSA-RF-CH4 model was used to predict CH4 flux in this invention.
[0227] Regarding the prediction of CO2 flux:
[0228] First, the data is divided into training, testing, and prediction sets in a ratio of 0.8, 0.1, and 0.1, respectively. The training set is used to train the machine learning model, the testing set is used to calculate the fit index of the SSA model and optimize the model parameters, and the prediction set is used for on-site prediction.
[0229] The SVM, RF, and DNN models are coupled into the SSA optimization algorithm, with a population size of 30 and a maximum number of iterations of 30. For the SVM model, c ∈ [0.01, 30] and gamma ∈ [0.01, 100]; for the RF model, n_estimators ∈ [0.01, 30] and max_features ∈ [0.01, 100]; for the DNN model, the learning rate η ∈ [0.001 0.01], the maximum number of iterations Epoch ∈ [10, 100], and the neural network has two hidden layers with the number of neurons num ∈ [1-100]. The batch size for the DNN model is set to 32, and the optimization algorithm is Adam.
[0230] The change in the fit index during the SSA optimization of hyperparameters for SVM, RF, and DNN models is as follows: Figure 7 As shown in Figure a, the vertical axis represents the Fitness Value, and the horizontal axis represents the number of iterations. The SVM model's hyperparameters reached their minimum value of 0.0989558 after 14 iterations, with optimal variable c of 0.4000962324216852 and gamma of 0.3998500319726644. The RF model's hyperparameters reached their minimum value of 0.1176530 after 11 iterations, with optimal variable n_estimators of 26 and max_features of 1. The DNN model's hyperparameters reached their minimum value of 0.1111070 after 15 adjustments. The optimal variable learning rate was 0.00632377, the number of iterations was 79, the number of neurons in the first hidden layer was 89, and the number of neurons in the second hidden layer was 43.
[0231] The prediction set data is input into the optimized SVM, RF, and DNN models, namely SSA-SVM-CO2, SSA-RF-CO2, and SSA-DNN-CO2, and the prediction results are as follows. Figure 7 As shown in Figure b, the SSA-RF-CO2 model has the best prediction performance, followed by the SSA-DNN-CO2 model, while the SSA-SVM-CO2 model has the worst performance. The SSA-SVM-CO2 and SSA-DNN-CO2 models predict CO2 flux fluctuations with smaller fluctuations.
[0232] Table 2 shows the RMSE and R values of the prediction results for the SSA-SVM-CO2, SSA-RF-CO2, and SSA-DNN-CO2 models. Among the three machine learning models, the SSA-RF model has the lowest RMSE, followed by SSA-DNN-CO2, and SSA-SVM-CO2 has the highest. The correlation coefficients of all three models are relatively low. Considering both the correlation coefficient (R) and RMSE, the SSA-RF-CO2 model is the best.
[0233] Through the scatter plot matrix of flux monitoring data (such as...) Figure 4 (as shown) and correlation heatmaps (such as) Figure 5 As shown in the figure, CH4 flux has a high correlation with time, showing a positive correlation; CO2 flux has a high correlation with time, showing a negative correlation; and the correlation between CH4 flux and CO2 flux is poor.
[0234] Furthermore, by analyzing the contribution of the input parameters, it can be concluded that (e.g.) Figure 8 As shown in the figure, among the characteristic parameters, the time feature has the highest contribution, reaching 0.68, while the temperature feature contributes 0.32.
[0235] This shows that the contribution of time characteristics is the highest, while the contribution of ambient temperature characteristics is the lowest. This aligns with the physical laws governing the evolution of carbon dioxide flux: CO2 flux changes are primarily controlled by ecosystem carbon cycle processes, and the time factor represents the cumulative effect of biogeochemical processes such as plant photosynthesis, soil microbial respiration, and organic matter decomposition. On a seasonal scale, the dynamic changes of these processes have a far greater impact on CO2 flux than instantaneous temperature fluctuations; therefore, time becomes the dominant factor driving CO2 flux changes.
[0236] Similarly, CO2 flux showed the strongest and most positive correlation with time, which aligns with the contribution analysis results, indicating a clear increasing trend in CO2 flux over time within the observation window. This may stem from mechanisms such as the continuous enhancement of microbial respiration, the gradual decomposition of soil organic carbon, or changes in plant phenology. The contribution of ambient temperature was the lowest and the correlation was weakest, suggesting that under the current observation conditions, the direct impact of temperature on CO2 flux is relatively limited. This may be because temperature changes are already within the suitable range for microbial activity, or other environmental factors (such as water and nutrient availability) have become the main limiting factors.
[0237] The high consistency between the SHAP contribution and the correlation analysis fully validates the interpretability of predicting CO2 flux evolution using parameters such as recording time and ambient temperature. The model not only accurately captures the temporal variation of CO2 flux but also scientifically reveals the relative importance of different environmental factors in the carbon cycle, providing reliable data support for understanding the driving mechanisms of carbon flux in terrestrial ecosystems.
[0238] Table 2. RMSE and R of CO2 flux model predictions and monitoring data: Evaluation indicators <![CDATA[SSA-SVM-CO2]]> <![CDATA[SSA-RF-CO2]]> <![CDATA[SSA-DNN-CO2]]> RMSE 0.0346 0.0233 0.0259 R 0.2513 0.0590 0.0515
[0239] Therefore, the SSA-RF-CO2 model is used to predict CO2 flux in this invention.
[0240] In summary, ambient temperature first increases and then decreases over time, CH4 flux fluctuates significantly with only a slight upward trend, while CO2 flux decreases over time. CH4 flux shows a high positive correlation with time; CO2 flux shows a high negative correlation with time, and the correlation between CH4 and CO2 fluxes is weak. Among the machine learning models for CH4 flux prediction, the SSA-RF model has the lowest RMSE, followed by SSA-DNN, with SSA-SVM having the highest. The correlation coefficients of all three models are relatively low, with the highest not exceeding 0.15. Considering both the correlation coefficient R and RMSE, the SSA-RF model is the best. Among the machine learning models for CO2 flux prediction, the SSA-RF model has the lowest RMSE, followed by SSA-DNN, with SSA-SVM having the highest. The correlation coefficients of all three models are relatively low. Considering both the correlation coefficient R and RMSE, the SSA-RF model is the best.
[0241] This invention accurately captures the different evolutionary patterns of the two gases by constructing independent evolutionary analysis models for CH4 and CO2 respectively. Furthermore, by training and optimizing the parameters of three machine learning models based on different principles in parallel, it ensures that the optimal model selected in the end has the best generalization ability and stability.
[0242] The above embodiments are merely exemplary embodiments of this application and are not intended to limit this application. The scope of protection of this application is defined by the claims. Those skilled in the art can make various modifications or equivalent substitutions to this application within its substance and scope of protection, and such modifications or equivalent substitutions should also be considered to fall within the scope of protection of this application.
Claims
1. A method for analyzing the evolution of environmental parameters based on a sparrow search algorithm, characterized in that, Includes the following steps: The ambient temperature, CH4 flux, and CO2 flux data were recorded over a period of time using a flux monitoring system. The recording time, ambient temperature, and CH4 flux data constitute the CH4 flux evolution analysis dataset, and the recording time, ambient temperature, and CO2 flux data constitute the CO2 flux evolution analysis dataset. The CH4 flux evolution analysis model was obtained by using Support Vector Machine (SVM), Random Forest (RF), and Distributed Neural Network (DNN) based on the CH4 flux evolution analysis dataset for model training, optimization, screening, and interpretability analysis. The CO2 flux evolution analysis model was obtained by using Support Vector Machine (SVM), Random Forest (RF), and Distributed Neural Network (DNN) based on the CO2 flux evolution analysis dataset for model training, optimization, screening, and interpretability analysis.
2. The environmental parameter evolution analysis method based on the sparrow search algorithm optimization according to claim 1, characterized in that: The method for constructing the CH4 flux evolution analysis model includes: The CH4 flux evolution analysis dataset is divided into a training set, a test set, and a prediction set according to a preset ratio; On the training set, support vector machine (SVM), random forest (RF), and neural network (DNN) are trained to obtain the SVM-CH4 flux prediction model, RF-CH4 flux prediction model, and DNN-CH4 flux prediction model. On the test set, the hyperparameters of the SVM-CH4 flux prediction model, RF-CH4 flux prediction model and DNN-CH4 flux prediction model were optimized to obtain the SSA-SVM-CH4 flux prediction model, SSA-RF-CH4 flux prediction model and SSA-DNN-CH4 flux prediction model. On the prediction set, the optimal model among the SSA-SVM-CH4 flux prediction model, SSA-RF-CH4 flux prediction model, and SSA-DNN-CH4 flux prediction model is selected, and the optimal model is interpreted to obtain the CH4 flux evolution analysis model.
3. The environmental parameter evolution analysis method based on the sparrow search algorithm optimization according to claim 2, characterized in that: Methods for optimizing the hyperparameters of SVM-CH4 flux prediction models, RF-CH4 flux prediction models, and DNN-CH4 flux prediction models include: On the test set, the Sparrow Search Algorithm (SSA) was used to iteratively optimize the hyperparameters of the SVM-CH4 flux prediction model (penalty parameter C and RBF kernel parameter gamma), the hyperparameters of the RF-CH4 flux prediction model (number of decision trees n_estimators, number of randomly selected features in each decision tree max_features, maximum tree depth max_depth), and the network structure parameters and model training parameters of the DNN-CH4 flux prediction model. This yielded SSA-SVM-CH4 flux prediction model, SSA-RF-CH4 flux prediction model, and SSA-DNN-CH4 flux prediction model with optimal hyperparameter values.
4. The environmental parameter evolution analysis method based on sparrow search algorithm optimization according to claim 3, characterized in that: Methods for selecting the optimal model among SSA-SVM-CH4 flux prediction models, SSA-RF-CH4 flux prediction models, and SSA-DNN-CH4 flux prediction models include: On the prediction set, the goodness of fit between the model predictions and the true values of the SSA-SVM-CH4 flux prediction model, the SSA-RF-CH4 flux prediction model, and the SSA-DNN-CH4 flux prediction model are evaluated, along with the relative standard error RSEM and the correlation coefficient R. The optimal model is selected based on the degree of fit between the model's predicted values and the true values, the relative standard error (RSEM), and the correlation coefficient (R).
5. The environmental parameter evolution analysis method based on sparrow search algorithm optimization according to claim 4, characterized in that: Methods for interpreting the optimal models among the SSA-SVM-CH4 flux prediction models, SSA-RF-CH4 flux prediction models, and SSA-DNN-CH4 flux prediction models include: The feature contributions of ambient temperature and recording time in the SSA-SVM-CH4 flux prediction model, SSA-RF-CH4 flux prediction model and SSA-DNN-CH4 flux prediction model were analyzed by SHAP. The results showed that the feature contribution of recording time was the highest and the feature contribution of ambient temperature was the lowest. The correlation between ambient temperature, recording time, CH4 flux and CO2 flux was analyzed to form a scatter plot matrix and a correlation heatmap. The results showed that CH4 flux had the highest correlation with time and was positively correlated.
6. The environmental parameter evolution analysis method based on the sparrow search algorithm optimization according to claim 5, characterized in that: The method for constructing the CO2 flux evolution analysis model includes: The CO2 flux evolution analysis dataset is divided into training set, test set and prediction set according to a preset ratio; On the training set, support vector machine (SVM), random forest (RF), and neural network (DNN) are trained to obtain the SVM-CO2 flux prediction model, the RF-CO2 flux prediction model, and the DNN-CO2 flux prediction model. On the test set, the hyperparameters of the SVM-CO2 flux prediction model, RF-CO2 flux prediction model and DNN-CO2 flux prediction model were optimized to obtain the SSA-SVM-CO2 flux prediction model, SSA-RF-CO2 flux prediction model and SSA-DNN-CO2 flux prediction model. On the prediction set, the optimal model among the SSA-SVM-CO2 flux prediction model, SSA-RF-CO2 flux prediction model, and SSA-DNN-CO2 flux prediction model is selected, and the optimal model is interpreted to obtain the CO2 flux evolution analysis model.
7. The environmental parameter evolution analysis method based on the sparrow search algorithm optimization according to claim 6, characterized in that: Methods for optimizing the hyperparameters of SVM-CO2 flux prediction models, RF-CO2 flux prediction models, and DNN-CO2 flux prediction models include: On the test set, the Sparrow Search Algorithm (SSA) was used to iteratively optimize the hyperparameters of the SVM-CO2 flux prediction model (penalty parameter C and gamma of the RBF kernel function), the hyperparameters of the RF-CO2 flux prediction model (number of decision trees n_estimators, number of randomly selected features in each decision tree max_features, maximum depth of the tree max_depth), and the network structure parameters and model training parameters of the DNN-CO2 flux prediction model. This yielded the SSA-SVM-CO2 flux prediction model, the SSA-RF-CO2 flux prediction model, and the SSA-DNN-CO2 flux prediction model with optimal hyperparameter values.
8. The environmental parameter evolution analysis method based on the sparrow search algorithm optimization according to claim 7, characterized in that: Methods for selecting the optimal model among SSA-SVM-CO2 flux prediction models, SSA-RF-CO2 flux prediction models, and SSA-DNN-CO2 flux prediction models include: On the prediction set, the goodness of fit between the model predictions and the true values of the SSA-SVM-CO2 flux prediction model, the SSA-RF-CO2 flux prediction model, and the SSA-DNN-CO2 flux prediction model are evaluated, along with the relative standard error RSEM and the correlation coefficient R. The optimal model is selected based on the degree of fit between the model's predicted values and the true values, the relative standard error (RSEM), and the correlation coefficient (R).
9. The environmental parameter evolution analysis method based on the sparrow search algorithm optimization according to claim 8, characterized in that: Methods for interpreting the optimal models among the SSA-SVM-CO2 flux prediction models, SSA-RF-CO2 flux prediction models, and SSA-DNN-CO2 flux prediction models include: The feature contributions of ambient temperature and recording time in the SSA-SVM-CO2 flux prediction model, SSA-RF-CO2 flux prediction model and SSA-DNN-CO2 flux prediction model were analyzed by SHAP. The results showed that the feature contribution of recording time was the highest and the feature contribution of ambient temperature was the lowest. The correlation between ambient temperature, recording time, CH4 flux and CO2 flux was analyzed to form a scatter plot matrix and a correlation heatmap. The results showed that CH4 flux had the highest correlation with time and was positively correlated.
10. The environmental parameter evolution analysis method based on the sparrow search algorithm optimization according to claim 9, characterized in that: The algorithm flow of the sparrow search algorithm includes: Step 1: Establish a population X consisting of n sparrows. The expression for population X is: ; Where d is the number of hyperparameters to be optimized. Let n be the position of the nth sparrow in dimension d; Step 2: Set fitness value The fitness value represents an individual sparrow's ability to find food. The expression is: ; in, For the fitness function, Let be the fitness value of the nth sparrow. Let be the position vector of the nth sparrow; Step 3: Based on population X and fitness value Set the location update formula for the discoverer as follows: ; in, For the number of iterations, The maximum number of iterations, , They were respectively in the second sequence During the nth iteration, the 1st The sparrow that was the discoverer was in the first The position of the dimension It is a random number in [0,1]. This is the warning value, and its range is [0,1]. The safe value is [0.5, 1], Q is a random number that follows a normal distribution, and L is a 1×d matrix with all elements being 1; Step 4: Based on population X and fitness value The location update formula for discoverers is set as follows: ; in, In the first In the next iteration, the sparrow, as the discoverer, is in the best position. Let A be the worst possible position for the sparrow that discovers the sparrow, and let A be a 1×d matrix where each element is randomly assigned a value of 1 or -1. ; Step 5: Set the number of scout sparrows to 10% to 20% of the total population. Their initial positions are randomly generated within the population. The behavioral expression for scout alerts is: ; in, Let t be the current globally optimal sparrow position in the t-th iteration, β be a control parameter, a random number following a standard normal distribution, K be a uniform random number with a value range of [-1, 1], and ε be a small constant to avoid the denominator being zero; The fitness value of the sparrow acting as a scout. The sparrow in the best position in the whole game fitness value, Sparrow in the worst position globally The fitness value.
Citation Information
Patent Citations
Land gas flux detection method and device
CN116818608A
Carbon flux prediction method based on whale algorithm optimization neural network
CN118396173A
Oil and gas well yield prediction method and device based on sparrow search algorithm
CN120258181A