Lycium barbarum garden soil quality evaluation method and system based on random forest
By applying random forest algorithm and principal component analysis method to screen features in wolfberry garden, combining exhaustive method and genetic algorithm to optimize parameters, the data complexity and interpretation difficulty problems in soil quality evaluation are solved, and high accuracy and automation are achieved. Soil quality evaluation provides detailed evaluation reports and visual results, improving the scientificity and efficiency of agricultural management.
Patent Information
- Application Number
- CN202411289187.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2024-12-20
AI Technical Summary
In the soil quality evaluation of wolfberry gardens, the existing technology faces the challenges of data acquisition and processing, feature selection and parameter setting, as well as the difficulty of interpretation and visualization of model output, which affects the accuracy and reliability of the evaluation.
A random forest-based method is used to screen key feature subsets in combination with principal component analysis method, build a soil quality evaluation model, and optimize parameters through exhaustive method and genetic algorithm to generate a detailed quality evaluation report, and use data visualization technology to interpret the results.
Improve the accuracy and robustness of soil quality evaluation, reduce calculation volume and noise, realize automation and intelligence, provide transparent and interpretable evaluation process, save manpower and time costs, is highly adaptable, and can have in-depth understanding. Key factors affecting soil quality.
Smart Images

Figure CN119168505A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of smart agriculture and data analysis technology, and specifically relates to a method and system for evaluating soil quality in a wolfberry garden based on random forest. Background Art
[0002] In the evaluation of soil quality in wolfberry gardens, the application of random forest algorithm faces the problem of complexity in data collection and processing. First of all, the evaluation of soil quality requires a comprehensive analysis of multiple indicators, such as pH value, organic matter content, total nitrogen content, etc. These indicators need to be obtained through a variety of sensors and laboratory testing methods. However, the accuracy and sensitivity of different sensors and detection methods vary, which may lead to data heterogeneity and inconsistency. In addition, the time and location of soil sample collection will also affect the representativeness of the data, and thus affect the accuracy of the model.
[0003] Secondly, although the random forest algorithm has advantages in processing high-dimensional data and nonlinear relationships, it is still a challenge to select appropriate feature sets and parameter settings in soil quality evaluation. Improper feature selection may lead to overfitting or underfitting of the model, thus affecting the reliability of the evaluation results. At the same time, the "black box" characteristics of the random forest model make it difficult to explain the specific reasons for the model output results, which puts higher requirements on identifying the key factors affecting soil quality.
[0004] Finally, the visualization and interpretation of soil quality evaluation results is also a technical challenge. How to transform complex model outputs into easy-to-understand soil quality evaluation reports so that agricultural managers and decision makers can conduct scientific soil management is an urgent problem to be solved. This requires combining data visualization technology and domain knowledge to provide intuitive and meaningful soil quality information. Summary of the invention
[0005] In view of the shortcomings of the prior art, the present invention provides a soil quality evaluation method and system for a wolfberry garden based on random forest, which significantly improves the accuracy and practicality of soil quality evaluation and provides strong support for precision agricultural management.
[0006] To achieve the above object, the present invention provides the following solutions:
[0007] A method for evaluating soil quality in wolfberry gardens based on random forests comprises the following steps:
[0008] Collect soil property data of wolfberry garden;
[0009] Based on the soil property data, soil quality characteristics are obtained;
[0010] Using principal component analysis, the soil quality characteristics are screened to obtain a key feature subset;
[0011] Based on key feature subsets and random forest algorithm, a soil quality evaluation model was constructed;
[0012] The quality of the wolfberry garden soil to be evaluated is evaluated based on the soil quality evaluation model to obtain a quality evaluation report.
[0013] Preferably, the soil property data include soil texture, bulk density, porosity, pH value, organic matter content, total nitrogen, total phosphorus, total potassium, available nutrient content, and soil microbial quantity and activity.
[0014] Preferably, the method for obtaining soil quality characteristics based on the soil property data is:
[0015] Cleaning the soil attribute data;
[0016] Calculating the differential entropy of the cleaned soil attribute data, discretizing the data, and obtaining discrete soil attribute data;
[0017] Calculating information gain of the discrete soil property data;
[0018] Calculate the weight of each discrete soil attribute data based on the information gain of each discrete soil attribute data and the total number of data;
[0019] The soil quality characteristics are constructed based on the weights of each discrete soil attribute data.
[0020] Preferably, the method for obtaining the key feature subset is:
[0021] Based on the soil quality characteristics, an initial feature matrix is constructed; wherein the rows of the initial feature matrix represent soil sampling points, and the columns represent each of the soil quality characteristics;
[0022] Performing principal component analysis on the initial feature matrix to obtain eigenvalues;
[0023] Based on the size of the eigenvalue, the number of principal components is obtained, and the variance contribution rate of each principal component is calculated;
[0024] When the variance contribution rate meets a preset threshold, the principal component corresponding to the variance contribution rate is used as a new soil quality feature;
[0025] Based on the new soil quality characteristics, a subset of key characteristics was obtained.
[0026] Preferably, the method for constructing a soil quality evaluation model based on a key feature subset and a random forest algorithm is:
[0027] By using an exhaustive method, all feature values in the key feature subset are traversed to obtain feature segmentation variables and segmentation points that meet preset conditions;
[0028] Based on the characteristic mean of the split points, a mean square error impurity function is established;
[0029] Based on the mean square error impurity function, obtaining the impurity weighted sum of the split points;
[0030] The decision tree of the random forest is segmented based on the impurity weighting to obtain the soil quality evaluation model.
[0031] Preferably, a genetic algorithm is used to optimize the parameters of the soil quality evaluation model.
[0032] The present invention also provides a wolfberry garden soil quality evaluation system based on random forest, which is used to implement the wolfberry garden soil quality evaluation method based on random forest, comprising:
[0033] Data collection module, used to collect soil property data of wolfberry garden;
[0034] A feature extraction module, used for obtaining soil quality features based on the soil attribute data;
[0035] A feature screening module, used to screen the soil quality features using principal component analysis to obtain a key feature subset;
[0036] Model building module, used to build soil quality assessment model based on key feature subsets and random forest algorithm;
[0037] The evaluation module is used to evaluate the quality of the wolfberry garden soil to be evaluated based on the soil quality evaluation model to obtain a quality evaluation report.
[0038] Preferably, the feature extraction module includes:
[0039] A data cleaning unit, used for cleaning the soil attribute data;
[0040] A data discretization unit is used to calculate the differential entropy of the cleaned soil attribute data, discretize the data, and obtain discrete soil attribute data;
[0041] A gain calculation unit, used for calculating the information gain of the discrete soil attribute data;
[0042] A weight calculation unit, used for calculating the weight of each discrete soil property data based on the information gain of each discrete soil property data and the total number of data;
[0043] The feature construction unit is used to construct the soil quality feature based on the weight of each discrete soil attribute data.
[0044] Compared with the prior art, the beneficial effects of the present invention are as follows: through the random forest algorithm, the method of the present invention can make full use of the multi-dimensional attribute data of the soil in the wolfberry garden, and combine the powerful classification and regression capabilities of the random forest to evaluate the soil quality more accurately and comprehensively. By constructing multiple decision trees and integrating their prediction results, the random forest effectively reduces the overfitting risk of a single model and improves the robustness and accuracy of the evaluation. The principal component analysis method is used to screen the soil quality characteristics, which can remove redundant information and noise and retain the key features that have the greatest impact on soil quality. This process not only reduces the amount of calculation and improves the efficiency of model training, but also makes the evaluation model more concise and clear, easy to understand and apply. The present invention realizes the automation and intelligence of the soil quality evaluation of the wolfberry garden. By constructing a soil quality evaluation model, the quality of the soil to be evaluated can be quickly evaluated, and a detailed quality evaluation report can be generated. This greatly saves manpower and time costs and improves work efficiency. The random forest model can provide feature importance evaluation, making the evaluation process more transparent and explainable. By analyzing the importance of key features, we can deeply understand which factors have the greatest impact on soil quality and provide a scientific basis for soil management and improvement. Strong adaptability: This method has strong adaptability and can be adjusted and optimized for different wolfberry garden soil conditions. By adjusting the parameters of the random forest model or retraining the model, it can be better adapted to the soil quality evaluation needs of different regions. Through scientific soil quality evaluation methods, soil problems can be discovered in a timely manner, and corresponding management measures can be taken to improve them. This will help improve the health of wolfberry garden soil, increase the yield and quality of wolfberries, and promote the sustainable development of the wolfberry industry. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0046] Figure 1 The present invention is a flowchart of a method for evaluating soil quality in a wolfberry garden based on random forests according to an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0049] Embodiment 1
[0050] like Figure 1 As shown, a method for evaluating soil quality in wolfberry garden based on random forest includes the following steps:
[0051] S1: Using a variety of sensors and laboratory testing methods to collect soil property data of wolfberry garden; a further implementation method is that the soil property data includes soil texture, bulk density, porosity, pH value, organic matter content, total nitrogen, total phosphorus, total potassium, available nutrient content, soil microbial quantity and activity.
[0052] S2: obtaining soil quality characteristics based on soil attribute data; a further implementation method is that the method for obtaining soil quality characteristics based on soil attribute data is:
[0053] Clean the soil attribute data; in this embodiment, if the data is heterogeneous, data cleaning is performed to fill missing values, remove outliers, etc. The cleaned soil attribute data is converted into a unified format through data standardization technology.
[0054] Calculate the differential entropy of the cleaned soil attribute data, discretize the data, and obtain discrete soil attribute data;
[0055] Calculate information gain for discrete soil property data;
[0056] Based on the information gain of each discrete soil property data and the total number of data, the weight of each discrete soil property data is calculated; in this embodiment,
[0057]
[0058] Among them, ω j is the weight of the jth attribute, IG(A j ) is the information gain of the j-th attribute, and m is the total number of attributes.
[0059] Soil quality characteristics are constructed based on the weights of each discrete soil attribute data.
[0060] In this embodiment, soil quality characteristics include physical property characteristics, chemical property characteristics and biological property characteristics, and each characteristic is composed of discrete soil attribute data with different weights rather than being directly composed of soil attribute data.
[0061] Among them, physical property characteristics include: Soil texture: determined by the distribution of soil particle size (the ratio of sand, silt, and clay), which affects the soil's water retention capacity, aeration, and root penetration. Bulk density: the dry weight of soil per unit volume, reflecting the compactness of the soil, affecting root growth and soil aeration. Porosity: the ratio of soil pore volume to total volume, affecting the soil's water and air content.
[0062] Chemical properties include: pH value: an indicator of soil acidity and alkalinity, which affects the effectiveness of nutrients and the absorption of nutrients by plants. Organic matter content: an important indicator of soil fertility and biological activity, affecting soil structure, water retention capacity and nutrient circulation. Total nitrogen, total phosphorus, and total potassium: the total nutrient content in the soil, which is an important basis for evaluating soil fertility. Available nutrient content (such as available nitrogen, available phosphorus, and available potassium): the nutrient content that can be directly absorbed and utilized by plants, which has a direct impact on plant growth.
[0063] Biological properties include: Soil microbial quantity and activity: Indicators of soil biodiversity and biological activity, which play an important role in soil nutrient cycling and plant health. Enzyme activity: The activity of certain soil enzymes (such as urease, phosphatase, etc.) can reflect the biochemical process and nutrient conversion capacity of the soil.
[0064] S3: Using principal component analysis, soil quality characteristics are screened to obtain a key feature subset; a further implementation method is that the method for obtaining the key feature subset is:
[0065] Based on the soil quality characteristics, an initial feature matrix is constructed; wherein the rows of the initial feature matrix represent soil sampling points, and the columns represent each soil quality characteristic;
[0066] Perform principal component analysis on the initial feature matrix to obtain eigenvalues;
[0067] Based on the size of the eigenvalue, the number of principal components is obtained, and the variance contribution rate of each principal component is calculated;
[0068] When the variance contribution rate meets the preset threshold, the principal component corresponding to the variance contribution rate is used as a new soil quality feature;
[0069] Based on the new soil quality characteristics, a subset of key characteristics was obtained.
[0070] S4: Based on the key feature subset and the random forest algorithm, a soil quality evaluation model is constructed; a further implementation method is that the method for constructing the soil quality evaluation model based on the key feature subset and the random forest algorithm is:
[0071] Use the exhaustive method to traverse all the feature values in the key feature subset to obtain the feature segmentation variables and segmentation points that meet the preset conditions;
[0072] Based on the feature mean of the split point, a mean square error impurity function is established; in this embodiment, the formula of the mean square error impurity function is as follows:
[0073]
[0074] X s is the key feature training set of the current split point, n s is the number of training sets for the current split point, is the feature mean of the current split point.
[0075] Based on the mean square error (MSE) impurity function, the weighted sum of impurities at the split points is obtained; in this embodiment, in the construction process of a single decision tree, the focus is on how to maximize the reduction in impurity at each split. The purpose of calculating the weighted sum is to clarify the overall contribution of all decision trees to impurity in the entire forest.
[0076] Based on the impurity weighted sum, multiple decision trees of the random forest are segmented to obtain a soil quality evaluation model. Specifically, in the present embodiment, the evaluation result of the soil quality evaluation model is the mean of the prediction results of multiple decision trees in the random forest. When performing decision tree segmentation, for each candidate split, the MSE change before and after the split is calculated, and the split that results in the largest reduction in MSE is selected as the best split. This process is repeated on each node of the decision tree until the stopping condition is met. The stopping condition includes but is not limited to reaching the maximum depth, the number of samples in the node is less than a certain threshold, the MSE reduction is less than a certain threshold, etc., and is adjusted according to actual conditions.
[0077] A further implementation method is to use a genetic algorithm to optimize the parameters of the soil quality evaluation model. Specifically, the global optimization capability of the genetic algorithm is used to dynamically adjust the probability of genetic operations and optimize the random forest framework parameters and decision tree parameters:
[0078] First, the parameters to be optimized (the number of trees in the random forest, the maximum depth of the tree, and the minimum number of samples required for splitting) are encoded as individuals (chromosomes) in the genetic algorithm;
[0079] Secondly, the fitness function is defined to evaluate the quality of each individual. In the soil quality evaluation model, the fitness function is the model performance index (MSE and R2 Fraction).
[0080] Then, according to the fitness function, the roulette wheel selection method is used to select excellent individuals for reproduction. The selected individuals are paired with each other, and some genes are exchanged through multi-point crossover operations to generate new individuals.
[0081] Mutate certain genes of individuals with a preset probability to increase the diversity of the population. (The crossover probability and mutation probability are adaptively adjusted according to the fitness of the individual or the evolutionary state of the population)
[0082] Repeat the selection, crossover, and mutation operations until the fitness reaches the preset threshold.
[0083] S5: Based on the soil quality evaluation model, the quality of the wolfberry garden soil to be evaluated is evaluated to obtain a quality evaluation report. Specifically, the trained soil quality evaluation model is used to predict the quality of the processed soil data. Assume that the soil quality score output by the model is between 0 and 100, and the higher the score, the better the soil quality. Through model prediction, the soil quality score of each sample is obtained. Linear regression analysis is performed on the soil quality score and the soil nutrient content data. It is assumed that the soil quality score is significantly positively correlated with the nitrogen content, and the correlation coefficient is 75. Further, a multivariate regression analysis is performed on the soil quality score and the crop yield data. Assume that the result shows that the influence coefficient of the soil quality score on the crop yield is 5, indicating that for every unit increase in soil quality, the crop yield will increase by 5 tons / hectare. In order to more intuitively display the soil quality evaluation results, data visualization technology is used to generate heat maps and bar charts to show the distribution of soil quality scores in different regions, and generate a detailed soil quality evaluation report.
[0084] In this embodiment, the report points out that the soil quality score of a certain area is generally low, and it is recommended to increase the application of organic fertilizer. Based on the soil quality evaluation report, fertilization decision suggestions are provided to agricultural managers to judge the rationality of the current fertilization plan. Combining soil quality evaluation and fertilization decision suggestions, soil improvement plans are proposed, such as increasing green manure planting in low-quality areas to increase soil organic matter content, and finally forming an improved soil management strategy.
[0085] Embodiment 2
[0086] The present invention also provides a wolfberry garden soil quality evaluation system based on random forest, which is used to implement a wolfberry garden soil quality evaluation method based on random forest, comprising:
[0087] Data collection module, used to collect soil property data of wolfberry garden;
[0088] A feature extraction module is used to obtain soil quality characteristics based on soil attribute data;
[0089] The feature screening module is used to screen soil quality features using principal component analysis to obtain key feature subsets;
[0090] Model building module, used to build soil quality assessment model based on key feature subsets and random forest algorithm;
[0091] The evaluation module is used to evaluate the quality of the wolfberry garden soil to be evaluated based on the soil quality evaluation model and obtain a quality evaluation report.
[0092] A further implementation is that the feature extraction module comprises:
[0093] A data cleaning unit, used for cleaning soil attribute data;
[0094] A data discretization unit is used to calculate the differential entropy of the cleaned soil attribute data, discretize the data, and obtain discrete soil attribute data;
[0095] A gain calculation unit, used to calculate the information gain of discrete soil attribute data;
[0096] A weight calculation unit, used for calculating the weight of each discrete soil property data based on the information gain of each discrete soil property data and the total number of data;
[0097] The feature construction unit is used to construct soil quality features based on the weights of each discrete soil attribute data.
[0098] The embodiments described above are only descriptions of the preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.
Claims
1. A method for evaluating soil quality in wolfberry gardens based on random forests, characterized in that: The following steps are involved: Collect soil property data of wolfberry garden; Based on the soil property data, soil quality characteristics are obtained; Using principal component analysis, the soil quality characteristics are screened to obtain a key feature subset; A soil quality evaluation model was constructed based on key feature subsets and random forest algorithm; The quality of the wolfberry garden soil to be evaluated is evaluated based on the soil quality evaluation model to obtain a quality evaluation report.
2. The method for evaluating soil quality in wolfberry gardens based on random forests according to claim 1, characterized in that: The soil attribute data include soil texture, bulk density, porosity, pH value, organic matter content, total nitrogen, total phosphorus, total potassium, available nutrient content, and soil microbial quantity and activity.
3. The method for evaluating soil quality in wolfberry gardens based on random forest according to claim 1, characterized in that: Based on the soil property data, the method for obtaining soil quality characteristics is: Cleaning the soil attribute data; Calculating the differential entropy of the cleaned soil attribute data, discretizing the data, and obtaining discrete soil attribute data; Calculating information gain of the discrete soil property data; Calculate the weight of each discrete soil attribute data based on the information gain of each discrete soil attribute data and the total number of data; The soil quality characteristics are constructed based on the weights of each discrete soil attribute data.
4. The method for evaluating soil quality in wolfberry gardens based on random forests according to claim 1, characterized in that: The method to obtain the key feature subset is: Based on the soil quality characteristics, an initial characteristic matrix is constructed; wherein the rows of the initial characteristic matrix represent soil sampling points, and the columns represent each of the soil quality characteristics; Performing principal component analysis on the initial feature matrix to obtain eigenvalues; Based on the size of the eigenvalue, the number of principal components is obtained, and the variance contribution rate of each principal component is calculated; When the variance contribution rate meets a preset threshold, the principal component corresponding to the variance contribution rate is used as a new soil quality feature; Based on the new soil quality characteristics, a subset of key characteristics was obtained.
5. The method for evaluating soil quality in wolfberry gardens based on random forests according to claim 1, characterized in that: Based on the key feature subset and random forest algorithm, the method of constructing the soil quality evaluation model is as follows: By using an exhaustive method, all feature values in the key feature subset are traversed to obtain feature segmentation variables and segmentation points that meet preset conditions; Based on the characteristic mean of the split points, a mean square error impurity function is established; Based on the mean square error impurity function, obtaining the impurity weighted sum of the split points; The decision tree of the random forest is segmented based on the impurity weighting to obtain the soil quality evaluation model.
6. The method for evaluating soil quality in wolfberry gardens based on random forests according to claim 1, characterized in that: A genetic algorithm is used to optimize the parameters of the soil quality evaluation model.
7. A wolfberry garden soil quality evaluation system based on random forest, used to implement the wolfberry garden soil quality evaluation method based on random forest according to any one of claims 1 to 6, characterized in that: include: Data collection module, used to collect soil property data of wolfberry garden; A feature extraction module, used for obtaining soil quality features based on the soil attribute data; A feature screening module, used to screen the soil quality features using principal component analysis to obtain a key feature subset; Model building module, used to build soil quality assessment model based on key feature subsets and random forest algorithm; The evaluation module is used to evaluate the quality of the wolfberry garden soil to be evaluated based on the soil quality evaluation model to obtain a quality evaluation report.
8. The random forest-based wolfberry garden soil quality evaluation system according to claim 7, characterized in that: The feature extraction module comprises: A data cleaning unit, used for cleaning the soil attribute data; A data discretization unit is used to calculate the differential entropy of the cleaned soil attribute data, discretize the data, and obtain discrete soil attribute data; A gain calculation unit, used for calculating the information gain of the discrete soil attribute data; A weight calculation unit, used for calculating the weight of each discrete soil property data based on the information gain of each discrete soil property data and the total number of data; The feature construction unit is used to construct the soil quality feature based on the weight of each discrete soil attribute data.
Citation Information
Cited By
Soil breeding and planting evaluation method based on Internet of Things
CN119940735A
