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

By combining a gamma spectrometer with the XGboost algorithm, radioactive elements in the soil can be identified and a soil nutrient prediction model can be established. This solves the problems of poor timeliness and high cost of soil nutrient testing in existing technologies, enables fast and accurate soil nutrient testing, and supports differentiated fertilization and sowing.

CN119595671BActive Publication Date: 2025-09-19INST OF COMPUTING TECH CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing soil nutrient testing methods require pretreatment of the soil, such as drying, grinding, and screening. These methods are time-consuming, difficult to implement rapid testing of soil properties deep underground in large-scale farmland, and are costly.

Method used

A gamma spectrometer is used to identify the types and contents of radioactive elements in the soil. A soil nutrient prediction model is established in combination with the XGboost algorithm. The model is optimized through training samples and loss function to achieve rapid detection of soil nutrients.

Benefits of technology

It achieves rapid and accurate detection of soil nutrients, reduces detection costs, has stability and reliability, is suitable for differentiated fertilization and sowing, and breaks the constraints of laboratory testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119595671B_ABST
    Figure CN119595671B_ABST
Patent Text Reader

Abstract

The present invention proposes a soil nutrient detection method based on gamma ray spectroscopy and an XGboost algorithm. The method comprises: constructing a training sample for soil nutrient detection, wherein the training sample comprises radioactive element data, and the label of the training sample is soil nutrient data of the same soil point as the radioactive element data; inputting the training sample into an XGboost model, wherein the XGboost model extracts features of the training sample and predicts soil nutrients of the training sample as nutrient prediction values; constructing a loss function based on the nutrient prediction values ​​and the labels of the training samples to train the XGboost model, thereby obtaining a soil nutrient detection model; and collecting soil radioactive elements of the soil to be tested using a gamma ray spectrometer, and inputting the collected radioactive elements into the soil nutrient detection model, thereby obtaining nutrient detection results of the soil to be tested.
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 ray spectrum and XGboost algorithm. Background Art

[0002] Soil, the foundation of agriculture and the most important resource for agricultural production, directly determines crop yield and quality. Overcrowding and indiscriminate fertilization have long been common problems in farmland, leading to soil compaction and reduced fertility, which in turn impacts the yield and quality of agricultural products. To improve soil fertility, soil testing and fertilizer application are crucial for rapidly and accurately determining the types and contents of active ingredients in the soil.

[0003] Currently, commonly used soil testing 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 these methods require soil pretreatment such as drying, grinding, and screening, resulting in poor timeliness and high testing costs, making it difficult to quickly detect soil properties deep underground in large-scale farmland.

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

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

[0006] To address the shortcomings of existing soil nutrient detection methods, a soil nutrient prediction method based on gamma ray spectroscopy and the XGboost algorithm is proposed. This method uses gamma rays in soil as its research object. Using a vehicle-mounted gamma spectrometer, it identifies the types and contents of radioactive elements in the soil. It then establishes a physical and chemical relationship between these elements and the active substances and their contents in the soil nutrients. Through continuous training and iteration using large amounts of data, this method improves prediction accuracy and the efficiency of soil nutrient detection, providing technical support for differentiated fertilization and seeding.

[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 ray spectroscopy and XGboost algorithm, which includes:

[0008] In the initial step, a training sample for soil nutrient detection is constructed, the training sample including: radioactive element data, the label of the training sample being the soil nutrient data of the same soil point where the radioactive element data was collected;

[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] In the monitoring step, radioactive elements of the soil to be tested are collected by a gamma spectrometer and input into the soil nutrient detection model to obtain nutrient detection results of the soil to be tested.

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

[0012] The spectral line data of the soil point is measured by a gamma spectrometer. 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 per unit time using the energy peak boundary counting method to obtain the radioactive element data. The radioactive element data 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 ray 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 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 ray spectroscopy and XGboost algorithm, wherein the training step includes:

[0017] The XGboost model is a tree model. When the tree model performs n-th iteration training:

[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 value of soil nutrients y i The gap, and Ω(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] For the form of the nth decision tree leaf node, 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 The sum of the first-order derivatives of all samples of the j-th leaf node, H j is the sum of the second-order derivatives of all samples of the j-th leaf node, γ is the parameter that controls the number of decision tree leaves, and λ is the regularization parameter;

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

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

[0029] An initial module constructs a training sample for soil nutrient detection, the training sample including: radioactive element data, the label of the training sample being the soil nutrient data of the same soil point where the radioactive element data was collected;

[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. Based on 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 collected radioactive elements into the soil nutrient detection model to obtain the nutrient detection results of the soil to be tested.

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

[0033] The spectral line data of the soil point is measured by a gamma spectrometer. 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 per unit time using the energy peak boundary counting method to obtain the radioactive element data. The radioactive element data 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 ray 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;

[0035] The training module 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 according to the soil property information of the training sample;

[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 the 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 performs n-th iteration training:

[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 gap, and Ω(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] For the form of the nth decision tree leaf node, 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 The sum of the first-order derivatives of all samples of the j-th leaf node, H j is the sum of the second-order derivatives of all samples of the j-th leaf node, γ is the parameter that controls the number of decision tree leaves, and λ is the regularization parameter;

[0049] Based on Bayesian hyperopt hyperparameter tuning, given a dataset D consisting of training samples, an XGboost model Y, and defining the hyperparameter domain X N ={x1,x2,x3....,x n}, find the optimal set of hyperparameter configuration x in X * , to improve the prediction performance of the model 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 using display parameters and attributes set by the user or through an artificial intelligence model.

[0051] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the steps of the soil nutrient detection method based on gamma ray spectrum and XGboost algorithm.

[0052] The present invention also provides 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 ray 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, built through multiple iterations of the XGboost algorithm and a large amount of basic soil information, can accurately predict multiple soil nutrient data for the same soil properties, and the model is stable and reliable;

[0055] 2) The present invention first 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 per unit time. This data set is then combined with the soil nutrient data, plot number, soil properties, and longitude and latitude at the same point to form a data set. This data set can be used to predict soil nutrients for the same soil properties and has a certain degree of 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. At the same time, it uses the Bayesian hyperopt hyperparameters to tune parameters and optimize model performance, so that the model has higher prediction accuracy and generalization ability. The effectiveness of the method is verified through relevant experiments.

[0057] 4) The soil nutrient prediction method based on gamma ray spectroscopy and XGboost algorithm proposed in this paper can achieve rapid detection of soil nutrients to a certain extent. This has broken away from the constraints of laboratory soil nutrient testing to a certain extent. It is an efficient and low-cost soil nutrient detection method and can provide a certain technical basis for differentiated fertilization and differentiated sowing. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 Flowchart 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 illustrating the algorithm for determining data collection points within a plot;

[0061] Figure 4 Schematic diagram of the prediction model training process based on XGboost;

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

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

[0064] Figure 7 Flow chart of the method of the present invention;

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

[0066] Figure 9 This is a schematic structural diagram of a first electronic device of the present invention;

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

[0068] Figure 11 This is a schematic structural diagram of a second electronic device according to 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] Ⅰ-computing 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] IX-Communication unit. DETAILED DESCRIPTION

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

[0085] Without further constraints, an element defined by the phrase "comprises a..." does not preclude the existence of additional identical elements in the process, method, article or apparatus that includes the element.

[0086] The processor described in the present invention is the control center of an electronic device and can be a single processor or a collective term for multiple processing elements. For example, it can be one or more central processing units (CPUs), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention, such as one or more 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 (e.g., computer program instructions). Electronic devices may include: servers, desktop computers, laptops, smartphones, 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 and 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 through software, hardware (such as circuits), firmware, or any other combination. When implemented using 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 program are loaded or executed on a computer, the processes or functions described in accordance with the embodiments of the present invention are 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. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired method (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 a collection of one or more available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, or magnetic tape), an optical medium (such as a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state drive.

[0092] It should also be understood that the term "and / or" as used herein simply describes a relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A alone, A and B together, or B alone. A and B can be singular or plural. Furthermore, the character " / " as used herein generally indicates an "or" relationship between the associated objects, but it may also indicate an "and / or" relationship. For specific understanding, please refer to the context.

[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 or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or plural.

[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 merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, 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 interface, indirect coupling or communication connection of the device or unit, which can be electrical, mechanical or other forms.

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

[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, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. 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, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment 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] To illustrate the above-mentioned features and effects of the present invention more clearly and easily, the following embodiments are specifically described below with reference to the accompanying drawings. This specification discloses one or more embodiments incorporating the features of the present invention. The disclosed embodiments are for illustrative purposes only. The scope of protection of the present invention is not limited to the disclosed embodiments; the present invention is defined by the appended claims.

[0100] To address the shortcomings of existing soil nutrient detection methods, this paper proposes a soil nutrient prediction method based on gamma ray spectroscopy and the XGboost algorithm. This method uses gamma rays in soil as its research object. Using a vehicle-mounted gamma spectrometer, the method identifies the types and contents of radioactive elements in the soil. It then establishes a physical and chemical relationship between these elements and the active substances and their contents in the soil nutrients. Through continuous training, iteration, and parameter optimization using large amounts of data, the model's prediction accuracy is improved, along with the efficiency of soil nutrient detection, providing technical support for differentiated fertilization and seeding.

[0101] In order to achieve the above-mentioned purpose, the technical solution 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, and brown soil 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. After preprocessing, a training set and a test set are constructed; the XGboost algorithm model hyperparameter objective function is determined; the parameter is tuned using the Bayesian-based hyperopt hyperparameter; and a soil nutrient prediction model based on the XGboost algorithm for determining soil type is constructed and applied.

[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 dataset, eliminating 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 is intended to find the optimal configuration of n hyperparameters, so as to maximize the performance of the XGboost model in the data set. It breaks the currently commonly used method of finding a good combination of hyperparameters required for the model after a large amount of search or repeated iterative optimization in the configuration space. The parameter information calculated using the prior steps can be used to continuously update the verification optimization parameter combination until the XGboost model performance reaches the best. In the actual implementation process of the present invention, parallel operation is supported, the number of iterations is small, and the speed is fast. The present invention introduces a penalty function and a regularization term in the application method to effectively prevent overfitting.

[0104] The present invention proposes a soil nutrient prediction method based on gamma ray spectroscopy 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: Raw soil information data collection: Under actual farmland operation conditions, two sets of data were collected from the same soil point. One set used the uniform sampling method to collect and test soil nutrient data; the other set used 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 plot data information, use longitude and latitude to mark the plot boundaries, and obtain the data within the plot. The data within the plot includes: soil properties, soil original gamma spectrum information, soil radioactive element information, soil nutrient data at the same site, and longitude and latitude;

[0109] Step 2: Construct a dataset. Extract soil data corresponding to different soil types, such as black soil, sandy soil, saline-alkali soil, and brown soil, from the basic soil information database. This data includes 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 index.

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

[0111] Step 2.2: Construct a data set including characteristic values ​​and target values. Use the soil radioactive element and soil nutrient data preprocessed in step 2.1 to construct characteristic values ​​and target values ​​according to the data type to construct the 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 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, using the feature data, plot number, soil properties, and longitude and latitude in the dataset obtained in step 2 as the input of the XGboost model, and the target value in the dataset 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, which is defined as:

[0118]

[0119] 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 gap, and Ω(f i ) is a regularization term used to control the complexity of the model and prevent overfitting.

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

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

[0122]

[0123] Here, we can find the extreme value to obtain the minimum value of the objective function, that is, the loss function is minimized. 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 The sum of the first-order derivatives of all samples of the j-th leaf node, H j is the sum of the second-order derivatives of all samples of the j-th 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, an 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 dataset D. The specific steps are as follows:

[0125] Step 4.1: Define the objective function for 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 their performance, the optimal set of hyperparameters is obtained when the objective value is the minimum. 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 penalty 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 data from Step 2 into the XGboost algorithm model. A soil nutrient prediction model based on gamma ray spectrum and XGboost algorithm for a specific soil type 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: Collection of original soil information data. In the actual farmland operation environment, two sets of soil data were collected simultaneously. One set used the uniform sampling method, and these soil samples were sent to the laboratory for testing of soil pH, organic matter, organic carbon, total potassium and other indicators; the other set used a vehicle-mounted gamma spectrometer to collect the original spectrum information of radioactive element data. The vehicle operated at a constant speed along the specified route and performed non-repeated sampling at a frequency of 5 Hz.

[0137] Step 1.2: Convert soil radioactivity spectrum information into the type and content of soil radioactive elements. First, use a laboratory high-purity germanium detector to measure the soil sample to determine the soil properties, identify each energy peak, calculate the peak shape, and select the nuclide energy peak with certain characteristics, such as Figure 2 Since the energy peaks in the soil radioactivity spectrum curve correspond to the channel addresses in a one-to-one relationship, 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. Based on the energy involved in the high-purity germanium measurement, the area of ​​the channel address corresponding to the spectrum line is summed 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. By calculating the total number of peaks corresponding to the identified radioactive elements within the peak boundary, the corresponding content of the radioactive element per unit time can be calculated.

[0138] Step 1.3: Construct the plot data information, use the longitude and latitude to mark the plot boundary, and use the ray method to determine whether the trajectory point of the vehicle-mounted gamma spectrometer 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 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 determination, a basic soil information database is constructed, including the plot number, plot area, soil properties, raw soil gamma spectrum information, soil radioactive element information, soil nutrient data at the same point, and longitude and latitude.

[0141] Step 2: Construct a dataset. The data is collected from actual farmland operation data in a certain area. 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 basic soil information database. This includes: plot number, soil properties, soil radioactive element information, soil nutrient data at the same point, and longitude and latitude. The data is organized into a two-dimensional matrix with characteristic parameters as feature columns and longitude and latitude as indexes. The specific 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 of a certain time period when 4G communication interruption occurs.

[0145] (2) Outlier processing

[0146] For soil radioactive elements such as Pb-212-85 and Ra-226 whose contents exceed the normal range, such data should be deleted. For data that deviate significantly from the normal value, a box plot algorithm can be used to identify and delete them.

[0147] (3) Data processing under abnormal working 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 dataset including characteristic values ​​and target values. The soil radioactive elements and soil nutrient data preprocessed in step 2.1 are shown in Table 1. According to the data type, characteristic values ​​and target values ​​are constructed. 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 dataset is randomly divided into a training set and a test set in a 4:1 ratio.

[0153] Serial number Parameter name unit Serial number Parameter name unit 1 Pb-212 pieces / kg 10 PH pH 2 Ra-226 pieces / kg 11 organic matter g / kg 3 Pb-214 pieces / kg 12 Total potassium g / kg 4 Tl-208 pieces / kg 13 organic carbon mg / kg 5 Bi-214 pieces / kg 14 6 Cs-137 pieces / kg 15 7 Ac-228 pieces / kg 16 8 Co-60 pieces / kg 17 9 K-40 pieces / 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 eigenvalues ​​one by one to measure the degree of correlation between the target values ​​and the eigenvalues. Mark the eigenvalues ​​that are determined to be strongly correlated and record their correlation strength in the data set so that these eigenvalues ​​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] Where x and y represent the characteristic parameter and target parameter in the dataset, i.e., various soil radioactive elements and soil nutrient data, respectively. n is the number of selected data points, ranging from -1 to 1, with larger absolute values ​​indicating stronger correlation. The correlation coefficient between each soil radioactive element and each soil nutrient data point is calculated, and characteristic parameters and target parameters with higher correlation coefficients are selected. In actual operation, the present invention uses |r| ≥ 0.5 as the selection criterion.

[0159] Step 3: Determine the hyperparameter objective function of the machine learning algorithm, specifically including: constructing the XGboost model Y, using the feature data, plot number, soil properties, and longitude and latitude in the dataset after step 2 as the input of the XGboost model, and the target value in the dataset 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 purpose, 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 and convert the target function into a function about the leaf nodes.

[0166] For the form of the nth decision tree leaf node, 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 The sum of the first-order derivatives of all samples of the j-th leaf node, H j is the sum of the second-order derivatives of all samples of the j-th 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, an 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 dataset D. The specific steps are as follows:

[0170] Step 4.1: Define the objective function for 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 their performance, the optimal set of hyperparameters is obtained when the objective value is the minimum. The formula is defined as:

[0171]

[0172] Step 4.2: When setting the type and value range of hyperparameters, in the specific implementation process of Bayesian hyperparameter tuning, the present invention uses the TPE optimization algorithm based on the 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 the XGboost algorithm

[0175] Step 4.3: Find the hyperparameter combination that minimizes the reward and penalty function. Nest the Bayesian optimization algorithm into the XGboost algorithm model. Find the optimal hyperparameter combination by minimizing the reward and penalty function. Then, input the optimal hyperparameter combination and test set data into the XGboost algorithm model for training. Root mean squared error (RMSE) and R 2 As the model accuracy evaluation indicators, 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 training and test sets in a ratio of 4:1;

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

[0183] (4) In the Bayesian optimization process, the 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 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 a soil nutrient prediction model based on the XGboost algorithm to determine the soil quality and apply it. 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 ray 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 actual values, as shown in the following example: Figure 6 As shown, the corresponding RMSE, 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, and total potassium is 0.2126 and 0.91. The ratio between the predicted value and the actual value is greater than 90%, which determines that the prediction model is qualified and can be used to predict soil nutrients.

[0191] The present invention is based on the mechanistic relationship between gamma energy spectrum and soil nutrients, combined with the XGboost algorithm to predict soil nutrients. The gamma ray spectrum in farmland is collected by a gamma spectrometer, and is parsed into the types and quantities of radioactive elements through energy peak recognition and peak shape calculation. A nonlinear physical and chemical relationship is established between the types and quantities of radioactive elements and the types and quantities of soil nutrients using a combination of qualitative and quantitative methods. This can achieve rapid and low-cost soil nutrient detection through the gamma spectrometer, which to a certain extent breaks away from the constraints of laboratory soil nutrient testing 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 and will not be repeated here to reduce repetition. Accordingly, the relevant technical details mentioned in this embodiment can also be applied to the above embodiment.

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

[0194] An initial module constructs a training sample for soil nutrient detection, the training sample including: radioactive element data, the label of the training sample being the soil nutrient data of the same soil point where the radioactive element data was collected;

[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. Based on 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 collected radioactive elements into the soil nutrient detection model to obtain the nutrient detection results of the soil to be tested.

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

[0198] The spectral line data of the soil point is measured by a gamma spectrometer. 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 per unit time using the energy peak boundary counting method to obtain the radioactive element data. The radioactive element data 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 ray 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;

[0200] The training module 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 according to the soil property information of the training sample;

[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 the 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 performs n-th iteration training:

[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 gap, and Ω(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] For the form of the nth decision tree leaf node, 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 The sum of the first-order derivatives of all samples of the j-th leaf node, H j is the sum of the second-order derivatives of all samples of the j-th leaf node, γ is the parameter that controls the number of decision tree leaves, and λ is the regularization parameter;

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

[0215] like Figure 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 ray spectrum and XGboost algorithm.

[0216] like Figure 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 organize and 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. It 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, etc. The user is presented with the key information specified by the user, such as the content ratio information of key elements in the nutrient test results, etc. The user can understand this information more promptly without having to visit 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 the user with rich and necessary key information.

[0218] The present invention also provides a computer program product, which includes a computer program. The computer program can be stored on 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] In another embodiment, the present invention further proposes a storage medium VIII 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 DRAM (SLDRAM), and direct rambus RAM (DR RAM).

[0220] Figure 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, workstations, 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 assistants, 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 as 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. Various programs and data required for the operation of the device 1000 can also be stored in the RAM III. 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] Multiple components in the second electronic device 1000 are connected to the I / O interface V, including: an input unit VI, such as a keyboard and mouse; an output unit VII, such as various types of displays and speakers; a storage medium VIII, such as a magnetic disk and optical disk; 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 via a computer network such as the Internet and / or various telecommunication networks.

[0223] Computing unit I can be various 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 that run machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. Computing unit I performs the various methods and processes described above, such as method steps S1-S3. For example, in some embodiments, the method can be implemented as a computer software program that is tangibly contained in a machine-readable medium, such as a storage medium VIII. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 1000 via ROM II and / or communication unit IX. When the computer program is loaded into RAM III and executed by computing unit I, one or more steps of the method described above can be performed. Alternatively, in other embodiments, computing unit I can 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 above, they are not limited to the applications listed in the description and implementation methods. 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 illustrations shown and described herein.

Claims

1. A soil nutrient detection method based on gamma ray spectroscopy and XGboost algorithm, characterized in that: include: In the initial step, a training sample for soil nutrient detection is constructed, the training sample including: radioactive element data, the label of the training sample being the soil nutrient data of the same soil point where the radioactive element data was collected; 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. In the monitoring step, radioactive elements of the soil to be tested are collected by a gamma spectrometer and input into the soil nutrient detection model to obtain nutrient detection results of the soil to be tested.

2. The soil nutrient detection method based on gamma ray spectroscopy and XGboost algorithm according to claim 1, characterized in that: This initial step includes: The spectral line data of the soil point is measured by a gamma spectrometer. 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 per unit time using the energy peak boundary counting method to obtain the radioactive element data. The radioactive element data 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 ray spectroscopy and XGboost algorithm according to 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 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 ray spectroscopy and XGboost algorithm according to claim 1, wherein: The training steps include: The XGboost model is a tree model. When the tree model performs n-th iteration training: in Indicates the training samples, 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, 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 actual soil nutrients The gap, and is the regularization term; Calculate the optimal target value of the model and transform the target function into a function about the leaf nodes. For the form of the nth decision tree leaf node, the ultimate value of the objective function is: in, is the number of leaf nodes of the decision tree, For each leaf index, is the predicted score of the current leaf, For the The sum of the first-order derivatives of all samples of leaf nodes, For the The sum of the second-order derivatives of all samples of leaf nodes, To control the number of decision tree leaves, is the regularization parameter; Bayesian hyperopt hyperparameter tuning, given a dataset D consisting of training samples, an XGboost model Y, and defining the hyperparameter domain ,turn up The optimal set of hyperparameter configurations in , to improve the prediction performance of the model XGboost model on dataset D.

5. A soil nutrient detection device based on gamma ray spectroscopy and XGboost algorithm, characterized in that: include: An initial module constructs a training sample for soil nutrient detection, the training sample including: radioactive element data, the label of the training sample being the soil nutrient data of the same soil point where the radioactive element data was collected; 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. Based on 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 collected radioactive elements into the soil nutrient detection model to obtain the nutrient detection results of the soil to be tested.

6. The soil nutrient detection device based on gamma ray spectrum and XGboost algorithm according to claim 5, characterized in that: This initial module includes: The spectral line data of the soil point is measured by a gamma spectrometer. 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 per unit time using the energy peak boundary counting method to obtain the radioactive element data. The radioactive element data 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 ray spectrum and XGboost algorithm according to 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: 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 according to the soil property information of the training sample; 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 the 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 performs n-th iteration training: in Indicates the training samples, 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, 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 actual soil nutrients The gap, and is the regularization term; Calculate the optimal target value of the model and transform the target function into a function about the leaf nodes. For the form of the nth decision tree leaf node, the ultimate value of the objective function is: In the formula is the number of leaf nodes of the decision tree, For each leaf index, is the predicted score of the current leaf, For the The sum of the first-order derivatives of all samples of leaf nodes, For the The sum of the second-order derivatives of all samples of leaf nodes, To control the number of decision tree leaves, is the regularization parameter; Bayesian hyperopt hyperparameter tuning, given a dataset D consisting of training samples, an XGboost model Y, and defining the hyperparameter domain ,turn up The optimal set of hyperparameter configurations in , to improve the prediction performance of the model XGboost model on dataset D.

8. An electronic device, characterized in that: The invention comprises a soil nutrient detection device based on gamma spectroscopy and XGboost algorithm as described in any one of claims 5 to 7, wherein the electronic device is connected to an information display device, and the information display device is used to display the nutrient detection results according to user settings 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 computer program implements the steps of the soil nutrient detection method based on gamma ray spectroscopy and XGboost algorithm according to any one of claims 1 to 4.

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 ray spectrum and XGboost algorithm described in any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

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

    CN118858594A

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

    WO2024139684A1