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.