Soil nutrient detection method and device based on gamma-ray energy spectrum and XGboost algorithm

By combining gamma energy spectrum and XGboost algorithm in soil nutrient detection, the problems of poor timeliness and high cost in soil nutrient detection in the prior art are solved, and rapid and accurate detection of soil nutrients is achieved, supporting differentiated fertilization and sowing.

CN119595671AActive Publication Date: 2025-03-11INST OF COMPUTING TECH CHINESE ACAD OF SCI

Patent Information

Application Number
CN202411651845.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2025-03-11
Estimated Expiration
2044-11-19

AI Technical Summary

Technical Problem

The existing soil nutrient detection methods have problems such as poor timeliness, high detection costs, and difficulty in achieving rapid detection of soil traits in deep underground parts of large-scale farmland.

Method used

The soil nutrient prediction method based on gamma energy spectrum and XGboost algorithm is used to identify the types and content of radioactive elements in the soil through vehicle-mounted gamma energy spectrum, and a model is established based on soil nutrient data, so as to improve the prediction accuracy through iterative training.

Benefits of technology

It realizes rapid and accurate detection of soil nutrients, reduces detection costs, improves detection efficiency, and provides technical support for differentiated fertilization and differentiated sowing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119595671A_ABST
    Figure CN119595671A_ABST
Patent Text Reader

Abstract

The invention provides a soil nutrient detection method based on a gamma-ray energy spectrum and an XGboost algorithm, and the method comprises the steps: constructing a training sample for soil nutrient detection, the training sample comprises radioactive element data, and the label of the training sample is soil nutrient data with the same soil point location as the radioactive element data; the training sample is input into an XGboost model, the XGboost model extracts features of the training sample and predicts soil nutrients of the training sample, the soil nutrients serve as nutrient predicted values, a loss function is constructed according to the nutrient predicted values and labels of the training sample, the XGboost model is trained, and a soil nutrient detection model is obtained; acquiring soil radioactive elements of to-be-detected soil through a gamma-ray energy spectrometer, and inputting the soil radioactive elements into the soil nutrient detection model to obtain a nutrient detection result of the to-be-detected soil.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of soil nutrient detection, and in particular to a soil nutrient prediction method, device, storage medium, electronic device and computer program product based on gamma spectrum and XGboost algorithm. Background Art

[0002] Soil is the foundation of agriculture and the most important agricultural production material. Its fertility directly determines the yield and quality of crops. For a long time, farmland has generally had problems with dense planting and blind fertilization, which has caused soil compaction and reduced fertility, thus affecting the yield and quality of agricultural products. In order to improve soil fertility, the key point of soil testing and fertilizer matching is to quickly and accurately detect the types and contents of effective components in the soil.

[0003] At present, commonly used soil detection methods include atomic absorption spectroscopy (AAS), atomic fluorescence spectroscopy (AFS), X-ray fluorescence spectroscopy (XRF), ion chromatography (IC), electrochemical analysis, chemical methods and laser induced breakdown spectroscopy (LIBS). All of the above methods require soil pretreatment such as drying, grinding and screening, which have poor timeliness and high detection costs, and it is difficult to achieve rapid detection of soil properties in the deep underground part of large-scale farmland.

[0004] With the continuous deepening and development of soil quality research, in the quantitative evaluation of soil erosion intensity, radionuclides in the soil can effectively respond to the changes in soil fertility and structure by releasing gamma rays. Radionuclides are distributed relatively stably and evenly on the soil surface through atmospheric deposition, and their own radioactive decay is slow, which produces physical and mechanical migration of soil particles. Therefore, radionuclides can characterize the degree of soil erosion and quality degradation to a certain extent.

[0005] Therefore, how to use gamma rays for rapid detection of soil nutrients has great practical significance. Summary of the invention

[0006] In view of the shortcomings of existing soil nutrient detection methods, a soil nutrient prediction method based on gamma spectrum and XGboost algorithm is proposed. The present invention takes gamma rays in soil as the research object, identifies the types and contents of radioactive elements in soil through a vehicle-mounted gamma spectrometer, establishes a physical and chemical relationship between them and the effective substances and their contents in soil nutrients, and improves the prediction accuracy and the efficiency of soil nutrient detection through continuous training and iteration of a large amount of data, providing technical support for differentiated fertilization and differentiated sowing.

[0007] In view of the shortcomings of existing technologies, such as Figure 7 As shown, the present invention proposes a soil nutrient detection method based on gamma spectroscopy and XGboost algorithm, which includes:

[0008] The initial step is to construct a training sample for soil nutrient detection, the training sample including: radioactive element data, the label of the training sample is the soil nutrient data of the same soil point as the radioactive element data;

[0009] In the training step, the training sample is input into the XGboost model. The XGboost model extracts the features of the training sample and predicts the soil nutrients of the training sample as the nutrient prediction value. According to the nutrient prediction value and the label of the training sample, a loss function is constructed to train the XGboost model to obtain a soil nutrient detection model.

[0010] The monitoring step is to collect soil radioactive elements of the soil to be tested by a gamma spectrometer and input the radioactive elements into the soil nutrient detection model to obtain the nutrient detection result of the soil to be tested.

[0011] The soil nutrient detection method based on gamma spectroscopy and XGboost algorithm, wherein the initial step comprises:

[0012] The spectral line data of the soil point is measured by a gamma spectrometer, and the corresponding relationship between the energy peak and the channel address in the spectral line data is used to quantitatively calculate the corresponding content of each radioactive element in unit time using the energy peak boundary counting method to obtain the radioactive element data, which is combined with the soil nutrient data of the soil point to form the training sample.

[0013] The soil nutrient detection method based on gamma spectroscopy and XGboost algorithm, wherein the radioactive element data in the training sample corresponds to soil property information, and the soil property information includes black soil, sandy soil, saline-alkali soil and brown soil;

[0014] The training step includes: training a soil nutrient detection model for black soil, a soil nutrient detection model for sandy soil, a soil nutrient detection model for saline-alkali soil, and a soil nutrient detection model for brown soil respectively according to the soil property information of the training sample;

[0015] The monitoring step includes: determining the soil property information of the soil to be tested, sending the soil radioactive elements of the soil to be tested into a soil nutrient detection model corresponding to the soil property information, and obtaining the nutrient detection result.

[0016] The soil nutrient detection method based on gamma spectroscopy and XGboost algorithm, wherein the training step comprises:

[0017] The XGboost model is a tree model. When the tree model is trained for the nth iteration:

[0018]

[0019] where xi represents the i-th training sample, represents the nutrient prediction value of the i-th sample after the n-th iteration, represents the prediction result of the first n-1 iterations, f n (x i ) represents the tree model of the nth iteration;

[0020] Construct the objective function:

[0021]

[0022] in is the loss function used to characterize the predicted value of soil nutrients in the model and the true soil nutrient y i The difference between Ω(f i ) is the regularization term;

[0023] Calculate the optimal target value of the model and transform the target function into a function about the leaf nodes.

[0024] According to the form of the leaf node of the nth decision tree, the ultimate value of the objective function is:

[0025]

[0026] Among them, T is the number of leaf nodes of the decision tree, j is the index of each leaf, and w j is the prediction score of the current leaf, G j is the sum of the first-order derivatives of all samples of the jth leaf node, H j is the sum of the second-order derivatives of all samples of the jth leaf node, γ is the parameter that controls the number of leaves in the decision tree, and λ is the regularization parameter;

[0027] Based on Bayesian hyperopt hyperparameter tuning, given a dataset D consisting of training samples, XGboost model Y, define the hyperparameter domain X N ={x1,x2,x3....,x n}, find the best set of hyperparameters in X * , to improve the prediction performance of the XGboost model on dataset D.

[0028] like Figure 8 As shown, the present invention also proposes a soil nutrient detection device based on gamma spectrum and XGboost algorithm, which includes:

[0029] The initial module constructs a training sample for soil nutrient detection, the training sample including: radioactive element data, the label of the training sample is the soil nutrient data of the same soil point as the radioactive element data;

[0030] The training module inputs the training sample into the XGboost model. The XGboost model extracts the features of the training sample and predicts the soil nutrients of the training sample as the nutrient prediction value. According to the nutrient prediction value and the label of the training sample, a loss function is constructed to train the XGboost model to obtain a soil nutrient detection model.

[0031] The monitoring module collects soil radioactive elements of the soil to be tested through a gamma spectrometer and inputs the soil radioactive elements into the soil nutrient detection model to obtain the nutrient detection result of the soil to be tested.

[0032] The soil nutrient detection device based on gamma spectroscopy and XGboost algorithm, wherein the initial module includes:

[0033] The spectral line data of the soil point is measured by a gamma spectrometer, and the corresponding relationship between the energy peak and the channel address in the spectral line data is used to quantitatively calculate the corresponding content of each radioactive element in unit time using the energy peak boundary counting method to obtain the radioactive element data, which is combined with the soil nutrient data of the soil point to form the training sample.

[0034] The soil nutrient detection device based on gamma spectrum and XGboost algorithm, wherein the radioactive element data in the training sample corresponds to soil property information, and the soil property information includes black soil, sandy soil, saline-alkali soil and brown soil;

[0035] The training module includes: according to the soil property information of the training sample, respectively training a soil nutrient detection model of black soil, a soil nutrient detection model of sandy soil, a soil nutrient detection model of saline-alkali soil and a soil nutrient detection model of brown soil;

[0036] The monitoring module includes: determining the soil property information of the soil to be tested, sending the soil radioactive elements of the soil to be tested into a soil nutrient detection model corresponding to the soil property information, and obtaining the nutrient detection result;

[0037] in,

[0038] This training module includes:

[0039] The XGboost model is a tree model. When the tree model is trained for the nth iteration:

[0040]

[0041] where x i represents the i-th training sample, represents the nutrient prediction value of the i-th sample after the n-th iteration, represents the prediction result of the first n-1 iterations, f n (xi ) represents the tree model of the nth iteration;

[0042] Construct the objective function:

[0043]

[0044] in is the loss function used to characterize the predicted value of soil nutrients in the model and the true soil nutrient y i The difference between Ω(f i ) is the regularization term;

[0045] Calculate the optimal target value of the model and transform the target function into a function about the leaf nodes.

[0046] According to the form of the leaf node of the nth decision tree, the ultimate value of the objective function is:

[0047]

[0048] Where T is the number of leaf nodes in the decision tree, j is the index of each leaf, and w j is the prediction score of the current leaf, G j is the sum of the first-order derivatives of all samples of the jth leaf node, H j is the sum of the second-order derivatives of all samples of the jth leaf node, γ is the parameter that controls the number of leaves in the decision tree, and λ is the regularization parameter;

[0049] Based on Bayesian hyperopt hyperparameter tuning, given a dataset D consisting of training samples, XGboost model Y, define the hyperparameter domain X N ={x1,x2,x3....,x n}, find the best set of hyperparameter configuration x in X * , to improve the prediction performance of the XGboost model on dataset D.

[0050] The present invention also proposes an electronic device, which includes the soil nutrient detection device based on gamma energy spectrum and XGboost algorithm. The electronic device may be connected to an information display device, which is used to display the nutrient detection results according to display parameters and attributes set by the user or through an artificial intelligence model.

[0051] The present invention also proposes a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any of the soil nutrient detection methods based on gamma energy spectrum and XGboost algorithm are implemented.

[0052] The present invention also proposes a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the steps of the soil nutrient detection method based on gamma energy spectrum and XGboost algorithm are implemented.

[0053] It can be seen from the above scheme that the advantages of the present invention are:

[0054] 1) The soil nutrient prediction model established by multiple iterations based on the XGboost algorithm and a large amount of basic soil information can accurately predict a variety of soil nutrient data of the same soil properties, and the model is stable and reliable;

[0055] 2) The present invention firstly utilizes the one-to-one correspondence between energy peaks and track addresses, and uses the energy peak boundary counting method to quantitatively calculate the corresponding content of each radioactive element in unit time, and combines it with the soil nutrient data, plot number, soil properties, longitude and latitude of the same point to form a data set, which can be used to realize soil nutrient prediction of the same soil properties, and has a certain versatility.

[0056] 3) The present invention uses the XGBoost gradient boosting tree algorithm to train models for black soil, sandy soil, saline-alkali soil, and brown soil, respectively, and uses the Bayesian-based hyperopt hyperparameters to tune parameters and optimize model performance, so that the model has higher prediction accuracy and generalization ability, and the effectiveness of the method is verified through relevant experiments.

[0057] 4) The soil nutrient prediction method based on gamma spectrum and XGboost algorithm proposed in the present invention can realize the rapid detection of soil nutrients to a certain extent, which gets rid of the constraints of laboratory soil nutrient testing to a certain extent. It is an efficient and low-cost soil nutrient detection method, which can provide a certain technical basis for differentiated fertilization and differentiated sowing. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 Flow chart for soil nutrient prediction model construction and nutrient data output;

[0059] Figure 2 This is the nuclide energy peak spectrum of a soil sample from a certain plot;

[0060] Figure 3 A diagram of the algorithm for determining the data collection points within the plot;

[0061] Figure 4 This is a schematic diagram of the training process of the prediction model based on XGboost;

[0062] Figure 5 Schematic diagram of the prediction process based on the XGboost model;

[0063] Figure 6This is a comparison chart between the model prediction value and the true value in actual application;

[0064] Figure 7 is a flow chart of the method of the present invention;

[0065] Figure 8 It is a module diagram of the device of the present invention;

[0066] Fig. 9 This is a schematic diagram of the structure of a first electronic device of the present invention;

[0067] Fig.10 This is a schematic diagram of the application environment structure of the first electronic device of the present invention;

[0068] Fig.11 It is a schematic diagram of the structure of a second electronic device of the present invention.

[0069] Reference numerals:

[0070] A-First electronic device;

[0071] B-Soil nutrient detection device;

[0072] C-data acquisition equipment;

[0073] D-information display device;

[0074] 1000 - second electronic device;

[0075] Ⅰ-computational unit;

[0076] II-ROM;

[0077] III-RAM;

[0078] IV-bus;

[0079] V-interface;

[0080] VI - input unit;

[0081] VII-output unit;

[0082] VIII- Storage medium;

[0083] Ⅸ-Communication unit. DETAILED DESCRIPTION

[0084] It should be noted that, in this application, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0085] Without more constraints, an element defined by the phrase "comprising a..." does not exclude the existence of other identical elements in the process, method, article or apparatus comprising the element.

[0086] The processor described in the present invention is the control center of the electronic device, which can be a processor or a general term for multiple processing elements. For example, it can be one or more central processing units (CPUs), or application specific integrated circuits (ASICs), or one or more integrated circuits configured to implement the embodiments of the present invention, such as one or more microprocessors (digital signal processors, DSPs), or one or more field programmable gate arrays (FPGAs).

[0087] Optionally, the processor can perform various functions of the electronic device by running or executing a software program stored in the memory, and calling data stored in the memory.

[0088] In a specific implementation, as an embodiment, the processor may include one or more CPUs. Each of these processors may be a single-core processor (single-CPU) or a multi-core processor (multi-CPU). The processor here may refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions). Electronic devices may include: servers, desktop computers, laptops, smart phones, tablet computers, embedded computers, etc., wherein the embedded computers include vehicles and robots, etc.

[0089] The memory is used to store the software program for executing the solution of the present invention, and the execution is controlled by the processor. The specific implementation method can refer to the above method embodiment, which will not be repeated here.

[0090] It should be noted that the structure of the electronic device shown in the drawings of the present invention does not constitute a limitation thereto, and the actual knowledge structure recognition device may include more or fewer components than shown in the drawings, or a combination of certain components, or a different arrangement of components.

[0091] The above embodiments can be implemented in whole or in part by software, hardware (such as circuits), firmware or any other combination. When implemented by software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.

[0092] It should also be understood that the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship, but it may also indicate an "and / or" relationship. Please refer to the context for specific understanding.

[0093] In the present invention, "at least one" means one or more, and "plurality" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can be represented by: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

[0094] It should also be understood that in various embodiments of the present invention, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0095] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0096] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0097] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0098] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0099] In order to make the above features and effects of the present invention more clearly and understandably described, embodiments are given below and described in detail with reference to the accompanying drawings. This specification discloses one or more embodiments that include the features of the present invention. The disclosed embodiments are only for illustration. The scope of protection of the present invention is not limited to the disclosed embodiments, and the present invention is defined by the attached claims.

[0100] In view of the shortcomings of existing soil nutrient detection methods, the present invention proposes a soil nutrient prediction method based on gamma spectrum and XGboost algorithm. The present invention takes gamma rays in soil as the research object, identifies the types and contents of radioactive elements in soil through a vehicle-mounted gamma spectrometer, establishes a physical and chemical relationship between them and the effective substances and their contents in soil nutrients, and improves the prediction accuracy of the model and the detection efficiency of soil nutrients through continuous training, iteration and parameter optimization of a large amount of data, thereby providing technical support for differentiated fertilization and differentiated sowing.

[0101] In order to achieve the above-mentioned purpose, the technical scheme adopted by the present invention includes: collecting original soil gamma spectrum data and soil nutrient data at the same point, converting the original gamma spectrum data into radioactive elements, and constructing a soil basic information database; extracting soil basic data corresponding to different soil types such as black soil, sandy soil, saline-alkali soil, brown soil, etc. from the soil basic information database, including plot number, soil properties, original soil gamma spectrum information, soil radioactive element information, soil nutrient data at the same point, longitude and latitude, etc., and dividing the soil basic data into feature data and target data, and constructing a training set and a test set after preprocessing; determining the hyperparameter objective function of the XGboost algorithm model; using the Bayesian-based hyperopt hyperparameter to perform parameter tuning; constructing a soil nutrient prediction model based on the XGboost algorithm to determine the soil type and applying it.

[0102] The present invention first converts massive amounts of soil radioactivity spectrum data into specific types and contents of soil radioactive elements, and then normalizes and digitizes the soil nutrient data and soil radioactive elements in the data set, eliminating the order of magnitude differences between the data and avoiding the problem of excessive errors in soil nutrient data prediction.

[0103] The Bayesian-based hyperopt hyperparameter tuning method used in the present invention aims to find the optimal configuration of n hyperparameters, so as to maximize the performance of the XGboost model in the data set, which breaks the currently commonly used method of finding a good hyperparameter combination required for the model after a large amount of search or repeated iterative optimization in the configuration space, and can use the parameter information calculated in the previous step to continuously update and verify the optimization parameter combination until the XGboost model performance reaches the best, and in the actual implementation process of the present invention, support parallel operation, few iterations, and fast speed. The present invention introduces a penalty function and a regular term in the application method to effectively prevent overfitting.

[0104] The present invention proposes a soil nutrient prediction method based on gamma ray spectrum and XGboost algorithm, which specifically includes the following steps:

[0105] Step 1: Construct a basic soil information database, including plot number, soil properties, soil original gamma spectrum information, soil radioactive element information, soil nutrient data at the same site, longitude and latitude, etc.

[0106] Step 1.1: Original soil information data collection: In the actual farmland operation environment, two sets of data are collected from the same soil point. One set uses the uniform sampling method to collect and test soil nutrient data; the other set uses a vehicle-mounted gamma spectrometer to collect radioactive element data.

[0107] Step 1.2: Convert soil radioactivity spectrum information into the types and contents of soil radioactive elements;

[0108] Step 1.3: Construct the plot data information, mark the plot boundary with longitude and latitude, and obtain the data within the plot. The data within the plot includes: soil properties, original soil gamma spectrum information, soil radioactive element information, soil nutrient data at the same site, and longitude and latitude;

[0109] Step 2: Construct a data set and extract soil data corresponding to different soil types such as black soil, sandy soil, saline-alkali soil, and brown soil from the soil basic information database, including plot number, soil properties, soil radioactive element information, soil nutrient data, and longitude and latitude. After data preprocessing, organize the data into a two-dimensional matrix with feature parameters and target parameters as columns and longitude and latitude as indexes.

[0110] Step 2.1: Data preprocessing, including null value processing, outlier processing, data processing under abnormal conditions, data normalization, etc.

[0111] Step 2.2: Construct a data set including characteristic values ​​and target values. Construct characteristic values ​​and target values ​​according to the data types of the soil radioactive elements and soil nutrient data preprocessed in step 2.1 to construct a data set;

[0112] Step 2.3: Data correlation analysis: Perform data correlation analysis on the target values ​​and eigenvalues ​​in the data set constructed in step 2.2 one by one, measure the degree of correlation between the target values ​​and the eigenvalues, screen out the target values ​​and eigenvalues ​​with high correlation, and input them into the XGboost algorithm model.

[0113] Step 3: Determine the hyperparameter objective function of the XGboost algorithm model, specifically including: constructing the XGboost model Y, taking the feature data, plot number, soil properties, and longitude and latitude in the data set obtained in step 2 as the input of the XGboost model, and the target value in the data set as the output of the XGboost model.

[0114] Step 3.1: Build a tree model. Assuming that the tree model is trained for the nth iteration, we have:

[0115]

[0116] where x i represents the i-th training sample, represents the prediction result (nutrient prediction value) of the i-th sample after the n-th iteration, represents the prediction result of the first n-1 iterations, f n (x i ) represents the tree model of the nth iteration.

[0117] Step 3.2: Construct the objective function, defined as:

[0118]

[0119] in is the loss function, which is used to characterize the predicted value of soil nutrients in the model and the true soil nutrient y i The difference between Ω(f i ) is a regular term, which is used to control the complexity of the model and prevent overfitting.

[0120] Step 3.3: Calculate the optimal target value of the model, convert the target function into a function about the leaf nodes,

[0121] According to the form of the leaf node of the nth decision tree, the ultimate value of the objective function is:

[0122]

[0123] Here, by finding the extreme value, we can find the minimum value of the objective function, that is, the minimum loss function. At this time, the predicted value of soil nutrients by the prediction model is closest to the actual value of soil nutrients. Where T is the number of leaf nodes in the decision tree, j is the index of each leaf, and w is the root of the leaf.j is the prediction score of the current leaf, G j is the sum of the first-order derivatives of all samples of the jth leaf node, H j is the sum of the second-order derivatives of all samples of the jth leaf node, γ is the parameter that controls the number of decision tree leaves, and λ is the regularization parameter.

[0124] Step 4: Bayesian hyperopt hyperparameter tuning, given a dataset D, XGboost model Y, define the hyperparameter domain X N ={x1,x2,x3....,x n}, which aims to find the best set of hyperparameter configurations x in X based on past evaluation experience * , thereby improving the prediction performance of model Y on data set D. The specific steps are as follows:

[0125] Step 4.1: Define the objective function of hyperparameter optimization. This function accepts a dictionary containing the hyperparameters to be optimized as input and returns a numerical value representing the model performance. By trying different hyperparameter combinations, the objective function is called to calculate its performance. When the objective value is the minimum, a set of optimal hyperparameters is obtained. The formula is defined as:

[0126]

[0127] Step 4.2: Set the type and value range of hyperparameters;

[0128] Step 4.3: Find the hyperparameter combination that minimizes the reward and punishment function;

[0129] Step 4.4: Implementation of Bayesian hyperopt hyperparameter tuning in the XGboost algorithm model.

[0130] Step 5: Construct soil nutrient prediction models based on the XGboost algorithm for black soil, sandy soil, saline-alkali soil, and brown soil and apply them. The specific steps are as follows:

[0131] Step 5.1: In the Python environment, input the hyperparameter combination output in step 4 and the training set data in step 2 into the XGboost algorithm model, and a soil nutrient prediction model based on gamma spectrum and XGboost algorithm for specific soil types is established;

[0132] Step 5.2: Input the feature values ​​in the test set into the model constructed in step 5.1 to obtain the predicted soil nutrient data.

[0133] Example 1

[0134] The soil nutrient prediction method based on gamma ray spectrum and XGboost algorithm described in the embodiment of the present invention has the following overall process: Figure 1 , the specific implementation steps are as follows:

[0135] Step 1: Construct a basic soil information database, including plot number, soil properties, soil original gamma spectrum information, soil radioactive element information, soil nutrient data at the same site, longitude and latitude, etc.

[0136] Step 1.1: Original soil information data collection. In the actual farmland operation environment, two groups of soil data are collected at the same time. One group is the uniform sampling method. This part of the soil samples is sent to the laboratory for testing of soil pH, organic matter, organic carbon, total potassium and other indicators; the other group uses a vehicle-mounted gamma spectrometer to collect the original spectrum information of radioactive element data. It runs at a constant speed on the specified route and performs non-repetitive sampling at a frequency of 5HZ.

[0137] Step 1.2: The soil radioactivity spectrum information is converted into the type and content of soil radioactive elements. First, the soil sample with determined soil properties is measured using a laboratory high-purity germanium detector, and each energy peak is identified and the peak shape is calculated. The nuclide energy peak with certain characteristics is selected, such as Figure 2 . Since the energy peaks in the soil radioactivity spectrum curve correspond to the channel addresses one by one, the energy peaks in the soil radioactivity spectrum curve collected by the identification equipment are calibrated as specific radioactive elements, namely Pb-212, Ra-226, Pb-214, Tl-208, Bi-214, Cs-137, Ac-228, Co-60, and K-40. Then, a sodium iodide (NaI) scintillator detector is used for field measurement. According to the energy involved in the high-purity germanium measurement, the area of ​​the channel address corresponding to the spectrum line is summed up and calculated as the calculated radioactivity index. The principle is that the count of the energy corresponding to the nuclide per unit time is proportional to the content of the nuclide. The total number of peaks corresponding to the identified radioactive elements is calculated, and the corresponding content of the radioactive elements per unit time can be calculated.

[0138] Step 1.3: Construct the plot data information, use longitude and latitude to mark the plot boundary, and use the divided plot as the unit to determine whether the trajectory point of the vehicle-mounted gamma spectrometer operation is within the plot. The judgment algorithm is as follows: Figure 3 , the definition formula is:

[0139]

[0140] The number of intersections between the ray and all the edges of the polygonal plot is used as the basis for judgment. If y0 is an odd number, the operation trajectory point is inside, otherwise it is outside. After confirmation, a soil basic information database containing the plot number, plot area, soil properties, soil original gamma spectrum information, soil radioactive element information, soil nutrient data at the same point, and longitude and latitude is constructed.

[0141] Step 2: Construct a data set. The data is collected from the actual operation data of farmland in a certain area. The historical soil-related data corresponding to different soil types such as black soil, sandy soil, saline-alkali soil, and brown soil are extracted from the soil basic information database, including: plot number, soil properties, soil radioactive element information, soil nutrient data at the same point, longitude and latitude, and the data is organized into a two-dimensional matrix with characteristic parameters as feature columns and longitude and latitude as indexes. The specific operation steps are as follows:

[0142] Step 2.1: Data preprocessing: preprocess the data in the following ways:

[0143] (1) Null value processing

[0144] Eliminate the control over a certain period of time when 4G communication interruption occurs.

[0145] (2) Outlier processing

[0146] For some soil radioactive elements such as Pb-212-85 and Ra-226, the content of which exceeds the normal content range of soil, such data should be deleted. For data that obviously deviates from the normal value, the box plot algorithm can be used to identify and delete it.

[0147] (3) Data processing under abnormal conditions

[0148] The operating data of the vehicle-mounted gamma spectrometer under abnormal operating conditions such as turning, repeating paths, and stopping should be deleted.

[0149] (4) Data normalization

[0150] The data filtered through the above steps are normalized as follows:

[0151]

[0152] Step 2.2: Construct a data set including characteristic values ​​and target values. The soil radioactive elements and soil nutrient data preprocessed in step 2.1 are as shown in Table 1. The characteristic values ​​and target values ​​are constructed according to the data type. The characteristic data include one or more of the following: radioactive elements such as Pb-212, Pb-214, and Ra-226. The target data include one or more of the following: soil nutrient data such as PH, organic matter, and total potassium. The data set is randomly divided into a training set and a test set in a 4:1 manner.

[0153] Serial number Parameter name unit Serial number Parameter name unit 1 Pb-212 Piece / kg 10 PH pH 2 Ra-226 Piece / kg 11 Organic matter g / kg 3 Pb-214 Piece / kg 12 Total Potassium g / kg 4 Tl-208 Piece / kg 13 Organic carbon mg / kg 5 Bi-214 Piece / kg 14 6 Cs-137 Piece / kg 15 7 Ac-228 Piece / kg 16 8 Co-60 Piece / kg 17 9 K-40 Piece / kg 18

[0154] Table 1 Table of soil radioactive elements and nutrient data characteristic parameters

[0155] Step 2.3: Data correlation analysis: Perform data correlation analysis on the target values ​​in the data set constructed in step 2.2 and the feature values ​​one by one to measure the degree of correlation between the target values ​​and the feature values. Mark the feature values ​​that are determined to be strongly correlated and record their correlation strength in the data set so that these feature values ​​can be given priority in the subsequent model training process.

[0156] The strength of the data correlation is expressed by the Pearson correlation coefficient:

[0157]

[0158] Wherein, x and y represent the characteristic parameters and target parameters in the data set, i.e., various soil radioactive elements and soil nutrient data, respectively, n is the number of selected data points, and its value range is between -1 and 1. The larger the absolute value, the stronger the correlation. The correlation coefficient between each soil radioactive element and each soil nutrient data is calculated, and the characteristic parameters and target parameters with higher correlation coefficients are screened out. In actual operation, the present invention uses |r|≥0.5 as the selection standard.

[0159] Step 3: Determine the hyperparameter objective function of the machine learning algorithm, including: constructing the XGboost model Y, taking the feature data, plot number, soil properties, and longitude and latitude in the data set after step 2 as the input of the XGboost model, and the target value in the data set as the output of the XGboost model.

[0160] Step 3.1: Build a tree model. Assuming that the tree model is trained for the nth iteration, we have:

[0161]

[0162] where x i represents the i-th sample, represents the prediction result of the i-th sample after the n-th iteration, represents the prediction result of the first n-1 iterations, f n (x i ) represents the tree model of the nth iteration.

[0163] Step 3.2: Construct the objective function. The prediction accuracy of the model is composed of the deviation and variance. The loss function is the deviation of the model. In order to make the variance of the model as small as possible, a regularization term needs to be added. For this reason, the objective function of the model consists of the loss function and the regularization term to prevent the model from overfitting, which is defined as:

[0164]

[0165] Step 3.4: Calculate the optimal target value of the model, convert the target function into a function about the leaf nodes,

[0166] According to the form of the leaf node of the nth decision tree, the ultimate value of the objective function is:

[0167]

[0168] Among them, T is the number of leaf nodes of the decision tree, j is the index of each leaf, and w j is the prediction score of the current leaf, G j is the sum of the first-order derivatives of all samples of the jth leaf node, H j is the sum of the second-order derivatives of all samples of the jth leaf node, γ is the parameter that controls the number of decision tree leaves, and λ is the regularization parameter.

[0169] Step 4: Bayesian hyperopt hyperparameter tuning, given a dataset D, XGboost model Y, define the hyperparameter domain X N ={x1,x2,x3....,x n}, which aims to find the best set of hyperparameter configurations x in X based on past evaluation experience * , thereby improving the prediction performance of model Y on data set D. The specific steps are as follows:

[0170] Step 4.1: Define the objective function of hyperparameter optimization. This function accepts a dictionary containing the hyperparameters to be optimized as input and returns a numerical value representing the model performance. By trying different hyperparameter combinations, calling the objective function to calculate its performance, the optimal set of hyperparameters is obtained when the objective value is the minimum value. The formula is defined as:

[0171]

[0172] Step 4.2: In setting the type and value range of hyperparameters, in the specific implementation process of hyperparameter tuning based on Bayesian, the present invention uses the TPE optimization algorithm based on Gaussian mixture model in the hyperopt optimizer. According to the characteristics of the XGboost algorithm model, the hyperparameter type, value range, representative meaning, etc. are roughly set as shown in Table 2:

[0173] Hyperparameter Types Value range meaning Max_depth (1,30) Specify the maximum depth of the tree Alpha(L1) [default=0] L1 regularization parameter Lambda (L2) (0,15) L2 regularization parameter Gamma [0,+∞] Complexity Control Parameters n_estimators (0,500) Number of decision trees learning_rate (0,1] Learning Rate Min_child_weight (0,20) Threshold of the sum of leaf node weights Subsample (0,1] Random sample ratio

[0174] Table 2 Common hyperparameter types, value ranges and meanings of XGboost algorithm

[0175] Step 4.3: Find the hyperparameter combination that minimizes the reward and punishment function, embed the Bayesian optimization algorithm into the XGboost algorithm model, find the optimal hyperparameter combination through the minimum value of the reward and punishment function, and then input the optimal hyperparameter combination and test set data into the XGboost algorithm model for training. The root mean squared error (RMSE) and R 2 As the model accuracy evaluation index, the formulas are as follows:

[0176]

[0177] where y i is the true value, is the corresponding predicted value, is the average value.

[0178] If the model evaluation index meets the requirements, the optimal hyperparameter combination is output, otherwise it enters the next round of iteration.

[0179] Step 4.4: Implementation of Bayesian hyperopt hyperparameter tuning in the XGboost algorithm model. Based on the above optimization process, in the python implementation process, we can first use the sklearn interface XGBRegressor in the xgboost library to establish a regression prediction model, and use the fmin function in hyperopt for Bayesian optimization search. The specific steps of the entire python implementation process are as follows:

[0180] (1) Loading basic soil data;

[0181] (2) Call the train_test_split interface to split the data into a training set and a test set in a ratio of 4:1;

[0182] (3) Call the XGBRegressor interface to establish a regression prediction model based on XGboost;

[0183] (4) In the Bayesian optimization process, an evaluation function is defined as the objective function obj, which receives a hyperparameter combination and returns an evaluation value;

[0184] (5) Call hp in hyperopt to set the parameter space space for hyperparameter optimization;

[0185] (6) Initialize the Trials object;

[0186] (7) Call the fmin function to perform Bayesian optimization search and store the results of each run into the Trials object;

[0187] (8) Set the number of runs and output the optimal XGboost algorithm hyperparameter combination.

[0188] Step 5: Construct and apply a soil nutrient prediction model based on the XGboost algorithm to determine the soil quality. The process is as follows: Figure 4 ,like Figure 5 As shown, the specific steps are as follows:

[0189] Step 5.1: In the Python environment, the hyperparameter combination output in step 4 is input into the XGboost algorithm model through the training set data in step 2 for training. A soil nutrient prediction model based on gamma spectrum and XGboost algorithm is established.

[0190] Step 5.2: Input the feature values ​​in the test set into the model constructed in step 5.1 to obtain the predicted soil nutrient data. The predicted values ​​are compared with the true values, as shown in Figure 6 As shown, the corresponding RMSE and R 2 They are as follows: pH is 0.2454 and 0.92, organic matter is 1.9749 and 0.93, organic carbon is 1.877 and 0.94, total potassium is 0.2126 and 0.91. The ratio between the predicted value and the actual value is greater than 90%, which means the prediction model is qualified and can be used to predict soil nutrients.

[0191] The invention is based on the mechanism relationship between gamma energy spectrum and soil nutrients, combines with XGboost algorithm to predict soil nutrients, collects gamma ray spectrum in farmland through gamma energy spectrometer, and resolves it into types and quantities of radioactive elements through energy peak recognition and peak shape calculation, and establishes nonlinear physical and chemical relationship between types and quantities of radioactive elements and types and quantities of soil nutrients by combining qualitative and quantitative methods, so as to realize fast and low-cost soil nutrient detection through gamma energy spectrometer, which gets rid of the constraints of laboratory soil nutrient testing to a certain extent, and can provide a certain technical basis for differentiated fertilization and differentiated sowing.

[0192] The following is a system embodiment corresponding to the above method embodiment. This embodiment can be implemented in conjunction with the above embodiment. The relevant technical details mentioned in the above embodiment are still valid in this embodiment. In order to reduce repetition, they are not repeated here. Accordingly, the relevant technical details mentioned in this embodiment can also be applied in the above embodiment.

[0193] like Figure 8 As shown, the present invention also proposes a soil nutrient detection device based on gamma spectrum and XGboost algorithm, which includes:

[0194] The initial module constructs a training sample for soil nutrient detection, the training sample including: radioactive element data, the label of the training sample is the soil nutrient data of the same soil point as the radioactive element data;

[0195] The training module inputs the training sample into the XGboost model. The XGboost model extracts the features of the training sample and predicts the soil nutrients of the training sample as the nutrient prediction value. According to the nutrient prediction value and the label of the training sample, a loss function is constructed to train the XGboost model to obtain a soil nutrient detection model.

[0196] The monitoring module collects soil radioactive elements of the soil to be tested through a gamma spectrometer and inputs the soil radioactive elements into the soil nutrient detection model to obtain the nutrient detection result of the soil to be tested.

[0197] The soil nutrient detection device based on gamma spectroscopy and XGboost algorithm, wherein the initial module includes:

[0198] The spectral line data of the soil point is measured by a gamma spectrometer, and the corresponding relationship between the energy peak and the channel address in the spectral line data is used to quantitatively calculate the corresponding content of each radioactive element in unit time using the energy peak boundary counting method to obtain the radioactive element data, which is combined with the soil nutrient data of the soil point to form the training sample.

[0199] The soil nutrient detection device based on gamma spectrum and XGboost algorithm, wherein the radioactive element data in the training sample corresponds to soil property information, and the soil property information includes black soil, sandy soil, saline-alkali soil and brown soil;

[0200] The training module includes: according to the soil property information of the training sample, respectively training a soil nutrient detection model of black soil, a soil nutrient detection model of sandy soil, a soil nutrient detection model of saline-alkali soil and a soil nutrient detection model of brown soil;

[0201] The monitoring module includes: determining the soil property information of the soil to be tested, sending the soil radioactive elements of the soil to be tested into a soil nutrient detection model corresponding to the soil property information, and obtaining the nutrient detection result;

[0202] in,

[0203] This training module includes:

[0204] The XGboost model is a tree model. When the tree model is trained for the nth iteration:

[0205]

[0206] where x i represents the i-th training sample, represents the nutrient prediction value of the i-th sample after the n-th iteration, represents the prediction result of the first n-1 iterations, f n (x i ) represents the tree model of the nth iteration;

[0207] Construct the objective function:

[0208]

[0209] in is the loss function used to characterize the predicted value of soil nutrients in the model and the true soil nutrient y i The difference between Ω(f i ) is the regularization term;

[0210] Calculate the optimal target value of the model and transform the target function into a function about the leaf nodes.

[0211] According to the form of the leaf node of the nth decision tree, the ultimate value of the objective function is:

[0212]

[0213] Where T is the number of leaf nodes in the decision tree, j is the index of each leaf, and w j is the prediction score of the current leaf, G j is the sum of the first-order derivatives of all samples of the jth leaf node, H j is the sum of the second-order derivatives of all samples of the jth leaf node, γ is the parameter that controls the number of leaves in the decision tree, and λ is the regularization parameter;

[0214] Based on Bayesian hyperopt hyperparameter tuning, given a dataset D consisting of training samples, XGboost model Y, define the hyperparameter domain X N ={x1,x2,x3....,xn}, find the best set of hyperparameter configuration x in X * , to improve the prediction performance of the XGboost model on dataset D.

[0215] like Fig. 9 As shown, the present invention further proposes a first electronic device A in another embodiment, which includes the soil nutrient detection device based on gamma spectrum and XGboost algorithm.

[0216] like Fig.10 As shown, the first electronic device A can also be connected to the data acquisition device C and the information display device D through a wired or wireless information transmission scheme. The data acquisition device C is used to collect training samples and radioactive rays of the soil to be tested, and the information display device D is used to display the nutrient detection results obtained by the analysis of the present invention.

[0217] The information display device D can process the data output by the first electronic device A based on the information display mechanism to improve the readability of the data output by the first electronic device A. The information display mechanism can be manually preset, for example, the data output by the first electronic device A is visually displayed, which can be based on the display parameters and / or attributes set by the user. The display parameters can be, for example, the display data range, and the display attributes can be, for example, the display font, color, whether to scroll and play, etc. The user is presented with the key information specified by the user, for example, the key element content ratio information in the nutrient test results, etc. The user can understand this information more timely without having to access the secondary page or scroll the page, saving the user's operation. Or the information display mechanism can be an artificial intelligence AI display model, which can learn the user's key information based on the user's previous usage habits, such as viewing time, number of clicks, number of edits, etc., and then automatically present rich and necessary key information to the user.

[0218] The present invention also provides a computer program product, which includes a computer program. The computer program can be stored in a readable storage medium. When the computer program is executed by a processor, the computer can execute the soil nutrient detection methods provided by the above methods.

[0219] The present invention also proposes a storage medium VIII in another embodiment for storing a computer program for executing the soil nutrient detection method. It should be understood that the storage medium in the embodiment of the present invention can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM) or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).

[0220] Fig.11 A schematic block diagram of a second electronic device 1000 that can be used to implement an embodiment of the present invention is shown. The second electronic device 1000 electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The second electronic device 1000 can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples, and are not intended to limit the implementation of the present invention described and / or required herein. The second electronic device 1000 may be the same or different from the first electronic device A.

[0221] The second electronic device 1000 includes a computing unit I, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory II (ROM) or a computer program loaded from a storage medium VIII into a random access memory (RAM) III. In RAM III, various programs and data required for the operation of the device 1000 can also be stored. The computing unit I, ROM II, and RAM III are connected to each other via a bus IV. An input / output (I / O) interface V is also connected to the bus IV.

[0222] A plurality of components in the second electronic device 1000 are connected to the I / O interface V, including: an input unit VI, such as a keyboard, a mouse, etc.; an output unit VII, such as various types of displays, speakers, etc.; a storage medium VIII, such as a disk, an optical disk, etc.; and a communication unit IX, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit IX allows the second electronic device 1000 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0223] The computing unit I may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of computing unit I include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit I performs the various methods and processes described above, such as method steps S1-S3. For example, in some embodiments, the method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage medium VIII. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1000 via ROM II and / or a communication unit IX. When the computer program is loaded into RAM III and executed by the computing unit I, one or more steps of the method described above may be performed. Alternatively, in other embodiments, the computing unit I may be configured to execute the method in any other appropriate manner (e.g., by means of firmware).

[0224] Although the embodiments of the present invention have been disclosed as above, they are not limited to the applications listed in the specification and the implementation modes, and they can be fully applied to various fields suitable for the present invention. For those familiar with the art, additional modifications can be easily implemented. Therefore, without departing from the general concept defined by the claims and the scope of equivalents, the present invention is not limited to the specific details and the illustrations shown and described herein.

Claims

1. A soil nutrient detection method based on gamma spectroscopy and XGboost algorithm, characterized in that: include: The initial step is to construct a training sample for soil nutrient detection, the training sample including: radioactive element data, the label of the training sample is the soil nutrient data of the same soil point as the radioactive element data; In the training step, the training sample is input into the XGboost model. The XGboost model extracts the features of the training sample and predicts the soil nutrients of the training sample as the nutrient prediction value. According to the nutrient prediction value and the label of the training sample, a loss function is constructed to train the XGboost model to obtain a soil nutrient detection model. The monitoring step is to collect the soil radioactive elements of the soil to be tested by a gamma spectrometer and input the soil radioactive elements into the soil nutrient detection model to obtain the nutrient detection result of the soil to be tested.

2. The soil nutrient detection method based on gamma ray spectrum and XGboost algorithm as claimed in claim 1, characterized in that: This initial step includes: The spectral line data of the soil point is measured by a gamma spectrometer, and the corresponding relationship between the energy peak and the channel address in the spectral line data is used to quantitatively calculate the corresponding content of each radioactive element in unit time using the energy peak boundary counting method to obtain the radioactive element data, which is combined with the soil nutrient data of the soil point to form the training sample.

3. The soil nutrient detection method based on gamma spectrum and XGboost algorithm as claimed in claim 1, characterized in that: The radioactive element data in the training sample corresponds to soil property information, and the soil property information includes black soil, sandy soil, saline-alkali soil and brown soil; The training step includes: training a soil nutrient detection model for black soil, a soil nutrient detection model for sandy soil, a soil nutrient detection model for saline-alkali soil, and a soil nutrient detection model for brown soil respectively according to the soil property information of the training sample; The monitoring step includes: determining the soil property information of the soil to be tested, sending the soil radioactive elements of the soil to be tested into a soil nutrient detection model corresponding to the soil property information, and obtaining the nutrient detection result.

4. The soil nutrient detection method based on gamma spectroscopy and XGboost algorithm according to claim 1, characterized in that: The training steps include: The XGboost model is a tree model. When the tree model is trained for the nth iteration: where x i represents the i-th training sample, represents the nutrient prediction value of the i-th sample after the n-th iteration, represents the prediction result of the first n-1 iterations, f n (x i ) represents the tree model of the nth iteration; Construct the objective function: in is the loss function used to characterize the predicted value of soil nutrients in the model and the true soil nutrient y i The difference between Ω(f i ) is the regularization term; Calculate the optimal target value of the model and transform the target function into a function about the leaf nodes. According to the form of the leaf node of the nth decision tree, the ultimate value of the objective function is: Among them, T is the number of leaf nodes of the decision tree, j is the index of each leaf, and w j is the prediction score of the current leaf, G j is the sum of the first-order derivatives of all samples of the jth leaf node, H j is the sum of the second-order derivatives of all samples of the jth leaf node, γ is the parameter that controls the number of leaves in the decision tree, and λ is the regularization parameter; Based on Bayesian hyperopt hyperparameter tuning, given a dataset D consisting of training samples, XGboost model Y, define the hyperparameter domain X N ={x1,x2,x3....,x n }, find the best set of hyperparameter configuration x in X * , to improve the prediction performance of the XGboost model on dataset D.

5. A soil nutrient detection device based on gamma spectroscopy and XGboost algorithm, characterized in that: include: The initial module constructs a training sample for soil nutrient detection, the training sample including: radioactive element data, the label of the training sample is the soil nutrient data of the same soil point as the radioactive element data; The training module inputs the training sample into the XGboost model. The XGboost model extracts the features of the training sample and predicts the soil nutrients of the training sample as the nutrient prediction value. According to the nutrient prediction value and the label of the training sample, a loss function is constructed to train the XGboost model to obtain a soil nutrient detection model. The monitoring module collects soil radioactive elements of the soil to be tested through a gamma spectrometer and inputs the soil radioactive elements into the soil nutrient detection model to obtain the nutrient detection result of the soil to be tested.

6. The soil nutrient detection device based on gamma spectrum and XGboost algorithm as claimed in claim 5, characterized in that: This initial module includes: The spectral line data of the soil point is measured by a gamma spectrometer, and the corresponding relationship between the energy peak and the channel address in the spectral line data is used to quantitatively calculate the corresponding content of each radioactive element in unit time using the energy peak boundary counting method to obtain the radioactive element data, which is combined with the soil nutrient data of the soil point to form the training sample.

7. The soil nutrient detection device based on gamma spectrum and XGboost algorithm as claimed in claim 5, characterized in that: The radioactive element data in the training sample corresponds to soil property information, and the soil property information includes black soil, sandy soil, saline-alkali soil and brown soil; The training module includes: according to the soil property information of the training sample, respectively training a soil nutrient detection model of black soil, a soil nutrient detection model of sandy soil, a soil nutrient detection model of saline-alkali soil and a soil nutrient detection model of brown soil; The monitoring module includes: determining the soil property information of the soil to be tested, sending the soil radioactive elements of the soil to be tested into a soil nutrient detection model corresponding to the soil property information, and obtaining the nutrient detection result; in, This training module includes: The XGboost model is a tree model. When the tree model is trained for the nth iteration: where x i represents the i-th training sample, represents the nutrient prediction value of the i-th sample after the n-th iteration, represents the prediction result of the first n-1 iterations, f n (x i ) represents the tree model of the nth iteration; Construct the objective function: in is the loss function used to characterize the predicted value of soil nutrients in the model and the true soil nutrient y i The difference between Ω(f i ) is the regularization term; Calculate the optimal target value of the model and transform the target function into a function about the leaf nodes. According to the form of the leaf node of the nth decision tree, the ultimate value of the objective function is: Where T is the number of leaf nodes in the decision tree, j is the index of each leaf, and w j is the prediction score of the current leaf, G j is the sum of the first-order derivatives of all samples of the jth leaf node, H j is the sum of the second-order derivatives of all samples of the jth leaf node, γ is the parameter that controls the number of leaves in the decision tree, and λ is the regularization parameter; Based on Bayesian hyperopt hyperparameter tuning, given a dataset D consisting of training samples, XGboost model Y, define the hyperparameter domain X N ={x1,x2,x3....,x n }, find the best set of hyperparameter configuration x in X * , to improve the prediction performance of the XGboost model on dataset D.

8. An electronic device, characterized in that: A soil nutrient detection device based on gamma spectrum and XGboost algorithm as described in claims 5-7, wherein the electronic device is connected to an information display device, and the information display device is used to display the nutrient detection result according to the display parameters and attributes set by the user or through an artificial intelligence model.

9. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the soil nutrient detection method based on gamma spectrum and XGboost algorithm described in any one of claims 1 to 4 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the soil nutrient detection method based on gamma spectrum and XGboost algorithm described in any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Soil moisture content prediction method and device, electronic equipment and storage medium

    CN114723149A

  • Multi-coal-type coal calorific value determination method and system based on NIRS-XRF combination

    CN118709081A

  • Gamma-ray spectrum detection method and device for soil nutrients

    CN118858594A

  • Soil available nutrient inversion method based on deep neural network

    WO2021226976A1

  • Machine-learning-based method and system for predicting stress layer depth after glass tempering

    WO2024139684A1

Cited By

  • Highway engineering post-ecological restoration method and system based on data analysis

    CN120741540A

  • Soil physical and chemical parameter inversion method based on artificial neural network

    CN121410817A

  • Soil nutrient prediction system and method based on radioactive elements

    CN121503758A

  • Farmland soil parameter prediction method and device

    CN121580275A

  • Gamma-ray spectrum-based variable rate fertilization prescription map generation method and system

    CN121773822A