Machine learning based regional soil selenium content prediction method and system
Patent Information
- Application Number
- CN202611391821.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-09
- Publication Date
- 2026-10-13
AI Technical Summary
[0002]土壤硒含量是富硒土地资源评价、农业开发利用和土壤环境管理的重要基础数据,土壤中的硒分布受成土母质、土壤理化性质及多种环境因素的综合影响,传统研究主要通过野外采样、实验测定以及相关分析、回归分析和地统计插值等方法分析土壤硒含量及其空间分布,检测时间长,分析效率较低,近年来,机器学习逐渐应用于土壤硒及其他土壤属性预测,通常以土壤性质、元素地球化学、地质背景、气候和地形等环境因子作为输入变量,通过模型训练建立环境特征与土壤硒含量之间的非线性关系
[0057]1、本发明可以根据土壤样品的多源环境数据构建成土过程数据,实现土壤硒含量预测。其中,本发明可以获取多源环境变量,使模型输入能够体现不同环境因素与土壤硒形成和富集过程之间的联系,并且,本发明通过计算化学蚀变指数和铁铝比两个关键衍生指标,将主要元素氧化物含量之间的相对变化转化为具有明确成土过程含义的定量信息,化学蚀变指数能够定量反映铝质组分相对保留以及钙、钠、钾等活动性组分在化学风化过程中的淋失程度,铁铝比能够定量反映铁质组分相对于铝质组分的富集程度及其所表征的土壤硒吸附和固定条件,通过将独热编码后的类别特征、原始连续变量及化学蚀变指数、铁铝比等成土过程表征指标组合,形成具有明确成土过程含义的多源环境特征矩阵,使得模型输入特征能够综合反映成土过程对土壤硒含量的综合影响。
Smart Images

Figure CN122907185A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to data processing technology, and more particularly to a method and system for predicting regional soil selenium content based on machine learning. Background Technology
[0002] Soil selenium content is an important basic data for the evaluation of selenium-rich land resources, agricultural development and utilization, and soil environmental management. The distribution of selenium in soil is affected by the parent material, soil physicochemical properties, and various environmental factors. Traditional studies mainly analyze soil selenium content and its spatial distribution through field sampling, experimental measurement, correlation analysis, regression analysis, and geostatistical interpolation. These methods are time-consuming and have low analysis efficiency. In recent years, machine learning has been gradually applied to the prediction of soil selenium and other soil properties. It usually uses environmental factors such as soil properties, elemental geochemistry, geological background, climate, and topography as input variables, and establishes a nonlinear relationship between environmental characteristics and soil selenium content through model training.
[0003] However, existing methods for predicting selenium content in regional soils lack a systematic organization of multi-source environmental data variables around the processes of parent material supply, weathering release, migration, and fixation, making it difficult to form a characteristic expression with clear meaning of soil formation processes.
[0004] Therefore, how to construct soil process data based on multi-source environmental data of soil samples to predict soil selenium content has become an urgent problem to be solved. Summary of the Invention
[0005] This invention provides a method and system for predicting regional soil selenium content based on machine learning. It can construct soil process data based on multi-source environmental data of soil samples to predict soil selenium content.
[0006] A first aspect of this invention provides a method for predicting regional soil selenium content based on machine learning, comprising:
[0007] Based on the predicted sample dataset of the sample to be predicted, the soil formation process characteristics are calculated to obtain the multi-source predicted environmental feature matrix;
[0008] Based on the prediction model, soil selenium is predicted using the multi-source predicted environmental feature matrix to obtain the logarithmic predicted value of soil selenium. The logarithmic predicted value of soil selenium is then transformed using an antilogarithmic method to obtain the predicted value of soil selenium.
[0009] Based on the predicted soil selenium values, the impact analysis results of key environmental characteristics in the predicted sample dataset were determined.
[0010] The output data, obtained based on the predicted soil selenium value and the impact analysis results, is sent to the management terminal.
[0011] Optionally, in one possible implementation of the first aspect, the step of predicting soil selenium based on the multi-source predicted environmental feature matrix using a prediction model to obtain a predicted logarithmic value of soil selenium includes:
[0012] The candidate prediction models are trained and screened to obtain the prediction model;
[0013] Based on the prediction model, soil selenium is predicted using the multi-source predicted environmental feature matrix to obtain the logarithmic predicted value of soil selenium.
[0014] Optionally, in one possible implementation of the first aspect, the step of training and filtering candidate prediction models to obtain a prediction model includes:
[0015] The sampling locations of soil samples, measured soil selenium data, and environmental data from multiple sources are obtained and matched to generate a basic sample dataset.
[0016] Based on the sample sampling locations, the basic sample dataset is spatially partitioned to obtain a training set and a test set.
[0017] Based on the training set, soil formation process features are calculated to obtain a multi-source environmental feature matrix;
[0018] Based on the training set, test set and multi-source environmental feature matrix, the candidate prediction model is trained and predicted in stages, and the predicted value of soil selenium for each soil sample is output.
[0019] Evaluation data for each candidate prediction model is calculated based on the predicted values of soil selenium in the test set and the measured soil selenium data. The evaluation data includes the coefficient of determination, root mean square error, and mean absolute error.
[0020] Based on the evaluation data, candidate prediction models are selected to obtain the prediction model.
[0021] Optionally, in one possible implementation of the first aspect, the step of acquiring soil sample sampling locations, measured soil selenium data, and multi-source sample environmental data through data matching and correlation to generate a basic sample dataset includes:
[0022] Based on a preset order, the sample sampling locations, multi-source sample environmental data, and soil selenium measurement data corresponding to each soil sample are matched and associated sequentially to obtain the sample point data corresponding to each soil sample.
[0023] The basic sample dataset is obtained by statistically analyzing the sample point data corresponding to each soil sample.
[0024] Optionally, in one possible implementation of the first aspect, the step of spatially partitioning the basic sample dataset based on the sample sampling locations to obtain a training set and a test set includes:
[0025] Based on the sampling location of the soil sample, the sample analysis area is obtained. The sample analysis area is then divided into regular grids according to a preset size to obtain multiple sample division units.
[0026] The sample point data of the same sample division unit are labeled to obtain sample unit labels. The sample point data with the same sample unit labels are combined to obtain the sample point unit dataset.
[0027] Based on a preset sample splitting ratio, the sample point unit dataset is randomly selected for sample splitting to obtain training set and test set respectively.
[0028] Optionally, in one possible implementation of the first aspect, the step of calculating soil formation process features based on the training set to obtain a multi-source environmental feature matrix includes:
[0029] One-hot encoding is performed on the categorical variables in the sample point data of the training set to obtain the categorical feature data of each categorical variable;
[0030] The chemical alteration index and iron-aluminum ratio are calculated based on the elemental geochemical data in the multi-source sample environmental data. The elemental geochemical data includes the oxides of major elements and the contents of related elements.
[0031] Based on a preset index splicing order, the category feature data, original continuous variables, chemical alteration index, and iron-aluminum ratio are combined and spliced to obtain a multi-source environmental feature matrix.
[0032] Optionally, in one possible implementation of the first aspect, the step of training and predicting the candidate prediction model in stages based on the training set, the test set, and the multi-source environmental feature matrix, and outputting the predicted soil selenium value for each of the soil samples, includes:
[0033] When the input feature type of the candidate prediction model is determined to be of the same scale type, the original continuous variables in the multi-source environmental feature matrix are standardized to obtain the input feature matrix of the corresponding candidate prediction model.
[0034] When the input feature type of the candidate prediction model is determined to be of the same non-scale type, the multi-source environmental feature matrix is used as the input feature matrix of the corresponding candidate prediction model.
[0035] During the training phase of the training set, candidate prediction models are trained based on preset model parameters;
[0036] After the training phase is completed, the test phase begins. The multi-source environmental feature matrix of the test set is retrieved and input into each candidate prediction model to predict soil selenium. Each candidate prediction model outputs the predicted soil selenium value of the soil sample.
[0037] Optionally, in one possible implementation of the first aspect, the step of selecting candidate prediction models based on the evaluation data to obtain a prediction model includes:
[0038] The coefficient of determination closest to 1 is determined as the candidate coefficient of determination. The difference between the candidate coefficient of determination and the other coefficients of determination is calculated to obtain the coefficient of determination difference.
[0039] When it is determined that there is no difference in the coefficient of determination less than the first preset threshold, the candidate prediction model corresponding to the candidate coefficient of determination is selected as the prediction model.
[0040] When it is determined that there is a difference in the coefficient of determination that is less than the first preset threshold, the candidate prediction model corresponding to the corresponding coefficient of determination is taken as the first candidate prediction model.
[0041] The smallest root mean square error is taken as the candidate root mean square error. The difference between the candidate root mean square error and the other root mean square errors is calculated based on the first candidate prediction model to obtain the root mean square error difference.
[0042] When it is determined that there is no root mean square error difference less than the second preset threshold, the first candidate prediction model corresponding to the candidate root mean square error is selected as the prediction model.
[0043] When it is determined that there is a root mean square error difference less than the second preset threshold, the corresponding first candidate prediction model is used as the second candidate prediction model;
[0044] The second candidate prediction model with the smallest mean absolute error is selected as the prediction model.
[0045] Optionally, in one possible implementation of the first aspect, the step of determining the impact analysis results of key environmental characteristics in the predicted sample dataset based on the predicted soil selenium values includes:
[0046] Calculate the contribution of each key environmental feature in the prediction sample dataset to the predicted value of soil selenium;
[0047] Calculate the average absolute contribution value of each of the key environmental features based on the contribution value, and calculate the relative contribution ratio of the corresponding key environmental features based on the average absolute contribution value.
[0048] The key environmental features are sorted in descending order based on the average absolute contribution value and the relative contribution ratio to obtain a key environmental feature sequence.
[0049] When the average contribution value of the key environmental feature is positive, it indicates that the corresponding key environmental feature has a positive effect on the predicted value of soil selenium; when the average contribution value of the key environmental feature is negative, it indicates that the corresponding key environmental feature has a negative effect on the predicted value of soil selenium.
[0050] The impact analysis results are obtained based on the relative contribution ratio, the positive effect results, and the negative effect results.
[0051] A second aspect of the present invention provides a regional soil selenium content prediction system based on machine learning, comprising:
[0052] The calculation module is used to calculate the soil formation process characteristics based on the predicted sample dataset of the sample to be predicted, and obtain the multi-source predicted environmental feature matrix.
[0053] The prediction module is used to predict soil selenium based on the multi-source predicted environmental feature matrix using a prediction model, obtain the logarithmic predicted value of soil selenium, and perform an anti-logarithmic transformation on the logarithmic predicted value of soil selenium to obtain the predicted value of soil selenium.
[0054] The analysis module is used to determine the impact analysis results of key environmental characteristics in the predicted sample dataset based on the predicted soil selenium values.
[0055] The sending module is used to send the output data obtained from the predicted soil selenium value and the impact analysis results to the management terminal.
[0056] The beneficial effects of this invention are as follows:
[0057] 1. This invention can construct soil formation process data based on multi-source environmental data of soil samples to predict soil selenium content. Specifically, this invention can acquire multi-source environmental variables, enabling the model input to reflect the relationship between different environmental factors and the formation and enrichment process of soil selenium. Furthermore, by calculating two key derived indicators, the chemical alteration index and the iron-aluminum ratio, this invention transforms the relative changes in the content of major element oxides into quantitative information with a clear meaning of soil formation process. The chemical alteration index can quantitatively reflect the relative retention of aluminum components and the leaching degree of active components such as calcium, sodium, and potassium during chemical weathering. The iron-aluminum ratio can quantitatively reflect the enrichment degree of iron components relative to aluminum components and the soil selenium adsorption and fixation conditions it represents. By combining the uniquely thermally encoded categorical features, original continuous variables, and soil formation process characterization indicators such as the chemical alteration index and the iron-aluminum ratio, a multi-source environmental feature matrix with a clear meaning of soil formation process is formed, allowing the model input features to comprehensively reflect the comprehensive impact of soil formation process on soil selenium content.
[0058] 2. This invention can partition samples based on spatial constraints, avoiding spatial information leakage and improving the accuracy of model performance evaluation data. Specifically, this invention can divide the sample analysis area into a pre-defined grid of regular dimensions based on the spatial coordinates of the soil sample. Using a complete spatial grid as the sample partitioning unit, each spatial grid is randomly assigned to either the training or test set. This ensures that all samples within the same spatial grid can only be included in one dataset as a whole. The test set remains independent during model training and parameter adjustment, and is used only for the final prediction performance evaluation. This avoids spatial information leakage caused by spatially adjacent samples simultaneously entering both the training and test sets, allowing the model evaluation to more accurately reflect its predictive ability for spatially independent samples.
[0059] 3. This invention can comprehensively evaluate the predictive performance of each model using three indicators: coefficient of determination, root mean square error, and mean absolute error. Based on this, a three-level progressive screening mechanism is used to screen candidate prediction models layer by layer, thereby selecting the prediction model with better comprehensive performance and improving the accuracy of soil selenium prediction values. Attached Figure Description
[0060] Figure 1 A flowchart of a machine learning-based method for predicting regional soil selenium content provided by the present invention;
[0061] Figure 2 A schematic diagram of the structure of a machine learning-based regional soil selenium content prediction system provided by the present invention;
[0062] Figure 3 This is a schematic diagram of the hardware structure of an electronic device provided by the present invention. Detailed Implementation
[0063] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0064] The technical solution of the present invention will be described in detail below with reference to specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0065] like Figure 1 As shown, this invention provides a method for predicting regional soil selenium content based on machine learning, comprising:
[0066] S1, calculate the soil formation process characteristics based on the predicted sample dataset of the sample to be predicted, and obtain the multi-source predicted environmental feature matrix.
[0067] It should be noted that before obtaining the soil selenium content of the area to be predicted, the sample to be predicted only contains spatial location information and raw environmental data such as geological background, climate and topography extracted from spatial data, but does not contain the measured soil selenium content. In order to input it into the machine learning prediction model and output the logarithmic predicted value of soil selenium of the sample to be predicted, these raw environmental data need to be converted into the input feature form that is completely consistent with the model training stage. At the same time, the predicted soil selenium content is not determined by a single environmental factor, but is jointly affected by soil formation processes such as parent material supply, chemical weathering, leaching and migration, and adsorption and fixation of iron components. If the raw measured values are directly input into the model, it is difficult to reflect the control mechanism of selenium enrichment and affect the scientificity of the prediction results. Therefore, before inputting into the prediction model, it is necessary to calculate key derived indicators that can quantitatively characterize the degree of chemical weathering and the relative enrichment of iron components from the raw environmental data based on the knowledge of soil formation processes, and convert categorical variables into numerical codes in order to form a standardized multi-source environmental feature matrix.
[0068] Understandably, the process involves obtaining the spatial coordinates of the sample to be predicted and extracting corresponding environmental attribute values from pre-collected multi-source spatial data. This multi-source spatial data includes geological background such as strata or lithology, annual average precipitation, annual average temperature, elevation, and slope, as well as soil properties such as organic carbon, nitrogen, sulfur, pH, and elemental geochemical indicators such as TFe₂O₃, Al₂O₃, CaO, Na₂O, and K₂O. Furthermore, for categorical variables such as geological background and soil type that cannot be directly involved in numerical calculations, the same one-heat coding rule as in the training phase is used. This involves converting each category into an independent binary variable; for example, the granite area is coded with a value of 1 in one column and 0 in the rest, avoiding the artificial introduction of order relationships between categories. Simultaneously, the chemical alteration index (CIA) and the iron-aluminum ratio (Fe / Al) are calculated based on the extracted main element oxide content. The CIA is calculated according to the formula... Calculations are performed to reflect the degree of leaching of active components calcium, sodium, and potassium during chemical weathering, with the Fe / Al ratio calculated according to the formula. The calculations are performed to reflect the enrichment of iron components relative to aluminum components and their impact on selenium adsorption and fixation capacity. The uniquely thermally encoded category features, original continuous variables, and calculated CIA and Fe / Al are then combined and spliced in a preset order to form a multi-source prediction environment feature matrix that is completely consistent with the training data structure, which serves as the input for subsequent prediction models.
[0069] Among them, the sample to be predicted is a soil sample waiting to be predicted for soil selenium content. The prediction sample dataset is a data set obtained by matching the multi-source environmental data corresponding to the sample to be predicted. It adopts the same method as the basic sample dataset obtained in the training process, which will not be elaborated here. The multi-source prediction environment feature matrix is the feature vector matrix input to the prediction model for soil selenium prediction. It is the same feature matrix with the same data structure as the multi-source environment feature matrix obtained in the training phase.
[0070] For example, in practical applications, each sample to be predicted is eventually converted into a feature vector with fixed dimensions, including geological codes, climate data, soil properties, and derived indices.
[0071] S2, Based on the prediction model, predict soil selenium on the multi-source predicted environmental feature matrix to obtain the logarithmic predicted value of soil selenium, and perform anti-logarithmic transformation on the logarithmic predicted value of soil selenium to obtain the predicted value of soil selenium.
[0072] It should be noted that, since measured soil selenium content data typically exhibits a significantly skewed distribution (i.e., most samples have low selenium content while a few have extremely high selenium content), directly using the original content as the model's prediction target would lead to a large learning bias in high-value areas and uneven prediction errors. Therefore, during the model training phase, this invention performs a logarithmic transformation on the measured soil selenium content, using the transformed value as the model's learning target. This makes the data distribution closer to a normal distribution, which is beneficial for improving the model's fitting effect and prediction stability. It is easy to understand that when the obtained data distribution conforms to a normal distribution, no logarithmic processing will be performed during the prediction process, and consequently, no antilogarithmic transformation will be performed. The logarithmic transformation process is only selectively processed based on the actual data distribution characteristics. Accordingly, the prediction model output is a predicted value on a logarithmic scale, which is not the actual content. Therefore, it needs to be transformed using an antilogarithmic transformation to restore the predicted soil selenium value on the original content scale for subsequent land resource assessment and environmental management.
[0073] Understandably, after obtaining the multi-source environmental feature matrix of the sample to be predicted, this matrix is input into the optimal machine learning prediction model obtained through pre-training and screening. The prediction model calculates and outputs the predicted natural logarithm of soil selenium for each sample to be predicted based on the nonlinear mapping relationship between environmental features and soil selenium logarithmic content learned during the training phase. For example, if the model outputs a predicted natural logarithm value of z, then through exponential transformation e... z This will restore the predicted soil selenium value to its original content scale.
[0074] Among them, the prediction model is a learning model for predicting soil selenium. The logarithmic prediction value of soil selenium is the predicted value of soil selenium at the logarithmic scale output by the prediction model. The predicted value of soil selenium is the predicted value of soil selenium at the original scale content, that is, the soil selenium content value corresponding to the unit mg / kg.
[0075] In some embodiments, the specific implementation steps of step S2 include:
[0076] S21, Train and screen the candidate prediction models to obtain the prediction model.
[0077] It should be noted that different learning models have different applicable scenarios and data fitting capabilities. For predicting soil selenium content in a specific region, a single model may not be able to achieve good prediction accuracy. For example, random forests are good at capturing nonlinear relationships but may overfit, support vector regression performs well with small samples but has high computational cost for large-scale data, and extreme gradient boosting usually performs well on structured data but requires fine-tuning of parameters. Therefore, it is impossible to determine in advance which model is most suitable for predicting soil selenium in the target region. It is necessary to systematically train and compare multiple candidate models to select the one with the best overall prediction performance as the final prediction model in order to improve the accuracy and reliability of the prediction results.
[0078] Understandably, based on the acquired basic sample dataset, training and test sets are determined through spatial constraints. Multiple candidate machine learning models of different types are then constructed in parallel, including random forest, extreme gradient boosting, support vector regression, class boosting, and multilayer perceptron. During training, each candidate model uses preset training set parameters for parameter training, and its predictive performance and stability are evaluated using five-fold cross-validation within the training set. After training, all candidate models are applied to the test set for independent predictions, obtaining prediction results for each model on independent samples not used in training. Finally, the error statistics between the predicted and measured values of each model on the test set are comprehensively compared, and the candidate model with the best overall evaluation is selected as the final prediction model.
[0079] Among them, the candidate prediction model is a learning model that needs to be trained and screened, such as random forest, extreme gradient boosting, support vector regression, class boosting and multilayer perceptron.
[0080] In some embodiments, the specific implementation steps of step S21 include:
[0081] S211: Obtain the sampling location of soil samples, measured soil selenium data, and environmental data from multiple sources, perform data matching and correlation, and generate a basic sample dataset.
[0082] It should be noted that the construction of the soil selenium content prediction model requires a large amount of sample data. The measured soil selenium data comes from laboratory chemical analysis after field sampling, recording the latitude and longitude coordinates of each sample and its corresponding selenium content. Multi-source environmental data includes the geological background, soil properties, elemental geochemistry, climate, and topographic data corresponding to the soil samples. Among them, geological background data includes strata, lithology, or geological unit type; soil property data includes soil organic carbon, nitrogen, sulfur, phosphorus, and pH; elemental geochemistry data includes major element oxides and related element contents; climate data includes annual average precipitation and annual average temperature; and topographic data includes elevation and slope. These data cannot be directly used by the model when they exist independently. It is necessary to correspond and associate the spatial location of each soil sample with the multi-source sample environmental data of its location and the measured soil selenium data corresponding to the model training target to form a complete sample record as a basic sample dataset. This facilitates the subsequent generation of the corresponding multi-source environmental matrix based on the basic sample dataset and input it into the candidate prediction model for model training.
[0083] It is understandable that the soil samples are samples collected in advance by humans during model training, the sample sampling location is the spatial coordinate location corresponding to the soil sample, the measured soil selenium data is the soil selenium content obtained in advance by humans according to existing analytical methods, the multi-source sample environmental data is the various environmental data corresponding to the soil sample, including the geological background, soil properties, elemental geochemistry, climate and topography data corresponding to the soil sample, etc., and the basic sample dataset is the sample data set for model training and testing obtained by matching the relevant data of multiple soil samples collected in advance by humans.
[0084] In some embodiments, the specific implementation steps of step S211 include:
[0085] S2111, based on a preset order, the sample sampling location, multi-source sample environmental data and soil selenium measured data corresponding to each soil sample are matched and associated sequentially to obtain the sample point data corresponding to each soil sample.
[0086] It should be noted that the data matching and association process involves a variety of data types, including coordinate data, environmental data, and chemical test data from different databases or data files. If the matching order is disordered, it is very easy to cause data correspondence errors. For example, matching the environmental data of sample A to the record of sample B will contaminate the training data and seriously affect the effectiveness of the model. Therefore, a clear preset order can be set in advance to ensure that each matching operation is traceable and verifiable, and to ensure that all attributes of each soil sample are not misplaced or omitted during the association process.
[0087] Understandably, using the unique identifier of the soil sample as the primary key, the sampling location (latitude and longitude coordinates) is associated with the measured selenium content in the soil measured in the laboratory, forming a basic record containing the sample number, coordinates, and selenium content. Then, using this coordinate as a data matching reference value, various spatial environmental data corresponding to this location are extracted in sequence. For example, first, category attributes such as geological background and soil type are extracted, then climate attributes such as annual average precipitation and annual average temperature are extracted, and finally, topographic attributes such as elevation and slope are extracted, as well as soil physicochemical attributes such as organic carbon, total iron, and alumina obtained through local soil surveys. Then, all the environmental data extracted in the above sequence are added to the basic record in turn, thus forming a single sample point data containing all input features and output targets.
[0088] For example, for sample JX-001, the preset order is coordinates, measured soil selenium content, geological type, average annual precipitation, average annual temperature, elevation, slope, organic carbon, total iron, and alumina. After extracting and filling in each item in this order, the complete sample point data record of the sample is obtained.
[0089] The preset order is a data matching order that is set in advance by humans, and the sample point data is the data set corresponding to a single soil sample.
[0090] S2112, Statistically analyze the sample point data corresponding to each soil sample to obtain the basic sample dataset.
[0091] Understandably, the data from all matched soil samples are aggregated and organized into a two-dimensional table according to a unified field order, such as sample number, longitude and latitude coordinates, measured selenium content in the soil, geological background, average annual precipitation, average annual temperature, elevation, slope, organic carbon, total iron, alumina, calcium oxide, sodium oxide, potassium oxide, etc. In this table, each row represents a soil sample, and each column represents an attribute or variable. After aggregation, the table undergoes a comprehensive statistical check, including verifying the completeness of each column's data (e.g., confirming the presence of numerous missing values and the reasonableness of numerical ranges, such as whether pH values are between 0 and 14 and whether precipitation is non-negative). Data records with obvious anomalies are deleted or corrected according to pre-set correction rules. This statistical and preliminary cleaning process forms the foundational sample dataset that can be used for subsequent model building and training.
[0092] For example, a total of 41,955 valid sample point data were collected. Each sample includes coordinates, measured selenium content, and more than 20 matching environmental attributes, which together constitute the basic sample dataset, providing a standardized data foundation for subsequent spatially constrained sample partitioning and model training.
[0093] S212, Based on the sample sampling location, the basic sample dataset is spatially divided to obtain a training set and a test set.
[0094] It should be noted that during machine learning model training, the sample dataset is typically divided into a training set and a test set. The training set is used for model learning and parameter optimization, while the test set is used to evaluate the model's predictive ability on unknown data. However, for spatially continuous geographic data such as soil properties, there is spatial autocorrelation between samples. That is, samples that are spatially close often have similar environmental characteristics and soil properties. If a traditional completely random partitioning method is used, it is likely that spatially close samples will be assigned to the training set and the test set respectively. This would cause the model to indirectly come into contact with information from the test set during training, i.e., spatial information leakage. This would result in an overly optimistic evaluation of the model's performance, failing to truly reflect the model's predictive ability in unsampled areas. Therefore, it is necessary to fully consider the spatial relationship of the samples when partitioning the samples and adopt a spatially constrained partitioning method to ensure that the training set and the test set are spatially independent, so that the model evaluation results are closer to the actual application scenario.
[0095] Understandably, the division of the training and test sets is based on the spatial location of the samples, using spatial grid constraints. Specifically, the sample analysis area is determined according to the distribution range of all soil sample sampling locations, and this area is divided into several regular grid units according to a preset size. Then, the complete grid unit is used as the basic unit of division, and all samples within the same grid are assigned the same unit label. It is ensured that all samples within the same grid can only be included in the training set or the test set as a whole, and samples within the same grid are not allowed to be split into different datasets. Finally, based on the grid unit, according to a preset sample division ratio, for example, the ratio of the number of samples in the training set to the test set is approximately 8:2, a number of grid units are randomly selected and assigned to the training set, and the remaining grid units are assigned to the test set, thereby completing the spatially constrained sample division to avoid spatial information leakage.
[0096] The training set is the dataset used for model training, and the test set is the dataset used to test and evaluate candidate prediction models.
[0097] In some embodiments, the specific implementation steps of step S212 include:
[0098] S2121, Based on the sampling location of the soil sample, the sample analysis area is obtained, and the sample analysis area is divided into regular grids according to a preset size to obtain multiple sample division units.
[0099] Understandably, based on the sampling location coordinates of all soil samples in the basic sample dataset, the distribution range of all samples in planar space is determined, that is, the minimum and maximum values in the longitude and latitude directions are identified, thereby defining the boundary of the sample analysis area. Then, based on the actual area of the study area and the sample distribution density, a preset regular grid size is set. Then, using this preset size as the unit side length, starting from a fixed corner point of the analysis area, such as the northwest corner, the entire sample analysis area is uniformly divided into several regular square or rectangular grid units in the longitude and latitude directions, and each grid unit is assigned a unique spatial number, thus forming multiple sample division units. All soil samples falling within the same grid unit are classified into the same sample division unit and will participate in the dataset division as a whole in the future.
[0100] The sample analysis area is the area corresponding to the collected soil sample. For example, the sample analysis area can be Province A. The preset size is the pre-set unit division size, such as 30km×30km. The sample division unit is the grid division area corresponding to the preset size.
[0101] S2122, the sample point data of the same sample division unit are labeled to obtain sample unit labels, and the sample point data with the same sample unit labels are combined to obtain sample point unit dataset.
[0102] It should be noted that when the sample analysis area is divided into multiple regular grid cells, each soil sample falls within a specific grid cell. However, the relationship between the sample and the grid cell is not explicitly recorded at this point, making it impossible to directly perform subsequent sample division operations based on the grid. Therefore, it is necessary to add the identification information of the grid cell to which each sample belongs, and group all samples according to this identification. This transforms the originally scattered data records based on samples into a combined dataset based on grid cells, providing data structure support for subsequent sample division with the complete grid as the smallest operational unit.
[0103] Understandably, for each soil sample in the basic sample dataset, the latitude and longitude coordinates of its sampling location are used to calculate which spatial range of the divided grid cell the coordinates fall within. The unique number of that grid cell is then added to the sample's record as the sample cell label field. For example, if a sample's coordinates are located in grid number 15, its cell label is recorded as 15. After all samples have been assigned and labeled, all samples are grouped according to their cell labels. That is, all samples labeled 1 are grouped into one group, all samples labeled 2 are grouped into another group, and so on. The number of samples in each group may vary, depending on the sampling density within the grid. After this grouping operation, each group of samples constitutes a sample point cell dataset, corresponding to a complete spatial grid cell. This data structure allows subsequent partitioning to be performed on a whole grid cell basis, ensuring that samples within the same grid are not split.
[0104] The sample unit label is the unit label corresponding to the sample point data, such as the unit number. The sample point unit dataset is the collection of all sample point data in the same sample partitioning unit.
[0105] S2123, Based on a preset sample division ratio, the sample point unit dataset is randomly selected for sample division to obtain a training set and a test set respectively.
[0106] It should be noted that the training set and the test set do not overlap at the spatial grid level, meaning that no single grid cell can appear in both the training set and the test set simultaneously.
[0107] It is understandable that the preset sample split ratio is a pre-defined ratio of the number of samples in the training set to the number of samples in the test set, which is usually determined based on the total number of samples in the study area and the model training requirements.
[0108] S213, calculate the soil formation process features based on the training set to obtain a multi-source environmental feature matrix.
[0109] It is understandable that, since soil selenium content is affected by multiple soil-forming processes such as parent material supply, chemical weathering, migration and fixation, index data of multiple environmental variables can be constructed to obtain a multi-source environmental feature matrix for input into the soil selenium prediction model.
[0110] In some embodiments, the specific implementation steps of step S213 include:
[0111] S2131, Perform one-hot encoding on the category variables in the sample point data of the training set to obtain the category feature data of each category variable.
[0112] It should be noted that the multi-source environmental data used in soil selenium prediction includes categorical variables such as geological background and soil type. These variables have discrete, non-numerical categorical labels. For example, the geological background may include different types such as granite area, sandstone area, and Quaternary sedimentary area. Therefore, one-hot encoding can be used to encode the categorical variables in the multi-source environmental data to obtain the categorical feature data corresponding to each categorical variable. This data can then be combined with other data to obtain a multi-source environmental feature matrix, which is then input into the candidate prediction model to predict the soil selenium content.
[0113] Understandably, the geological background values of all samples in the training set are iterated through to identify all geological background categories appearing in the training set. Each category is then assigned an independent feature column. For example, if there are four geological background types in the training set: granite, sandstone, Quaternary sedimentary rocks, and metamorphic rocks, four new feature columns are created. For a specific sample, the new feature column corresponding to the geological background category is set to 1, while the other three feature columns are set to 0. For example, a sample located in a granite area would have a 1 value in the geological granite column and 0 values in the other three columns. Other category variables, such as soil type, are also encoded according to the same rules. After encoding, the original textual categories such as geological background and soil type have been replaced with several numerical feature columns with values of 0 or 1.
[0114] It is important to emphasize that the category structure and the definition of each coding bit in one-hot encoding are determined entirely based on the training set. If a new category not included in the training set appears in the test set or the sample to be predicted, all its coding bits are set to 0 according to the preset rules.
[0115] Among them, categorical variables are variable data with index type of category in the sample point data, and categorical feature data are feature data obtained after encoding each categorical variable.
[0116] S2132, calculate the chemical alteration index and iron-aluminum ratio based on the elemental geochemical data in the multi-source sample environmental data, wherein the elemental geochemical data includes the oxides of major elements and the contents of related elements.
[0117] It should be noted that the behavior of soil selenium during soil formation is influenced by the degree of chemical weathering. In areas with weak weathering, selenium may mainly be found in primary minerals, while in areas with strong weathering, active components are leached and iron and aluminum oxides are relatively enriched, and selenium may be adsorbed and fixed by iron components. Therefore, the chemical alteration index (CIA) and the iron-aluminum ratio (Fe / Al) can be calculated based on the contents of multiple primary elements. CIA reflects the relative retention of aluminum components and the degree of leaching of active components such as calcium, sodium, and potassium during chemical weathering. Fe / Al reflects the enrichment of iron components relative to aluminum components and the soil selenium adsorption and fixation conditions it reflects. By calculating the chemical alteration index (CIA) and the iron-aluminum ratio (Fe / Al), derived indicators with clear meanings in the soil formation process can be obtained, so that subsequent models can capture the deep environmental information reflected by the synergistic changes between elements.
[0118] Understandably, the formula for calculating the Chemical Alteration Index (CIA) is:
[0119]
[0120] In this study, the molar content of each oxide was calculated by dividing the mass percentage of each oxide by its corresponding molecular weight. CaO is in a silicate-bound state. When CaO reacts with... When the molar ratio is greater than 1, let = That is, CaO equals The molar content of CaO when it is mixed with... When the molar ratio is less than or equal to 1, let =CaO, meaning CaO equals the molar content of CaO itself. The larger the CIA value, the more fully the active components are leached and the stronger the degree of chemical weathering.
[0121] The formula for calculating the Fe / Al ratio is:
[0122]
[0123] in, molar content divided by The molar content of Fe / Al is used to obtain the Fe / Al ratio. The larger the ratio, the higher the enrichment of iron components relative to aluminum components, and the stronger the adsorption and fixation capacity of soil selenium may be.
[0124] For example, when a sample The molar content is 0.25. The molar content is 0.02. The molar content is 0.03. If the molar content is 0.05, then its CIA = 0.25 / (0.25+0.02+0.03+0.05)×100 = 71.43, indicating that the sample has undergone a moderate degree of chemical weathering.
[0125] S2133, based on a preset index splicing order, the category feature data, original continuous variables, chemical alteration index and iron-aluminum ratio are combined and spliced to obtain a multi-source environmental feature matrix.
[0126] It should be noted that, in order to facilitate subsequent batch input into multiple candidate machine learning models for training and comparison, all features need to be concatenated and combined in a consistent and traceable order to form a standardized two-dimensional feature matrix. The structure of this matrix will serve as a standard template for constructing features of the subsequent test set and the sample to be predicted. All new data must be combined in the exact same feature order. Therefore, the category feature data after one-heat encoding, the calculated chemical alteration index and iron-aluminum ratio, and the original continuous variables such as annual precipitation, annual temperature, organic carbon, total iron content, and pH value are combined in sequence according to the preset index concatenation order to obtain a multi-source environmental feature matrix.
[0127] The preset index splicing order is a manually pre-defined order of multidimensional data combinations, and the original continuous variables are the corresponding continuous variable data in the sample point data, such as TOC, N, S, P, pH, etc. , CaO , MgO Zn, Mn, average annual precipitation, average annual temperature, elevation, and slope.
[0128] S214, Based on the training set, test set and multi-source environmental feature matrix, the candidate prediction model is trained and predicted in stages, and the predicted value of soil selenium for each soil sample is output.
[0129] It should be noted that if the test set is used for prediction before the model training is completed, or if the model is exposed to the information of the test set during the training process, the performance evaluation of the model will lose objectivity. Therefore, training and testing can be carried out in stages by dividing the training set and the test set, so as to select a suitable prediction model later.
[0130] Understandably, during the training phase, the model is trained using data from the training set. The candidate prediction model adjusts its parameters by continuously learning the mapping relationship between input features and output targets, and its performance gradually improves as the training process progresses. During the testing phase, the model is used to predict independent data that has never participated in the training to test its generalization ability. In addition, different types of candidate prediction models have different requirements for the scale range of input features, and differentiated data preprocessing is required before model training to address this difference.
[0131] In some embodiments, the specific implementation steps of step S214 include:
[0132] S2141, when the input feature type of the candidate prediction model is determined to be of the same scale type, the original continuous variables in the multi-source environmental feature matrix are standardized to obtain the input feature matrix of the corresponding candidate prediction model.
[0133] It's important to note that different machine learning algorithms have varying sensitivities to the numerical scale of input features. Models like Support Vector Regression and Multilayer Perceptron rely on distance metrics or gradient descent optimization during their internal computation. If the value ranges of different features differ significantly—for example, elevation ranges from 0 to 2000 meters while pH ranges from 4 to 9—features with larger numerical ranges will dominate during model training. This can prevent the model from fairly learning the contributions of each feature and may even affect the convergence speed and stability of the optimization algorithm. These models require all continuous input features to be within similar numerical scales, i.e., they belong to the same scale type. Conversely, tree-structured models such as Random Forest, Extreme Gradient Boosting, and Class Boosting rely on comparisons of feature values rather than distance calculations for their decision rules, making them naturally unaffected by differences in feature scales. Therefore, it's necessary to determine whether to perform standardization based on the specific type of candidate model, and standardization parameters such as mean and standard deviation must be calculated solely based on the training set data before being applied to the test set and the samples to be predicted.
[0134] Understandably, when the input feature type of a candidate prediction model, such as support vector regression or multilayer perceptron, is determined to be of the same scale type, the following standardization operation is performed: based solely on the multi-source environmental feature matrix of the training set, the mean and standard deviation of each original continuous variable, such as annual average precipitation, annual average temperature, elevation, slope, organic carbon, total iron, and alumina, are calculated one by one. Then, for each continuous variable in the training set, the standard deviation is calculated according to the formula... The transformation is performed, where x is the original value, μ is the mean of the variable in the training set, and σ is the standard deviation of the variable in the training set. The transformed x' is the standardized value, and its distribution will have the typical characteristics of a mean of 0 and a standard deviation of 1. For the category features after one-hot encoding and the derived features such as CIA and Fe / Al calculated, they are usually not standardized, and their original numerical range is retained or processed according to the same rules. Finally, the standardized continuous variables are recombined with the unstandardized category features and derived indices to form an input feature matrix suitable for models of the same scale type.
[0135] Among them, the input feature type is the model type of the candidate prediction model, which is determined according to the input feature requirements of the candidate prediction model; the same scale type is the model type that needs to be standardized for continuous variable features in the input model; and the input feature matrix is the input data input into the candidate prediction model for soil selenium prediction.
[0136] S2142, when the input feature type of the candidate prediction model is determined to be non-scale same type, the multi-source environmental feature matrix is used as the input feature matrix of the corresponding candidate prediction model.
[0137] It should be noted that tree-based machine learning models such as random forests, extreme gradient boosting, and class boosting work by comparing the magnitude of feature values to split the data and make decisions. Each split only focuses on comparing the value of a single feature at a certain threshold, without involving numerical calculations or distance measurements between different features. Therefore, even if the numerical ranges of different features differ significantly, it will not affect the decision-making process and fitting ability of this type of model. Thus, for candidate prediction models of the same type but different scales, there is no need to perform any scaling operations on the multi-source environmental feature matrix; the original data can be used directly as the model input.
[0138] S2143, During the training phase of the training set, candidate prediction models are trained based on preset model parameters.
[0139] It should be noted that during model training, in addition to the internal parameters learned by the model itself through training data, such as the node splitting rules of decision trees and the connection weights of neural networks, there is another type of parameter that needs to be pre-set before training begins and cannot be directly learned through the standard training process. These are called hyperparameters, such as the number of decision trees in a random forest, the learning rate and maximum depth of extreme gradient boosting, and the hidden layer structure and regularization coefficient of a multilayer perceptron. The selection of hyperparameters directly affects the model's fitting ability and generalization performance. However, if we directly train on the entire training set and use the test set to evaluate the effect of different hyperparameter combinations, it is equivalent to letting the test set indirectly participate in the hyperparameter selection process, leading to an overly optimistic model evaluation. Therefore, we can use five-fold cross-validation within the training set, that is, divide an independent validation subset for hyperparameter tuning. Five-fold cross-validation is performed by repeatedly rotating the validation set.
[0140] Understandably, the specific process of five-fold cross-validation involves randomly dividing the training set samples into five equal parts, called five folds. Each fold contains approximately one-fifth of the training set samples. This is followed by five rounds of training and validation. In the first round, the first fold is used as the validation set, and the remaining four folds are combined as a training subset. A pre-defined set of hyperparameters is used to train the model on this training subset, and the prediction error is calculated on the validation set. In the second round, the second fold is used as the validation set, and the remaining four folds are used as the training subset. The same hyperparameter combination is used for training and validation again, and so on, until all five rounds are completed. The average error result from the five rounds of validation is taken as the result of the current hyperparameter combination. The model performance metrics are then evaluated. Subsequently, the hyperparameter combinations are adjusted, and the five-fold cross-validation process described above is repeated. Multiple hyperparameter combinations are traversed using a preset search strategy, such as grid search or random search. Finally, the hyperparameters with the smallest average cross-validation error are selected as the optimal hyperparameter configuration for the candidate model. After determining the optimal hyperparameters, the final model is retrained using all training set data with these optimal hyperparameters for subsequent test set predictions. In this way, every sample in the training set has participated in model performance evaluation as a validation set, but each time it is trained, the sample is not used for parameter learning of the corresponding model, thus achieving effective isolation validation within the training set.
[0141] In the training phase, the multi-source environmental feature matrix of the training set is used as the input variable, and the corresponding logarithmic transformation value of the measured selenium content in the soil is used as the target variable. Feature preprocessing is completed according to the input scale requirements of different models, and the model is trained using preset parameters. At the same time, the predictive performance of each candidate model is evaluated through five-fold cross-validation.
[0142] It is worth mentioning that the preset hyperparameters for each candidate prediction model can be as follows: The random forest candidate prediction model has the following hyperparameters: 350 decision trees, a maximum number of features equal to the square root, and a minimum number of samples per leaf node of 2. The extreme gradient boosting candidate prediction model has the following preset parameters: 600 base learners, a learning rate of 0.05, a maximum depth of 6, a sample sampling ratio of 0.8, and a feature column sampling ratio of 0.8. The support vector regression candidate prediction model has the following hyperparameters: radial basis function kernel, C=12, ε=0.04, where C controls the regularization strength, and ε is the insensitive value. The tolerance bandwidth of the loss function is limited, with a maximum of 9000 training samples. The hyperparameters for the category boosting candidate prediction model are 700 iterations, a learning rate of 0.04, a tree depth of 6, and a loss function of RMSE. The hyperparameters for the multilayer perceptron candidate prediction model are a hidden layer structure of (96, 48), ReLU activation, an initial learning rate of 0.001, a maximum of 260 iterations, an early stopping strategy, and uniformly set parameters including a random seed of 42. Random five-fold cross-validation is performed within the training set, with a maximum of 12000 SVR cross-validation samples.
[0143] S2144, after the training phase is completed, the test phase of the test set is entered. The multi-source environmental feature matrix of the test set is retrieved and input into each candidate prediction model to predict soil selenium, and the predicted soil selenium value of each soil sample is obtained.
[0144] Understandably, after each candidate model completes training and five-fold cross-validation evaluation, it enters the testing phase. At this time, the processing method of the training set is the same as in the training phase. A pre-divided test set is retrieved, and the corresponding multi-source environmental feature matrix is obtained through multi-source environmental data matching, one-hot encoding of categorical variables, calculation of CIA and Fe / Al. The same standardization operation as in the training phase is then performed according to the type of the corresponding candidate prediction model to obtain the input feature matrix of the corresponding candidate prediction model for soil selenium prediction. It should be noted that the categorical variable encoding structure and continuous variable standardization parameters in the feature matrix of this test set are determined based on the training set if standardization is required. The test set only applies the same transformation rules and does not independently calculate its own encoding mapping or standardization parameters. The feature matrix of the test set is used as input and input into each candidate prediction model that has completed training. Each model independently performs forward computation and outputs the logarithmic predicted value of soil selenium for each test set sample. The logarithmic predicted value of soil selenium is then subjected to antilogarithmic transformation to obtain the predicted value of soil selenium for the sample, which is then used for subsequent model performance evaluation calculations.
[0145] Among them, the predicted value of selenium in the sample soil is the predicted value of the soil sample corresponding to the test set.
[0146] S215, calculate the evaluation data of each candidate prediction model based on the predicted value of soil selenium corresponding to the test set and the measured soil selenium data. The evaluation data includes the coefficient of determination, root mean square error, and mean absolute error.
[0147] It should be noted that since a single evaluation index can only reflect one aspect of model performance—for example, mean absolute error (MSE) can reflect the average deviation of predicted values but is not sensitive to outliers, root mean square error (RMSE) is more sensitive to large errors and thus reflects model stability, and the coefficient of determination (CMD) reflects the model's ability to explain the overall variability of measured values—relying on only one index may not be able to comprehensively evaluate the quality of the model. Therefore, this invention uses three complementary indices—the coefficient of determination (R²), the root mean square error (RMSE), and the mean absolute error (MAE)—to comprehensively evaluate the predictive ability of each candidate model from different dimensions, so as to facilitate the subsequent screening of candidate prediction models.
[0148] Understandably, the formulas for calculating the coefficient of determination R², root mean square error (RMSE), and mean absolute error (MAE) are as follows:
[0149]
[0150]
[0151]
[0152] in, This represents the measured soil selenium content of the i-th sample in the test set. This represents the predicted soil selenium content for the i-th sample in the test set. is the average value of the measured soil selenium, and n is the number of samples participating in the evaluation. The closer the values are to 1, the stronger the model's ability to explain the variation in observed values; the smaller the RMSE and MAE, the smaller the model's prediction error. It can be less than 0 when the model's prediction performance is poor.
[0153] The evaluation data consists of performance metrics for evaluating candidate prediction models, including the coefficient of determination, root mean square error, and mean absolute error.
[0154] S216, Select candidate prediction models based on the evaluation data to obtain a prediction model.
[0155] It is understandable that different evaluation metrics reflect the predictive performance of a model from different dimensions, but the three are not entirely consistent. There may be a situation where a certain model performs best on R² but is slightly inferior to another model on RMSE. Therefore, the evaluation metrics can be screened step by step according to their importance priority to ensure that the final selected model has better overall performance.
[0156] Among them, the coefficient of determination R² reflects the model's overall ability to explain the variation of measured values and is the most core evaluation index. When multiple models perform similarly on R², the root mean square error is further compared because RMSE is more sensitive to large deviations in prediction and can reflect the stability of the model. If RMSE still cannot distinguish between good and bad, the mean absolute error is used as the final evaluation criterion, and the model with the smallest error is selected as the prediction model.
[0157] In some embodiments, the specific implementation steps of step S216 include:
[0158] S2161, determine the determination coefficient closest to 1 as the candidate determination coefficient, and calculate the difference between the candidate determination coefficient and the other determination coefficients to obtain the determination coefficient difference.
[0159] It should be noted that in the model selection process, the coefficient of determination (R²) is the highest priority evaluation indicator. The closer its value is to 1, the stronger the model's explanatory power for the variation in soil selenium content. Therefore, the optimal value, i.e., the R² closest to 1, needs to be identified from all candidate models first. This value is then used as the candidate coefficient of determination for subsequent comparisons. Based on this, the difference between this candidate coefficient of determination and the coefficient of determination of each of the other models is calculated. The magnitude of these differences directly reflects the gap in explanatory power between the other models and the current optimal model. If the difference is large, it indicates that the optimal model has a significant advantage in the R² index. If the difference is small, it indicates that the explanatory power of multiple models is comparable, and other indicators can be used to further differentiate them.
[0160] Among them, the candidate coefficient of determination is the coefficient of determination closest to 1, and the difference in coefficients of determination is the difference between the candidate coefficient of determination and the other coefficients of determination.
[0161] S2162, when it is determined that there is no difference in the coefficient of determination less than the first preset threshold, the candidate prediction model corresponding to the candidate coefficient of determination is selected as the prediction model.
[0162] It is understandable that when the difference between candidate coefficients of determination is greater than or equal to the first threshold, it indicates that the candidate prediction model corresponding to the current candidate coefficient of determination has a significant advantage in explanatory power, and there is a substantial gap between the performance of other models and the optimal model. In this case, there is no need to introduce other evaluation indicators for comparison, and it can be directly determined that the model corresponding to the candidate coefficient of determination is the best prediction model overall.
[0163] The first threshold is a pre-set critical value used to determine whether the difference between the two models in the R² index has any real distinguishing significance.
[0164] S2163, when it is determined that there is a difference in the coefficient of determination less than the first preset threshold, the candidate prediction model corresponding to the corresponding coefficient of determination is taken as the first candidate prediction model.
[0165] Understandably, when the difference between the coefficient of determination of one or more candidate models and the candidate coefficient of determination is less than the first preset threshold, it means that these models are at the same level as the candidate prediction models corresponding to the candidate coefficient of determination in terms of R² index. The coefficient of determination alone cannot reliably determine which is better. At this time, these models with similar R² performance can be screened out and retained for the next round of comparison, while models with significantly worse R² are directly eliminated.
[0166] The first candidate prediction model is a relevant candidate prediction model whose difference in the coefficient of determination is less than the first preset threshold, including the candidate prediction model corresponding to the candidate coefficient of determination.
[0167] S2164, the smallest root mean square error is taken as the candidate root mean square error, and the difference between the candidate root mean square error and the other root mean square errors is calculated based on the first candidate prediction model to obtain the root mean square error difference.
[0168] Understandably, when multiple models are indistinguishable due to similar performance on the coefficient of determination R², a second evaluation metric, root mean square error (RMSE), can be introduced for screening. Among models with comparable R², a smaller RMSE usually means that the model's predictions are more robust and have less outlier bias. Therefore, the model with the smallest RMSE value is first identified from the first candidate prediction models and used as the candidate RMSE benchmark. Then, the difference between the benchmark and the RMSE of the other first candidate models is calculated one by one to determine whether the optimal model has a significant advantage in the RMSE metric.
[0169] Among them, the candidate root mean square error is the smallest root mean square error in the first candidate prediction model, and the root mean square error difference is the difference between the candidate root mean square error and the other root mean square errors in the first candidate prediction model.
[0170] S2165, when it is determined that there is no root mean square error difference less than the second preset threshold, the first candidate prediction model corresponding to the candidate root mean square error is selected as the prediction model.
[0171] Understandably, when the difference between the RMSE of the candidate optimal model and the RMSE of the other first candidate models is greater than or equal to the threshold, it indicates that the optimal model has a clear and substantial advantage in prediction stability, and the other models have a distinguishable gap with it. In this case, the model corresponding to the candidate root mean square error can be directly determined as the final prediction model, without the need to introduce a third indicator, MAE, for comparison.
[0172] The second preset threshold is a critical value set by humans to determine whether the two models have a large difference in the RMSE index.
[0173] S2166, when it is determined that there is a root mean square error difference less than the second preset threshold, the corresponding first candidate prediction model is used as the second candidate prediction model.
[0174] Understandably, when the difference between the RMSE of one or more first candidate models and the candidate optimal RMSE is less than the second preset threshold, it means that these models perform very similarly in both R² and RMSE. The first two levels of indicators still cannot reliably distinguish between the superior and inferior models. In this case, it is necessary to further screen these first candidate models that perform similarly in both R² and RMSE as second candidate prediction models and retain them for the third round of comparison, while models with significantly worse RMSE are eliminated.
[0175] The second candidate prediction model is a candidate prediction model selected from the first candidate prediction model, including the first candidate prediction model corresponding to the candidate root mean square error.
[0176] S2167, Select the second candidate prediction model with the smallest mean absolute error as the prediction model.
[0177] Understandably, if multiple models still have very similar performance metrics after the first two screenings, the second candidate prediction model with the smallest mean absolute error can be selected as the prediction model.
[0178] S22, Based on the prediction model, predict soil selenium using the multi-source predicted environmental feature matrix to obtain the predicted logarithmic value of soil selenium.
[0179] Understandably, once a prediction model with the best performance in predicting soil selenium is selected, the multi-source prediction environmental feature matrix of the sample to be predicted can be input into the finally selected prediction model to output the corresponding logarithmic predicted value of soil selenium.
[0180] S3, determine the impact analysis results of key environmental characteristics in the predicted sample dataset based on the predicted soil selenium values.
[0181] It should be noted that while the prediction model can obtain the corresponding predicted values, it is difficult to directly explain how each input feature affects the prediction results. Since the dominant factors may differ in different regions, the corresponding agricultural management and land use strategies should also be different. Therefore, based on the model prediction, it is necessary to further analyze the contribution, direction, and influence of each environmental feature on the prediction results.
[0182] Understandably, this invention can use the SHAP method to interpret and analyze the selected prediction models. SHAP is a model interpretation method based on Shapley values in cooperative game theory. It can calculate a contribution value for each input feature of each sample, quantitatively reflecting the degree to which the feature drives the prediction result to deviate from the baseline value in the prediction of that sample. After calculating the SHAP values of all features for all samples, the average absolute contribution value of each feature on all samples is further calculated to measure the overall influence of each feature on the model prediction results. The features are then ranked according to their contribution intensity to identify key environmental features. At the same time, the positive or negative sign of the SHAP value is used to determine the direction of each feature's effect on selenium content prediction, i.e., whether the change in the feature value tends to increase or decrease the predicted value. Finally, the feature importance ranking, relative contribution ratio, and direction of effect are integrated into a complete impact analysis result for the management of soil selenium resources.
[0183] Among them, the SHAP method is a model interpretation framework based on game theory Shapley values. It achieves quantitative interpretation of the machine learning model output by calculating the marginal contribution of each feature to the prediction result. The contribution value refers to the specific influence of a certain environmental feature on the prediction result of a single sample. A positive number indicates that the feature pushes the prediction value higher than the benchmark, and a negative number indicates that it pushes the prediction value lower than the benchmark. The average absolute contribution value refers to the average absolute contribution value of a certain feature on all interpreted samples, reflecting the overall influence strength of the feature on the model prediction result. The relative contribution ratio refers to the percentage of the average absolute contribution value of a certain feature to the sum of the average absolute contribution values of all features, which is used to compare the relative importance of each feature. The influence analysis results are the interpretation analysis results of each environmental feature data on the prediction of soil selenium.
[0184] In some embodiments, the specific implementation steps of step S3 include:
[0185] S31, calculate the contribution of each key environmental feature in the prediction sample dataset to the predicted value of soil selenium.
[0186] Understandably, the SHAP interpreter can be called to interpret the antilogarithmic transformation of the soil selenium prediction value output by the selected prediction model. Specifically, for each multi-source environmental feature matrix of the sample to be predicted, the SHAP value of the feature for the prediction result of the current sample is calculated feature by feature.
[0187] Taking the i-th sample and the j-th feature as an example, its SHAP value The calculation process comprehensively considers the marginal contribution of the feature in all possible combinations of feature subsets, and performs a weighted average according to the Shapley value allocation principle to ensure that the sum of the contribution values of all features plus the baseline value equals the predicted output of the model. After the calculation is completed, each sample corresponds to a contribution value vector of length m, where m is the total number of features, and positive and negative values coexist.
[0188] For example, if the baseline value of a sample to be predicted is 0.25, after SHAP decomposition, the contribution of organic carbon is +0.10, the contribution of CIA is +0.05, the contribution of annual precipitation is -0.03, and the contribution of geological background is +0.01. The sum of the contribution values of 0.13 plus the baseline value of 0.25 equals the model prediction value of 0.38. This result clearly shows which features push up the predicted value of the sample, which features pull it down, and their respective influence.
[0189] S32, calculate the average absolute contribution value of each of the key environmental features based on the contribution value, and calculate the relative contribution ratio of the corresponding key environmental features based on the average absolute contribution value.
[0190] It should be noted that the feature values differ across samples, and the SHAP contribution value of the same feature on different samples may be positive or negative, large or small. The contribution value of a single sample cannot represent the overall importance of the feature in the entire study area. In order to evaluate the overall impact of each feature on the model prediction from a global perspective, it is necessary to summarize and statistically analyze the contribution values of all explanatory samples. Directly calculating the arithmetic mean of the contribution values will cause positive and negative values to cancel each other out, which cannot truly reflect the overall influence strength of the feature. Therefore, the average absolute contribution value is used as an indicator to measure the overall importance of the feature. That is, by taking the absolute value of the contribution value and then averaging it, the effect of positive and negative cancellation can be eliminated, reflecting the average strength of the feature's influence on the prediction results in the study area regardless of the direction. On this basis, the average absolute contribution value of each feature is normalized into a percentage form, which is the relative contribution ratio, facilitating intuitive comparison between features.
[0191] Understandably, the formulas for calculating the average absolute contribution value and the relative contribution ratio are as follows:
[0192]
[0193] in, For the importance of the j-th environmental feature, Let be the contribution of the j-th environmental feature to the prediction result of the i-th sample, and n be the number of samples involved in the explanation. The larger the average absolute contribution value, the stronger the overall influence of the feature on the model prediction result.
[0194]
[0195] in, Let m be the relative contribution ratio of the j-th environmental feature, m be the number of environmental features, and k be the subscript for the summation of environmental features.
[0196] S33, based on the average absolute contribution value and the relative contribution ratio, the key environmental features are sorted in descending order to obtain a key environmental feature sequence.
[0197] It should be noted that in practical applications such as the evaluation of selenium-rich land resources and the remediation of selenium-deficient soil areas, managers and decision-makers often need to quickly identify which environmental factors are the core controlling factors affecting the selenium content of regional soils in order to carry out targeted investigations, monitoring, or regulation. Therefore, it is necessary to sort all features according to their contribution intensity, placing the most influential features at the top to form a clear sequence of key environmental features. After sorting, users can directly obtain the most important influencing factors from the top of the sequence, while features at the tail of the sequence can be ignored as appropriate, thereby improving analysis efficiency.
[0198] It is understandable that the sorting can be performed based on the average absolute contribution value or directly based on the relative contribution ratio. The sorting results are completely consistent because the relative contribution ratio is a monotonic transformation of the average absolute contribution value, multiplied by the same constant.
[0199] Among them, the key environmental feature sequence is the feature sequence after the key environmental features are sorted in descending order.
[0200] S34. When the average value of the contribution of the key environmental feature is positive, the result is that the corresponding key environmental feature has a positive effect on the predicted value of soil selenium. When the average value of the contribution of the key environmental feature is negative, the result is that the corresponding key environmental feature has a negative effect on the predicted value of soil selenium.
[0201] It should be noted that while the key environmental feature sequence obtained by ranking feature importance can tell users which features have the greatest impact, it cannot tell them how these features affect the prediction results. That is, does a higher feature value mean higher selenium content, or a higher feature value mean lower selenium content? In soil environmental management and agricultural planning, information on both positive and negative effects is equally important. If a factor has a positive promoting effect on selenium content, such as organic carbon accumulation contributing to selenium fixation, then soil selenium availability can be improved through management measures such as increasing the application of organic fertilizers. If a factor has a negative effect, such as strong weathering and leaching leading to selenium loss, then it is necessary to assess whether control measures are needed. Therefore, it is necessary to determine the direction of each feature's effect on the prediction results based on the positive or negative sign of the SHAP contribution value in order to provide directional guidance for subsequent decision-making.
[0202] For example, the average SHAP contribution value of organic carbon is +0.025, and the vast majority of samples have a positive contribution value for organic carbon. This indicates that organic carbon has a positive effect on soil selenium prediction, meaning that the higher the organic carbon content, the higher the selenium content predicted by the model. This is consistent with the mechanism of organic matter complexing and fixing selenium. Conversely, the average SHAP contribution value of annual precipitation is -0.018, indicating a negative effect. This means that the greater the precipitation and the stronger the leaching, the lower the soil selenium content tends to be. For each key environmental feature, its positive or negative effect direction is determined according to this method, and recorded together with the feature name and contribution ratio to form complete feature influence direction information.
[0203] Among them, the positive effect result is that the direction of the predictive effect of environmental characteristics on soil selenium is positive, and the negative effect result is that the direction of the predictive effect of environmental characteristics on soil selenium is negative.
[0204] S35, the impact analysis results are obtained based on the relative contribution ratio, the positive effect results, and the negative effect results.
[0205] It should be noted that, through the analysis steps described above, each environmental feature has obtained information in multiple dimensions, namely, the relative contribution ratio reflecting the intensity of the impact, the ranking order reflecting the relative importance, and the direction reflecting the positive promoting or negative inhibiting effect. These three dimensions of information characterize the influence of each environmental feature on soil selenium content from different perspectives. At the same time, the SHAP method can further reveal the nonlinear response relationship between feature values and contribution values, that is, the degree and direction of the influence of features on the prediction results may change in different value ranges. For example, organic carbon has a strong promoting effect on selenium in the low content range, but the effect tends to level off or even turn negative after reaching a certain threshold. This in-depth information can also be incorporated into the analysis results and used as the final impact analysis results for output to the management end for visualization.
[0206] S4. Based on the predicted soil selenium value and the impact analysis results, the output data is sent to the management terminal.
[0207] It should be noted that the output data is the result output to the management terminal, which may include the predicted value of soil selenium and the results of impact analysis. The management terminal is the terminal of the management personnel who need to obtain information on soil selenium in soil samples.
[0208] See Figure 2 This is a schematic diagram of a machine learning-based regional soil selenium content prediction system provided in an embodiment of the present invention. The machine learning-based regional soil selenium content prediction system includes:
[0209] The calculation module is used to calculate the soil formation process characteristics based on the predicted sample dataset of the sample to be predicted, and obtain the multi-source predicted environmental feature matrix.
[0210] The prediction module is used to predict soil selenium based on the multi-source predicted environmental feature matrix using a prediction model, obtain the logarithmic predicted value of soil selenium, and perform an anti-logarithmic transformation on the logarithmic predicted value of soil selenium to obtain the predicted value of soil selenium.
[0211] The analysis module is used to determine the impact analysis results of key environmental features in the predicted sample dataset based on the predicted soil selenium values.
[0212] The sending module is used to send the output data obtained from the predicted soil selenium value and the impact analysis results to the management terminal.
[0213] See Figure 3 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. The electronic device 30 includes: a processor 31, a memory 32, and a computer program; wherein...
[0214] The memory 32 is used to store the computer program, and the memory may also be flash memory. The computer program is, for example, an application program or functional module that implements the above method.
[0215] The processor 31 is configured to execute the computer program stored in the memory to implement the various steps performed by the device in the above method. For details, please refer to the relevant descriptions in the preceding method embodiments.
[0216] Alternatively, the memory 32 can be either standalone or integrated with the processor 41.
[0217] When the memory 32 is a device independent of the processor 31, the device may further include:
[0218] Bus 33 is used to connect the memory 32 and the processor 31.
[0219] The present invention also provides a readable storage medium storing a computer program, which, when executed by a processor, is used to implement the methods provided in the various embodiments described above.
[0220] The readable storage medium can be a computer storage medium or a communication medium. A communication medium includes any medium that facilitates the transfer of computer programs from one location to another. A computer storage medium can be any available medium accessible to a general-purpose or special-purpose computer. For example, a readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application-Specific Integrated Circuit (ASIC). Alternatively, the ASIC can be located in a user equipment. Of course, the processor and the readable storage medium can also exist as discrete components in a communication device. The readable storage medium can be a read-only memory (ROM), random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0221] The present invention also provides a program product including executable instructions stored in a readable storage medium. At least one processor of the device can read the executable instructions from the readable storage medium, and the at least one processor executes the executable instructions to cause the device to implement the methods provided in the various embodiments described above.
[0222] In the embodiments of the above-described device, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly manifested as execution by a hardware processor, or execution by a combination of hardware and software modules within the processor.
[0223] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for predicting regional soil selenium content based on machine learning, characterized in that, include: Based on the predicted sample dataset of the sample to be predicted, the soil formation process characteristics are calculated to obtain the multi-source predicted environmental feature matrix; Based on the prediction model, soil selenium is predicted using the multi-source predicted environmental feature matrix to obtain the logarithmic predicted value of soil selenium. The logarithmic predicted value of soil selenium is then transformed using an antilogarithmic method to obtain the predicted value of soil selenium. Based on the predicted soil selenium values, the impact analysis results of key environmental characteristics in the predicted sample dataset were determined. The output data, obtained based on the predicted soil selenium value and the impact analysis results, is sent to the management terminal.
2. The method according to claim 1, characterized in that, The step of predicting soil selenium based on the prediction model using the multi-source predicted environmental feature matrix to obtain the predicted logarithmic value of soil selenium includes: The candidate prediction models are trained and screened to obtain the prediction model; Based on the prediction model, soil selenium is predicted using the multi-source predicted environmental feature matrix to obtain the logarithmic predicted value of soil selenium.
3. The method according to claim 2, characterized in that, The process of training and screening candidate prediction models to obtain prediction models includes: The sampling locations of soil samples, measured soil selenium data, and environmental data from multiple sources are obtained and matched to generate a basic sample dataset. Based on the sample sampling locations, the basic sample dataset is spatially partitioned to obtain a training set and a test set. Based on the training set, soil formation process features are calculated to obtain a multi-source environmental feature matrix; Based on the training set, test set and multi-source environmental feature matrix, the candidate prediction model is trained and predicted in stages, and the predicted value of soil selenium for each soil sample is output. Evaluation data for each candidate prediction model is calculated based on the predicted values of soil selenium in the test set and the measured soil selenium data. The evaluation data includes the coefficient of determination, root mean square error, and mean absolute error. Based on the evaluation data, candidate prediction models are selected to obtain the prediction model.
4. The method according to claim 3, characterized in that, The process involves matching and correlating the soil sample collection locations, measured soil selenium data, and multi-source environmental data to generate a basic sample dataset, including: Based on a preset order, the sample sampling locations, multi-source sample environmental data, and soil selenium measurement data corresponding to each soil sample are matched and associated sequentially to obtain the sample point data corresponding to each soil sample. The basic sample dataset is obtained by statistically analyzing the sample point data corresponding to each soil sample.
5. The method according to claim 4, characterized in that, The step of spatially partitioning the basic sample dataset based on the sample sampling locations to obtain a training set and a test set includes: Based on the sampling location of the soil sample, the sample analysis area is obtained. The sample analysis area is then divided into regular grids according to a preset size to obtain multiple sample division units. The sample point data of the same sample division unit are labeled to obtain sample unit labels. The sample point data with the same sample unit labels are combined to obtain the sample point unit dataset. Based on a preset sample splitting ratio, the sample point unit dataset is randomly selected for sample splitting to obtain training set and test set respectively.
6. The method according to claim 4, characterized in that, The step of calculating soil formation process features based on the training set to obtain a multi-source environmental feature matrix includes: One-hot encoding is performed on the categorical variables in the sample point data of the training set to obtain the categorical feature data of each categorical variable; The chemical alteration index and iron-aluminum ratio are calculated based on the elemental geochemical data in the multi-source sample environmental data. The elemental geochemical data includes the oxides of major elements and the contents of related elements. Based on a preset index splicing order, the category feature data, original continuous variables, chemical alteration index, and iron-aluminum ratio are combined and spliced to obtain a multi-source environmental feature matrix.
7. The method according to claim 3, characterized in that, The step of training and predicting candidate prediction models in stages based on the training set, test set, and multi-source environmental feature matrix, and outputting the predicted soil selenium value for each soil sample, includes: When the input feature type of the candidate prediction model is determined to be of the same scale type, the original continuous variables in the multi-source environmental feature matrix are standardized to obtain the input feature matrix of the corresponding candidate prediction model. When the input feature type of the candidate prediction model is determined to be of the same non-scale type, the multi-source environmental feature matrix is used as the input feature matrix of the corresponding candidate prediction model. During the training phase of the training set, candidate prediction models are trained based on preset model parameters; After the training phase is completed, the test phase begins. The multi-source environmental feature matrix of the test set is retrieved and input into each candidate prediction model to predict soil selenium. Each candidate prediction model outputs the predicted soil selenium value of the soil sample.
8. The method according to claim 3, characterized in that, The step of selecting candidate prediction models based on the evaluation data to obtain a prediction model includes: The coefficient of determination closest to 1 is determined as the candidate coefficient of determination. The difference between the candidate coefficient of determination and the other coefficients of determination is calculated to obtain the coefficient of determination difference. When it is determined that there is no difference in the coefficient of determination less than the first preset threshold, the candidate prediction model corresponding to the candidate coefficient of determination is selected as the prediction model. When it is determined that there is a difference in the coefficient of determination that is less than the first preset threshold, the candidate prediction model corresponding to the corresponding coefficient of determination is taken as the first candidate prediction model. The smallest root mean square error is taken as the candidate root mean square error. The difference between the candidate root mean square error and the other root mean square errors is calculated based on the first candidate prediction model to obtain the root mean square error difference. When it is determined that there is no root mean square error difference less than the second preset threshold, the first candidate prediction model corresponding to the candidate root mean square error is selected as the prediction model. When it is determined that there is a root mean square error difference less than the second preset threshold, the corresponding first candidate prediction model is used as the second candidate prediction model; The second candidate prediction model with the smallest mean absolute error is selected as the prediction model.
9. The method according to claim 1, characterized in that, The step of determining the impact analysis results of key environmental characteristics in the predicted sample dataset based on the predicted soil selenium values includes: Calculate the contribution of each key environmental feature in the prediction sample dataset to the predicted value of soil selenium; Calculate the average absolute contribution value of each of the key environmental features based on the contribution value, and calculate the relative contribution ratio of the corresponding key environmental features based on the average absolute contribution value. The key environmental features are sorted in descending order based on the average absolute contribution value and the relative contribution ratio to obtain a key environmental feature sequence. When the average contribution value of the key environmental feature is positive, it indicates that the corresponding key environmental feature has a positive effect on the predicted value of soil selenium; when the average contribution value of the key environmental feature is negative, it indicates that the corresponding key environmental feature has a negative effect on the predicted value of soil selenium. The impact analysis results are obtained based on the relative contribution ratio, the positive effect results, and the negative effect results.
10. A regional soil selenium content prediction system based on machine learning, characterized in that, include: The calculation module is used to calculate the soil formation process characteristics based on the predicted sample dataset of the sample to be predicted, and obtain the multi-source predicted environmental feature matrix. The prediction module is used to predict soil selenium based on the multi-source predicted environmental feature matrix using a prediction model, obtain the logarithmic predicted value of soil selenium, and perform an anti-logarithmic transformation on the logarithmic predicted value of soil selenium to obtain the predicted value of soil selenium. The analysis module is used to determine the impact analysis results of key environmental characteristics in the predicted sample dataset based on the predicted soil selenium values. The sending module is used to send the output data obtained from the predicted soil selenium value and the impact analysis results to the management terminal.