A soil fluorine content prediction method based on data analysis
By optimizing the number of hidden layers and the learning rate factor of the BP neural network using the improved Grey Goose optimization algorithm, the problem of low prediction accuracy of soil fluoride content was solved, achieving efficient and universal soil fluoride content prediction that is adaptable to different soil types and environmental conditions, and improving prediction accuracy and generalization ability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENYANG MEDICAL COLLEGE
- Filing Date
- 2026-03-26
- Publication Date
- 2026-06-23
AI Technical Summary
Existing methods for predicting soil fluoride content rely on sample collection and experimental analysis, which are labor-intensive, time-consuming, and costly. Furthermore, traditional methods are unable to fully explore the nonlinear mapping relationship between soil fluoride content and environmental factors, resulting in insufficient prediction accuracy and generalization ability.
An improved Grey Goose Optimization (ZGGO) algorithm is used to optimize the number of hidden layers and the learning rate factor of the BP neural network. By dynamically adjusting the step size parameter through an adaptive optimal strategy and the random jump term of Levy flight, the global search capability and local exploration capability of the model are improved, thus constructing an efficient and general soil fluoride content prediction model.
It significantly improves the accuracy and generalization ability of soil fluoride content prediction, can effectively handle data in complex geological environments, improves training efficiency and prediction accuracy, and is highly adaptable to different soil types and environmental conditions.
Smart Images

Figure CN122266523A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data prediction, and specifically to a method for predicting soil fluoride content based on data analysis. Background Technology
[0002] Currently, obtaining soil fluoride content mainly relies on sample collection and experimental analysis. Although this method offers high analytical precision, it suffers from drawbacks such as high workload, long cycle time, and high cost, making it difficult to meet the application needs of rapid assessment of large-scale soil fluoride distribution. To address this issue, some studies have attempted to model and predict soil fluoride content using statistical regression models or traditional machine learning methods. However, these methods generally rely on linear assumptions or predefined features, making it difficult to fully explore the nonlinear mapping relationship between soil fluoride content and environmental factors, resulting in significant deficiencies in prediction accuracy and generalization ability.
[0003] To address this, researchers have proposed combining intelligent optimization algorithms with neural network models. By using optimization algorithms to perform a global search on the weights and thresholds of the network, the prediction accuracy and stability of the model can be improved. Various intelligent optimization algorithms have achieved good results in parameter optimization problems. However, for the task of predicting soil fluoride content, which is characterized by the complexity of the geological environment and the diversity of data dimensions, there is still a lack of an efficient, universal, and adaptable prediction method.
[0004] The Grey Goose Optimization (GGO) algorithm employs a quadratic decay mechanism in its stochastic update model, causing the control parameter z to decrease rapidly in early iterations. This can lead to premature convergence. Since GGO still needs to search a wide range of solutions for the global optimum during the initial exploration phase, if the control parameter z decreases too quickly, it will prematurely fall into local optima, lacking sufficient global exploration capability. Furthermore, the decay of the control parameter z in the Grey Goose algorithm design relies entirely on the iteration number t and the maximum iteration number T, lacking the ability to dynamically adjust based on the quality of the current solution or the search state. This fixed decay method ignores the dynamic requirements of the Grey Goose algorithm at different problems or stages. Summary of the Invention
[0005] To address the issue of low accuracy in existing soil fluoride content prediction methods, this invention proposes a data analysis-based method for predicting soil fluoride content. This method utilizes an improved Grey Goose Optimization Algorithm (ZGGO) to optimize the number of hidden layers in a backpropagation neural network. With learning rate factor By adjusting parameters, the prediction accuracy of the BP neural network prediction model can be improved, meeting the requirements of complex geological environments and diverse data dimensions. It is an efficient, universal, and highly adaptable prediction method.
[0006] To achieve the above objectives, the present invention is implemented through the following technical solution: a method for predicting soil fluoride content based on data analysis, specifically including the following steps:
[0007] S1. Obtain environmental parameters of soil samples and record the fluoride content data of the current soil environment. Soil environmental parameters include: soil type, pH value, temperature, humidity, soil organic matter content, and salt concentration.
[0008] S2. Preprocess the acquired soil environmental parameter data, remove outliers and noisy data, normalize the data, and divide the dataset into training set and test set.
[0009] S3. Construct a first model for predicting soil fluoride content using a BP neural network. The first prediction model includes an input layer, a hidden layer, an output layer, and training parameters, including: a learning rate factor k, the number of training iterations iter, and the target prediction error.
[0010] S4. The number of hidden layers and the learning rate factor of the first prediction model are optimized using the improved Grey Goose optimization algorithm to obtain the optimal number of hidden layers and the learning rate factor. The improved Grey Goose optimization algorithm includes: improving the optimization position update strategy of the Grey Goose optimization algorithm using an adaptive optimal strategy, improving the step size parameter using a relation factor, and dynamically adjusting the step size to optimize the optimization position update strategy of the Grey Goose optimization algorithm based on the distance between the current search agent position and the global best solution.
[0011] S5. Reconstruct the soil fluoride content prediction model using the optimal number of hidden layers and learning rate factor, and perform final training on the entire training set to obtain the second prediction model. The soil fluoride content prediction model records the feature data in the soil environmental parameters through the training set.
[0012] S6. Input the test set into the second prediction model, train iteratively, calculate the prediction effect through the mean square error function until the target prediction error of soil fluoride content is reached, and output the prediction result of soil fluoride content.
[0013] Preferably, in the selected method for predicting soil fluoride content, the prediction of soil environmental parameters fluoride content is mainly affected by soil type, pH value, temperature, and humidity environmental factors. Through data analysis, multiple soil environmental parameters are selected as prediction input data, including four characteristic data: temperature, humidity, salinity, and pH value. N sets of input data are recorded, and each set of input data contains the corresponding soil environmental parameters. The output data is the prediction result of soil fluoride content.
[0014] Preferably, the random shuffling of environmental parameter data is used to prevent overfitting of the soil fluoride content prediction model, prevent data from exhibiting order dependencies, and ensure that the samples in the training and test sets are representative. Data preprocessing after random shuffling, and following the division into training and test sets, helps the prediction model better learn the impact of environmental parameters on soil fluoride content. Data preprocessing includes handling missing and outlier values, and normalization. The training set is used to train the soil fluoride content prediction model; through repeated training, the model gradually learns the relationship between input features and soil fluoride content. The test set is used to predict soil fluoride content. The test set represents a real-world application scenario; the performance on the test set can be used to evaluate the effectiveness of the soil fluoride content prediction model in real-world environments, i.e., whether the model can correctly predict soil fluoride content on new data.
[0015] Preferably, the first soil fluoride content prediction model is a prediction model constructed based on a standard BP neural network. In this model, the hidden layers extract useful feature representations from the input data features through weighted connections and nonlinear transformations. The number of hidden layers determines the accuracy of the soil fluoride content prediction model. The predictive ability of the prediction model increases with the number of hidden layers, but too many layers can lead to overfitting. Therefore, the number of hidden layers is a parameter that needs to be optimized using advanced methods in this invention to improve the accuracy of soil fluoride content prediction.
[0016] Preferably, the learning rate factor k affects the weight update of the prediction model built on the standard BP neural network. The learning rate factor controls the step size of each weight update. If the learning rate is too large, the weights will be too large, resulting in unstable training of the prediction model. If the learning rate is too small, the prediction model will train slowly and it will be difficult to converge to the global optimum. For the soil fluoride content prediction model, the learning rate needs to be tuned and a suitable learning rate factor needs to be selected.
[0017] Preferably, the optimization of the number of hidden layers and learning rate factor of the prediction second model using the improved Grey Goose Optimization Algorithm includes: first, improving the individual position update mathematical model of the Grey Goose Optimization Algorithm; second, the mapping relationship between the Grey Goose individual positions of the improved Grey Goose Optimization Algorithm and the number of hidden layers and learning rate factor of the prediction first model; and third, updating the individual position update mathematical model of the improved Grey Goose Optimization Algorithm and updating the Grey Goose individual positions, wherein the Grey Goose individual position value is the value of the number of hidden layers and learning rate factor of the prediction first model.
[0018] Preferably, the mathematical model of the step size parameter z in the Grey Goose Optimization Algorithm (GGO) adopts a quadratic decay method. The decay of z depends entirely on the current iteration number t and the maximum iteration number T, and does not have the ability to dynamically adjust according to the quality of the current solution or the search state.
[0019] Preferably, the step size parameter z in the global search phase of the improved grey goose optimization algorithm is achieved by designing a relation degree factor. To reflect the convergence of the grey goose optimization algorithm, and at the same time, by designing the gradient function of the individual grey goose position. To reflect the fitness improvement of an individual greylag goose relative to its neighboring greylag geese, the relationship factor is used. This can improve the overall convergence trend of the Grey Goose optimization algorithm in controlling individuals, while the position gradient function... This can improve the judgment of an individual's local performance and increase the algorithm's exploratory nature when necessary. The improved mathematical model for the step size parameter is as follows:
[0020] (2);
[0021] In equation (2), Let be the improved step size parameter for the current i-th gray goose individual. and To improve the maximum and minimum values of the step size parameter, To set the relation degree factor; Let be the average value of the gradient function of the i-th individual at the position of the t-th iteration.
[0022] Preferably, the gradient function of individual greylag goose positions The mathematical model is as follows:
[0023] (3);
[0024] In equation (3), The position of the i-th gray goose in the t-th iteration The distance from the i-th individual greylag goose's position to the t-th iteration is the nearest position to the i-th individual. distance, for The fitness function value, for The fitness function value.
[0025] Preferred relational factor The mathematical model is as follows:
[0026] (4);
[0027] In equation (4), t is the current iteration number and T is the maximum iteration number.
[0028] Preferably, a mathematical model for updating the individual positions of grey geese in the global search phase of the improved grey goose optimization algorithm is established using improved step size parameters;
[0029] (5);
[0030] In equation (5), Let i be the position of the i-th gray goose in the t-th iteration. This represents the position of the i-th gray goose in the (t+1)-th iteration. Let A and C be the optimal location of the greylag goose in the t-th iteration, and let A and C be control parameters with values ranging from 0 to 2. Let be the improved step size parameter for the current i-th gray goose individual. , and These are the weighting coefficients. , , The locations of three random greylag geese.
[0031] Preferably, the mathematical model design for the development of the region surrounding the optimal solution in the Grey Goose optimization algorithm development stage makes the movement trajectory of individual Grey Goose too deterministic. In the early search stage, if the movement direction of an individual Grey Goose deviates significantly from the global optimum, it lacks sufficient exploration ability. In the later stage, when an individual Grey Goose approaches the optimum, the lack of local small-scale random perturbations leads to low search accuracy, affecting the accuracy of the final solution (optimal number of hidden layers and learning rate factor). Based on the mathematical model for the development of the region surrounding the optimal solution in the Grey Goose optimization algorithm development stage, a random jump term of Levy flight is introduced to improve the position update mathematical model in the Grey Goose optimization algorithm development stage. This allows the movement of individual Grey Goose not only to have local searches around the optimum but also to make large-scale global jumps, making the movement trajectory of individual Grey Goose no longer a deterministic trajectory, avoiding getting trapped in local optima while enhancing exploration ability.
[0032] Preferably, the mathematical model for the optimal solution in the development phase of the grey goose optimization algorithm, which incorporates a random jump term for Levy flight, is as follows:
[0033] (6);
[0034] In equation (6), Let i be the position of the i-th gray goose in the t-th iteration. Let be the position of the i-th gray goose in the (t+1)-th iteration, dim be the question dimension, and w be a random number between 0 and 1. The optimal position for a gray goose globally.
[0035] Preferably, the mapping relationship between the individual positions of gray geese in the improved gray goose optimization algorithm and the number of hidden layers and the learning rate factor of the prediction first model is as follows: In each iteration of the improved gray goose optimization algorithm, a set of candidate positions is generated by updating the mathematical model through the individual positions of gray geese. Each candidate position represents a set of parameters combining the number of hidden layers n and the learning rate factor k. The mathematical model is as follows:
[0036] (7);
[0037] In equation (7), The dimension is 2. Let i be the position of the i-th gray goose. Let be the hidden layer number corresponding to the position of the i-th gray goose. Let be the learning rate factor corresponding to the position of the i-th gray goose; This represents the total number of species.
[0038] Preferably, the specific steps for using the improved Grey Goose optimization algorithm to derive the optimal number of hidden layers and learning rate factor for predicting the first model are as follows:
[0039] S5-1. Set the total population N for the improved Grey Goose optimization algorithm. max The problem dimension dim, the upper bound ub and lower bound lb of the individual position of the grey goose, the maximum number of iterations T, and the maximum and minimum values of the improved step size parameter;
[0040] S5-2. Randomly initialize the positions of individual geese in the improved gray goose optimization algorithm, and define the fitness function of individual gray goose positions using F;
[0041] (8);
[0042] In equation (8), N is the number of samples in the test set. Let j be the predicted value for the j-th sample. This represents the true value of the j-th sample.
[0043] S5-3. Calculate the fitness value of each individual goose at its current position using the fitness function, compare it with the fitness value of the individual goose at its position in the previous iteration, and retain the current minimum fitness value. And the location of the greylag goose with the minimum fitness value is taken as the optimal location;
[0044] S5-4. Is the current iteration number t less than the maximum iteration number T? If yes, then execute S5-5; otherwise, exit the optimization loop and output the optimal position of the gray goose. ;Will The optimal number of hidden layers and learning rate factor are determined.
[0045] S5-5. The improved gray goose optimization algorithm's position update mathematical model is used to update the individual gray goose positions;
[0046] S5-6. Construct an adaptive optimal strategy to adaptively adjust the updated individual positions of gray geese obtained in S5-5.
[0047] S5-7. Boundary constraints are applied to the adaptively adjusted positions of individual grey geese between the upper bound ub and the lower bound lb. The local iteration count t is then incremented by t+1, and S5-3 is executed again.
[0048] Preferably, the adaptive optimal strategy can dynamically adjust the search range according to the progress of the search, which helps the improved grey goose optimization algorithm to find better solutions. The mathematical model is as follows:
[0049] (9);
[0050] In equation (9), This represents the position of the i-th gray goose in the (t+1)-th iteration. The location of the individual greylag goose after adaptive adjustment. The optimal position for a gray goose globally. Let be the neighborhood radius, and the mathematical model is:
[0051] (10);
[0052] In equation (10), The maximum value of the neighborhood radius. It is the minimum neighborhood radius. As the relational factor, The position of the i-th gray goose in the t-th iteration Distance to the globally best individual greylag goose position.
[0053] The optimal number of hidden layers and learning rate factor are used to reconstruct the soil fluoride content prediction model based on a backpropagation neural network. The model includes: an input layer containing environmental parameter types, an optimal number of hidden layers, and an output layer of 1. In the forward propagation, the input layer passes the input environmental parameter data to the hidden layers. Each hidden layer receives the input signal from the previous layer, calculates a weighted sum, and performs a nonlinear mapping using the ReLU activation function f. The mathematical model is as follows: Where V is the output activation value. This is the weight matrix. For environmental parameter data, the output of the hidden layer is weighted and then passed to the output layer. The output layer performs the final calculation to obtain the current soil fluoride content, which is then expressed using the mean squared error function E. The prediction error is calculated, and the weights in the prediction model are updated using the optimal learning rate factor and backpropagation of the prediction error. The mathematical model is: ;in, and For the updated weights and the weights before the update, The optimal learning rate factor is... The gradient of the loss function E with respect to the weights is given. The first prediction model performs forward propagation again based on the new weights to calculate the new prediction error until the target prediction error of soil fluoride content is reached, and then outputs the final prediction result of soil fluoride content.
[0054] The beneficial effects of this invention are as follows: By optimizing the number of hidden layers and the learning rate factor of the BP neural network through the improved Grey Goose Optimization Algorithm (ZGGO), the prediction accuracy of the soil fluoride content prediction model is significantly improved, overcoming the limitations of traditional methods in nonlinear modeling; this method has strong adaptability and can effectively handle complex data under different soil types and environmental conditions, improving global optimization capabilities and avoiding premature convergence to local optima; at the same time, data preprocessing techniques effectively prevent model overfitting, enhance the model's generalization ability, and improve training efficiency, ensuring high-precision predictions are achieved in a short time, thus possessing high practical application value and wide applicability. Attached Figure Description
[0055] Figure 1 A flowchart illustrating the steps involved in predicting soil fluoride content.
[0056] Figure 2 This is a flowchart for predicting the soil fluoride content output by the second model.
[0057] Figure 3 A fitness comparison chart showing the number of hidden layers and learning rate factor of the first prediction model optimized by the improved Grey Goose Optimization Algorithm and the standard Grey Goose Optimization Algorithm.
[0058] Figure 4 A comparison of the learning rate factor results between the improved Grey Goose Optimization Algorithm and the standard Grey Goose Optimization Algorithm.
[0059] Figure 5 A comparison of the hidden layer number results obtained by the improved Grey Goose Optimization Algorithm and the standard Grey Goose Optimization Algorithm.
[0060] Figure 6 A comparison of soil fluoride content results trained by the ZGGO-BP prediction model and the GGO-BP prediction model.
[0061] Figure 7 A comparison chart showing the results of soil fluoride content predictions by the ZGGO-BP prediction model and the GGO-BP prediction model. Detailed Implementation
[0062] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. The following embodiments are only a part of the embodiments of the present invention and are used to provide a clearer explanation of the technical solutions of the present invention. It is understood that the specific embodiments described are only used to explain the present invention, but the implementation of the present invention is not limited thereto.
[0063] This invention provides a method for predicting soil fluoride content based on data analysis, such as... Figure 1 As shown, the code implementation in Matlab is as follows, from S1 to S6:
[0064] S1. Obtain environmental parameters of soil samples and record the fluoride content data of the current soil environment. Soil environmental parameters include: soil type, pH value, temperature, humidity, soil organic matter content, and salt concentration.
[0065] S2. Preprocess the acquired soil environmental parameter data, remove outliers and noisy data, normalize the data, and divide the dataset into training set and test set.
[0066] S3. Construct a first model for predicting soil fluoride content using a BP neural network. The first prediction model includes an input layer, a hidden layer, an output layer, and training parameters, including: a learning rate factor k, the number of training iterations iter, and the target prediction error.
[0067] S4. The number of hidden layers and the learning rate factor of the first prediction model are optimized using the improved Grey Goose optimization algorithm to obtain the optimal number of hidden layers and the learning rate factor. The improved Grey Goose optimization algorithm includes: improving the optimization position update strategy of the Grey Goose optimization algorithm using an adaptive optimal strategy, improving the step size parameter using a relation factor, and dynamically adjusting the step size to optimize the optimization position update strategy of the Grey Goose optimization algorithm based on the distance between the current search agent position and the global best solution.
[0068] S5. Reconstruct the soil fluoride content prediction model using the optimal number of hidden layers and learning rate factor, and perform final training on the entire training set to obtain the second prediction model. The soil fluoride content prediction model records the feature data in the soil environmental parameters through the training set.
[0069] S6. Input the test set into the second prediction model, train iteratively, calculate the prediction effect through the mean square error function until the target prediction error of soil fluoride content is reached, and output the prediction result of soil fluoride content.
[0070] Furthermore, in S1, four environmental parameters—temperature, humidity, salinity, and pH—are used as input data for predicting soil fluoride content. Soil environmental parameters are acquired through sensors, and 110 sets of input data are recorded. Each set of environmental parameter input data includes four characteristic data points—temperature, humidity, salinity, and pH—for the same time period. The output data is the soil fluoride content. The soil environmental parameters and soil fluoride content are summarized in an Excel spreadsheet, such as... Figure 3 As shown, the code importing the sample size N into Matlab using the xlsread function is: N=size(X, 1).
[0071] Furthermore, in S2, the environment parameter data is randomly shuffled using the `randperm` function in Matlab, with the code: `X=X(randperm(N), :)`. The shuffled environment parameter data is then preprocessed, including normalizing it to between 0 and 1. The mathematical model is as follows:
[0072] (11);
[0073] In equation (11), Let j be the j-th feature data after normalization of environmental parameters, where j=1,2,3,4; The j-th feature data before environmental parameter normalization. Let j be the minimum value of the j-th feature data before normalization of the environmental parameters. To find the maximum value of the j-th feature data before environmental parameter normalization, the Matlab code is as follows: X_min=min(X); X_max=max(X); X_normalized=(X-X_min) . / (X_max-X_min); Further, the shuffled and preprocessed dataset is divided into training and test sets in an 8:2 ratio, as shown in the following code: train_ratio=0.8; num_samples=size(X_normalized, 1); num_train=round(train_ratio*num_samples).
[0074] Furthermore, the first soil fluoride content prediction model is a prediction model built based on a standard BP neural network. In this model, the hidden layers extract useful feature representations from the input data features through weighted connections and nonlinear transformations. The number of hidden layers determines the accuracy of the soil fluoride content prediction model. The predictive ability of the model increases with the number of hidden layers, but too many layers can lead to overfitting. Therefore, the number of hidden layers is a parameter that needs to be optimized using advanced methods in this invention to improve the accuracy of soil fluoride content prediction.
[0075] Furthermore, in Matlab, the input layer is set to 4, which is the number of environmental parameter features; the hidden layer is set to an initial value of 3 and the output layer to 1; the learning rate factor k is set to an initial value of 0.5, the number of training iterations is set to 800, and the target prediction error is set to 1e-4; a standard BP neural network is built using the feedforwardnet function, as shown in the following code: net = feedforwardnet(hidden_layer_size).
[0076] Furthermore, the improved Grey Goose Optimization Algorithm is used to optimize the number of hidden layers and the learning rate factor of the second prediction model, including: first, improving the individual position update mathematical model of the Grey Goose Optimization Algorithm; second, the mapping relationship between the Grey Goose individual positions of the improved Grey Goose Optimization Algorithm and the number of hidden layers and the learning rate factor of the first prediction model; and third, updating the individual position update mathematical model of the improved Grey Goose Optimization Algorithm and updating the Grey Goose individual positions, wherein the Grey Goose individual position value is the value of the number of hidden layers and the learning rate factor of the first prediction model.
[0077] Furthermore, the step size parameter z in the global search phase of the Grey Goose optimization algorithm is improved by designing a relation degree factor. To reflect the convergence of the grey goose optimization algorithm, and at the same time, by designing the gradient function of the individual grey goose position. To reflect the fitness improvement of an individual greylag goose relative to its neighboring greylag geese, the relationship factor is used. This can improve the overall convergence trend of the Grey Goose optimization algorithm in controlling individuals, while the position gradient function... This can improve the judgment of an individual's local performance and increase the algorithm's exploratory nature when necessary. The improved mathematical model for the step size parameter is as follows:
[0078] (2);
[0079] In equation (2), Let be the improved step size parameter for the current i-th gray goose individual. and To improve the maximum and minimum values of the step size parameter, To set the relation degree factor; Let be the average value of the gradient function of the i-th individual at the position in the t-th iteration;
[0080] Among them, the gradient function of individual greylag goose positions The mathematical model is as follows:
[0081] (3);
[0082] In equation (3), The position of the i-th gray goose in the t-th iteration The distance from the i-th individual greylag goose's position to the t-th iteration is the nearest position to the i-th individual. distance, for The fitness function value, for The fitness function value;
[0083] Among them, the relation degree factor The mathematical model is as follows:
[0084] (4);
[0085] In equation (4), t is the current iteration number and T is the maximum iteration number.
[0086] Furthermore, the improved step size parameter code is completed in MATLAB, as follows: Calculate the relation factor: alpha_t(t) = atan(2*pi*sqrt(t / T)) / atan(2*pi); Calculate the average value of the position gradient function g(i,t): avg_g_i_t=mean(g_i_t(:, t)); Calculate the step size parameter for each individual greylag goose: for i = 1:n; z_i(i, t)=z_min+(z_max-z_min)*avg_g_i_t / (avg_g_i_t+alpha_t(t)-alpha_c_t(t)).
[0087] Furthermore, a mathematical model for updating the individual positions of grey geese in the global search phase of the improved grey goose optimization algorithm is established using the improved step size parameter.
[0088] (5);
[0089] In equation (5), Let i be the position of the i-th gray goose in the t-th iteration. This represents the position of the i-th gray goose in the (t+1)-th iteration. Let A and C be the optimal location of the greylag goose in the t-th iteration, and let A and C be control parameters with values ranging from 0 to 2. Let be the improved step size parameter for the current i-th gray goose individual. , and These are the weighting coefficients. , , The locations of three random greylag geese.
[0090] Furthermore, the mathematical model for the optimal solution surrounding the region in the development phase of the improved grey goose optimization algorithm, which incorporates a random jump term for Levy flight, is as follows:
[0091] (6);
[0092] In equation (6), Let i be the position of the i-th gray goose in the t-th iteration. Let be the position of the i-th gray goose in the (t+1)-th iteration, dim be the question dimension, and w be a random number between 0 and 1. The optimal position for a gray goose globally.
[0093] Furthermore, the adaptive optimal strategy can dynamically adjust the search range according to the progress of the search, which helps the improved grey goose optimization algorithm to discover better solutions. The mathematical model is as follows:
[0094] (9);
[0095] In equation (9), This represents the position of the i-th gray goose in the (t+1)-th iteration. The location of the individual greylag goose after adaptive adjustment. The optimal position for a gray goose globally. Let be the neighborhood radius, and the mathematical model is:
[0096] (10);
[0097] In equation (10), The maximum value of the neighborhood radius. It is the minimum neighborhood radius. As the relational factor, The position of the i-th gray goose in the t-th iteration Distance to the globally best individual greylag goose position.
[0098] Furthermore, the adaptive optimal strategy code in Matlab is as follows:
[0099] for t = 1:T;
[0100] alpha_t(t) = atan(2 * pi * sqrt(t / T)) / atan(2 * pi);
[0101] for i = 1:n;
[0102] distance = sqrt(sum((X_i(i, :) - X_best).^2));
[0103] r(t) r_t = r_min + (r_max - r_min) * (exp(-alpha_t(t)) + distance);
[0104] for d = 1:dim;
[0105] rand_val = (2 * rand - 1) * r_t;
[0106] X_i_new(i, d, t) = X_best(d) + rand_val * X_i(i, d).
[0107] Furthermore, the mapping relationship between the individual positions of gray geese in the improved gray goose optimization algorithm and the number of hidden layers and the learning rate factor of the first prediction model is as follows: In each iteration of the improved gray goose optimization algorithm, a set of candidate positions is generated by updating the mathematical model through the individual positions of gray geese. Each candidate position represents a set of parameters combining the number of hidden layers n and the learning rate factor k. The mathematical model is as follows:
[0108] (7);
[0109] In equation (7), The dimension is 2. Let i be the position of the i-th gray goose. Let be the hidden layer number corresponding to the position of the i-th gray goose. Let be the learning rate factor corresponding to the position of the i-th gray goose; This represents the total number of species.
[0110] Furthermore, the specific steps for deriving the optimal number of hidden layers and learning rate factor for predicting the first model using the improved Grey Goose optimization algorithm are as follows:
[0111] S5-1. Set the total population N for the improved Grey Goose optimization algorithm. max The problem dimension dim, the upper bound ub and lower bound lb of the individual position of the grey goose, the maximum number of iterations T, and the maximum and minimum values of the improved step size parameter;
[0112] S5-2. Randomly initialize the positions of individual geese in the improved gray goose optimization algorithm, and define the fitness function of individual gray goose positions using F;
[0113] (8);
[0114] In equation (8), N is the number of samples in the test set. Let j be the predicted value for the j-th sample. This represents the true value of the j-th sample.
[0115] S5-3. Calculate the fitness value of each individual goose at its current position using the fitness function, compare it with the fitness value of the individual goose at its position in the previous iteration, and retain the current minimum fitness value. And the location of the greylag goose with the minimum fitness value is taken as the optimal location;
[0116] S5-4. Is the current iteration number t less than the maximum iteration number T? If yes, then execute S5-5; otherwise, exit the optimization loop and output the optimal position of the gray goose. ;Will The optimal number of hidden layers and learning rate factor are determined.
[0117] S5-5. The improved gray goose optimization algorithm's position update mathematical model is used to update the individual gray goose positions;
[0118] S5-6. Construct an adaptive optimal strategy to adaptively adjust the updated individual positions of gray geese obtained in S5-5.
[0119] S5-7. Boundary constraints are applied to the adaptively adjusted positions of individual grey geese between the upper bound ub and the lower bound lb. The local iteration count t is then incremented by t+1, and S5-3 is executed again.
[0120] Furthermore, in Matlab, the lower bound of the individual position of the greylag goose is set as lb = [6 1e-4], and the upper bound as ub = [321e-3]; the problem dimension dim = 2, i.e., the number of parameters to be optimized; and the total population N of the improved greylag goose optimization algorithm is set. max =30; Maximum number of iterations T=70, the maximum value of the improved step size parameter is 1 and the minimum value is 0.1. The improved Grey Goose Optimization Algorithm (ZGGO) is used to obtain the optimal number of hidden layers and learning rate factor for predicting the first model. The Matlab code is: [Best_score, Best_pos, curve] =ZECO(SearchAgents_no, Max_iteration, lb, ub, dim,fun); The optimal Grey Goose individual position value is decoded and assigned to the optimal number of hidden layers and the optimal learning rate factor. The Matlab code is: best_hd = round(Best_pos(1,1)); best_lr = Best_pos(1,2).
[0121] Furthermore, such as Figure 2As shown, the optimal number of hidden layers and learning rate factor are used to reconstruct the soil fluoride content prediction model based on a backpropagation neural network. The model includes: an input layer containing soil environmental parameter types, an optimal number of hidden layers, and an output layer of 1. In the forward propagation, the input layer passes the input environmental parameter data to the hidden layers. Each hidden layer receives the input signal from the previous layer, calculates a weighted sum, and performs a nonlinear mapping using the ReLU activation function f. The mathematical model is as follows: Where V is the output activation value. This is the weight matrix. For environmental parameter data, the output of the hidden layer is weighted and then passed to the output layer. The output layer performs the final calculation to obtain the current soil fluoride content, which is then expressed using the mean squared error function E. The prediction error is calculated, and the weights in the prediction model are updated using the optimal learning rate factor and backpropagation of the prediction error. The mathematical model is: ;in, and For the updated weights and the weights before the update, The optimal learning rate factor is... The gradient of the loss function E with respect to the weights is given. The first prediction model performs forward propagation again based on the new weights to calculate the new prediction error until the target prediction error of soil fluoride content is reached, and then outputs the final prediction result of soil fluoride content.
[0122] Furthermore, to verify the beneficial effects of the method of the present invention, the standard Grey Goose Optimization Algorithm (GGO) was introduced and compared with the improved Grey Goose Optimization Algorithm (ZGGO). A comparison was made between the soil fluoride content prediction model established based on the standard Grey Goose Optimization Algorithm and the soil fluoride content prediction model established based on the improved Grey Goose Optimization Algorithm, yielding the following results: Figure 3 , Figure 4 , Figure 5 , Figure 6 Resulting graph; as shown Figure 3 As shown in the figure, the improved Grey Goose Optimization Algorithm (ZGGO) decreases in fitness value faster and has a lower fitness value when optimizing the first prediction model based on BP than the standard Grey Goose Optimization Algorithm. The lower the fitness value, the higher the optimization accuracy of the algorithm. As can be seen from the figure, the comparison of fitness values shows that the improved Grey Goose Optimization Algorithm (ZGGO) is significantly better than the standard Grey Goose Optimization Algorithm (GGO) when predicting soil fluoride content. ZGGO can quickly find a better solution in the early stage of iteration and maintain a stable low fitness value in the later stage of iteration, indicating that the improved GGO algorithm has better optimization performance and convergence speed. In contrast, GGO has a slower optimization speed and a higher final fitness value, indicating that its performance is relatively poor.
[0123] Furthermore, the optimal learning rate and optimal number of hidden layers obtained through optimization are as follows: Figure 4 and Figure 5 As shown, after 60 iterations, the optimal learning rate of the ZGGO-BP prediction model was 0.0001 and the optimal number of hidden layers was 6. The optimal learning rate of the ZGGO-BP prediction model was 0.001 and the optimal number of hidden layers was 32. Using the optimal number of hidden layers and learning rate factor, the soil fluoride content prediction model was reconstructed and finally trained on the entire training set, yielding the results. Figure 6 The training results of the ZGGO-BP prediction model and the GGO-BP prediction model are compared. Analysis of the training results shows that the curve trend of the ZGGO-BP model fits the actual soil fluoride content more closely and can track the changes in actual values better in areas with large fluctuations. While the GGO-BP model can also roughly reflect the changing trend of actual soil fluoride content, it deviates significantly at some data points, especially in areas with drastic fluctuations, exhibiting a certain degree of lag and overfitting. Overall, the ZGGO-BP model has a smaller prediction error, especially at sample peak and trough points, where its predicted values are closer to the actual values. The GGO-BP model performs relatively poorly in extreme value areas, with larger errors, indicating the limitations of the standard Grey Goose optimization algorithm in handling complex nonlinear problems.
[0124] Furthermore, the test set is input into the second prediction model, and the output is as follows: Figure 7 The comparison chart showing the prediction results of the ZGGO-BP prediction model and the GGO-BP prediction model indicates that the improved Grey Goose Optimization Algorithm (ZGGO) combined with the BP neural network model has higher prediction accuracy and better generalization ability than the standard Grey Goose Optimization Algorithm (GGO) when predicting soil fluoride content. The ZGGO-BP model can better fit the actual data, especially when dealing with large data fluctuations, it can still maintain a small error.
Claims
1. A method for predicting soil fluoride content based on data analysis, characterized in that, The specific steps include: S1. Obtain environmental parameters of soil samples and record the fluoride content data of the current soil environment. Soil environmental parameters include: soil type, pH value, temperature, humidity, soil organic matter content, and salt concentration. S2. Preprocess the acquired soil environmental parameter data, remove outliers and noisy data, normalize the data, and divide the dataset into training set and test set. S3. Construct a first model for predicting soil fluoride content using a BP neural network. The first prediction model includes an input layer, a hidden layer, an output layer, and training parameters, including: a learning rate factor k, the number of training iterations iter, and the target prediction error. S4. The number of hidden layers and the learning rate factor of the first prediction model are optimized using the improved Grey Goose optimization algorithm to obtain the optimal number of hidden layers and the learning rate factor. The improved Grey Goose optimization algorithm includes: improving the optimization position update strategy of the Grey Goose optimization algorithm using an adaptive optimal strategy, improving the step size parameter using a relation factor, and dynamically adjusting the step size to optimize the optimization position update strategy of the Grey Goose optimization algorithm based on the distance between the current search agent position and the global best solution. S5. Reconstruct the soil fluoride content prediction model using the optimal number of hidden layers and learning rate factor, and perform final training on the entire training set to obtain the second prediction model. The soil fluoride content prediction model records the feature data in the soil environmental parameters through the training set. S6. Input the test set into the second prediction model, train iteratively, calculate the prediction effect through the mean square error function until the target prediction error of soil fluoride content is reached, and output the prediction result of soil fluoride content.
2. The method for predicting soil fluoride content based on data analysis according to claim 1, characterized in that, Multiple environmental parameters of the soil are selected as prediction input data, including four feature data: temperature, humidity, salinity, and pH. N sets of input data are recorded. Each set of input data contains the four feature data of temperature, humidity, salinity, and pH for the same time period. The output data is the soil fluoride content.
3. The method for predicting soil fluoride content based on data analysis according to claim 2, characterized in that, S4 utilizes an improved Grey Goose optimization algorithm to optimize the number of hidden layers and the learning rate factor of the first prediction model. First, it establishes a mapping relationship between the individual Grey Goose positions in the improved Grey Goose optimization algorithm and the number of hidden layers and the learning rate factor of the first prediction model. Specifically, in each iteration of the improved Grey Goose optimization algorithm, a set of candidate positions is generated by updating the mathematical model through the individual Grey Goose positions. Each candidate position represents a combination of hidden layer number n and learning rate factor k parameters. The mathematical model is as follows: (7); In equation (7), The dimension is 2. Let i be the position of the i-th gray goose. Let be the hidden layer number corresponding to the position of the i-th gray goose. Let be the learning rate factor corresponding to the position of the i-th gray goose; This represents the total number of species.
4. The method for predicting soil fluoride content based on data analysis according to claim 3, characterized in that, The improved grey goose optimization algorithm includes: firstly, improving the step size parameter z in the global search phase of the grey goose optimization algorithm, and using the improved step size parameter to establish a mathematical model for updating the individual grey goose positions in the global search phase of the improved grey goose optimization algorithm. The mathematical model is as follows: (5); In equation (5), Let i be the position of the i-th gray goose in the t-th iteration. This represents the position of the i-th gray goose in the (t+1)-th iteration. Let A and C be the optimal location of the greylag goose in the t-th iteration, and let A and C be control parameters with values ranging from 0 to 2. Let be the improved step size parameter for the current i-th gray goose individual. , and These are the weighting coefficients. , , The locations of three random greylag geese; Secondly, an improved greylag goose optimization algorithm, incorporating a random jump term from Levy's flight, is developed using a mathematical model for updating the individual greylag goose positions in the surrounding area. The mathematical model is as follows: (6); In equation (6), Let i be the position of the i-th gray goose in the t-th iteration. Let be the position of the i-th gray goose in the (t+1)-th iteration, dim be the question dimension, and w be a random number between 0 and 1. The optimal position for a gray goose globally.
5. The method for predicting soil fluoride content based on data analysis according to claim 4, characterized in that, The improved step size parameter is achieved by designing a relational factor. To reflect the convergence of the grey goose optimization algorithm, and at the same time, by designing the gradient function of the individual grey goose position. To reflect the fitness improvement of individual greylag geese relative to their neighboring greylag geese, the improved mathematical model for the step size parameter is as follows: (2); In equation (2), Let be the improved step size parameter for the current i-th gray goose individual. and To improve the maximum and minimum values of the step size parameter, To set the relation degree factor; Let be the average value of the position gradient function of the i-th individual in the t-th iteration, and be the position gradient function of the greylag goose individual. The mathematical model is as follows: (3); In equation (3), The position of the i-th gray goose in the t-th iteration The distance from the i-th individual greylag goose's position to the t-th iteration is the nearest position to the i-th individual. distance, for The fitness function value, for The fitness function value; Relationship Factor The mathematical model is as follows: (4); In equation (4), t is the current iteration number and T is the maximum iteration number.
6. The method for predicting soil fluoride content based on data analysis according to claim 5, characterized in that, In step S4, the specific steps for optimizing the number of hidden layers and the learning rate factor of the first prediction model using the improved Grey Goose optimization algorithm are as follows: S5-1. Set the total population N for the improved Grey Goose optimization algorithm. max The problem dimension dim, the upper bound ub and lower bound lb of the individual position of the grey goose, the maximum number of iterations T, and the maximum and minimum values of the improved step size parameter; S5-2. Randomly initialize the positions of individual geese in the improved gray goose optimization algorithm, and define the fitness function of individual gray goose positions using F; (8); In equation (8), N is the number of samples in the test set. Let j be the predicted value for the j-th sample. This represents the true value of the j-th sample. S5-3. Calculate the fitness value of each individual goose at its current position using the fitness function, compare it with the fitness value of the individual goose at its position in the previous iteration, and retain the current minimum fitness value. And the location of the greylag goose with the minimum fitness value is taken as the optimal location; S5-4. Is the current iteration number t less than the maximum iteration number T? If yes, then execute S5-5; otherwise, exit the optimization loop and output the optimal position of the gray goose. ,Will The optimal number of hidden layers and learning rate factor are determined. S5-5. The improved gray goose optimization algorithm's position update mathematical model is used to update the individual gray goose positions; S5-6. Construct an adaptive optimal strategy to adaptively adjust the updated individual positions of gray geese obtained in S5-5. S5-7. Boundary constraints are applied to the adaptively adjusted positions of individual grey geese between the upper bound ub and the lower bound lb. The local iteration count t is then incremented by t+1, and S5-3 is executed again.
7. The method for predicting soil fluoride content based on data analysis according to claim 6, characterized in that, The mathematical model for the adaptive optimal strategy is as follows: (9); In equation (9), This represents the position of the i-th gray goose in the (t+1)-th iteration. The location of the individual greylag goose after adaptive adjustment. The optimal position for a gray goose globally. Let be the neighborhood radius, and the mathematical model is: (10); In equation (10), The maximum value of the neighborhood radius. It is the minimum neighborhood radius. As the relational factor, The position of the i-th gray goose in the t-th iteration Distance to the globally best individual greylag goose position.
8. The method for predicting soil fluoride content based on data analysis according to claim 6, characterized in that, A soil fluoride content prediction model was reconstructed using the optimal number of hidden layers and learning rate factor. The specific steps are as follows: the input layer contains the types of soil environmental parameters, the hidden layer contains the optimal number of hidden layers, and the output layer is 1. In the forward propagation, the input layer passes the input environmental parameter data to the hidden layers. Each hidden layer receives the input signal from the previous layer, calculates the weighted sum, and performs a nonlinear mapping using the ReLU activation function f. The mathematical model is as follows: Where V is the output activation value. This is the weight matrix. For environmental parameter data, the output of the hidden layer is weighted and then passed to the output layer. The output layer performs the final calculation to obtain the current soil fluoride content, which is then expressed using the mean squared error function E. The prediction error is calculated, and the weights in the prediction model are updated using the optimal learning rate factor and backpropagation of the prediction error. The mathematical model is: ;in, and For the updated weights and the weights before the update, The optimal learning rate factor is... The gradient of the loss function E with respect to the weights is given. The first prediction model performs forward propagation again based on the new weights to calculate the new prediction error until the target prediction error of soil fluoride content is reached, and then outputs the final prediction result of soil fluoride content.