A rice nitrogen prediction method and system based on an interpretable ensemble machine learning
By using an interpretable ensemble machine learning approach, spectral features are obtained from UAV hyperspectral images. The optimal feature subset is selected and a linear ridge regression model is used for nitrogen prediction. This solves the problems of time-consuming and labor-intensive methods and weak model generalization ability in traditional methods, and achieves high-precision, interpretable nitrogen diagnosis and optimized fertilization decisions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INST OF AGRI RESOURCES & ENVIRONMENT GUANGDONG ACADEMY OF AGRI SCI
- Filing Date
- 2026-05-09
- Publication Date
- 2026-07-31
AI Technical Summary
Traditional nitrogen diagnosis methods are time-consuming and labor-intensive, making it difficult to meet the needs of modern precision agriculture for large-scale, high-frequency, and low-cost nitrogen diagnosis. Furthermore, existing machine learning models lack interpretability and have weak generalization ability, making them difficult to apply across regions and years.
An interpretable ensemble machine learning approach is adopted to acquire spectral features from UAV hyperspectral images. The optimal feature subset is selected by combining recursive feature elimination cross-validation and weighted SHAP value sorting. A linear ridge regression model is used for nitrogen prediction. By integrating multiple types of spectral features and interpretability analysis, the risk of overfitting is reduced and the generalization robustness is improved.
It achieves high-precision and robust inversion of nitrogen content in rice, ensuring the interpretability and reliability of the model, optimizing fertilization decisions, improving nitrogen fertilizer use efficiency, and reducing agricultural non-point source pollution.
Smart Images

Figure CN122491027A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine learning technology, and in particular to a method and system for predicting nitrogen levels in rice based on interpretable ensemble machine learning. Background Technology
[0002] In research on efficient rice cultivation and management, real-time and non-destructive monitoring of plant nitrogen nutrition status is a key link in optimizing fertilization decisions, improving nitrogen fertilizer use efficiency, and reducing agricultural non-point source pollution. Traditional nitrogen diagnosis methods rely on destructive field sampling and laboratory chemical analysis. Although these methods can accurately measure plant nitrogen content, they are time-consuming, labor-intensive, and costly. Furthermore, the representativeness of the data is limited by the sampling density, making it difficult to characterize the spatial heterogeneity of nitrogen in different fields. Consequently, they cannot meet the urgent needs of modern precision agriculture for large-scale, high-frequency, and low-cost nitrogen diagnosis.
[0003] In recent years, the rapid development of UAV hyperspectral remote sensing technology has provided a new technical approach for the rapid inversion of crop nitrogen nutrition. Hyperspectral data contains rich spectral information and can sensitively capture physiological and morphological changes such as chlorophyll, leaf area index, and canopy structure caused by nitrogen stress. However, spectral-based nitrogen prediction in rice still faces a series of scientific challenges: the spectral response of rice canopy is comprehensively affected by multiple factors such as variety, growth stage, soil background, water layer state, and light conditions; the spectrum-nitrogen relationship exhibits significant nonlinearity and spatiotemporal variability; traditional empirical statistical models have strong mechanism interpretation but weak generalization ability, and model coefficients usually need to be recalibrated for different growth stages and varieties. In cross-regional and cross-year applications, model accuracy decreases significantly. Single inversion models (such as empirical statistical models and radiative transfer models) have limited generalization ability under different environmental conditions, high sample collection costs, and limited sample numbers; single models are prone to overfitting or local optima. In addition, most machine learning models are black-box structures, and their prediction results lack interpretability, severely limiting the extended application of the models.
[0004] In summary, developing a method for predicting nitrogen levels in rice that integrates multiple spectral features, ensemble learning strategies, and an interpretable analysis framework is of significant scientific importance and practical value for achieving accurate diagnosis of nitrogen nutrition and optimizing fertilization decisions. Summary of the Invention
[0005] To overcome the problems existing in related technologies, the purpose of this invention is to provide a method and system for predicting nitrogen in rice based on interpretable ensemble machine learning. The method integrates multiple spectral features, ensemble learning strategies and interpretable analysis frameworks, which has important scientific significance and application value for achieving accurate diagnosis of nitrogen nutrition and optimized fertilization decisions.
[0006] A method for predicting nitrogen levels in rice based on interpretable ensemble machine learning includes: Acquire hyperspectral images of the UAV, extract spectral features from the UAV hyperspectral images, and form a high-dimensional feature pool from the spectral features; The optimal feature subset is selected from the high-dimensional feature pool by using recursive feature elimination cross-validation combined with weighted SHAP value sorting. The optimal feature subset is divided into a training set and a test set. The training set is divided into five folds. Cross-validation training is performed on each base model to obtain a preliminary prediction feature matrix. The preliminary predicted feature matrix is used to train a linear ridge regression model, which consists of three base models. The test set is input into the linear ridge regression model, which performs a weighted integration of the predictions output by each base model to obtain the predicted value of nitrogen in rice.
[0007] In a preferred embodiment of the present invention, the linear ridge regression meta-model includes a linear basis model, a nonlinear basis model, and a deep learning basis model. The linear basis model is LASSO, the nonlinear basis model is a random forest, and the deep learning basis model is a backpropagation neural network. The spectral features include raw reflectance, first derivative spectrum, continuum-removed spectrum, and vegetation index.
[0008] In a preferred embodiment of the present invention, before the recursive feature elimination cross-validation combined with weighted SHAP value sorting, the method further includes: The weighted SAP value is calculated using the following weighted summation model: ; in, The weighted SHAP value, The SHAP value of the first interpreter. The SHAP value for the second interpreter. The SHAP value for the third interpreter; The first free parameter that can be learned. These are learnable second free parameters. is a learnable third free parameter; exp is an exponential function with the natural constant as the base.
[0009] In a preferred embodiment of the present invention, the step of using recursive feature elimination cross-validation combined with weighted SHAP value sorting to select the optimal feature subset from the high-dimensional feature pool includes: The data in the high-dimensional feature pool is divided into M feature subsets; Recursive feature elimination is performed on each of the feature subsets to obtain M recursive feature-eliminated subsets; wherein, in each iteration of the recursive feature elimination, the feature stability index of each spectral feature is calculated, and spectral features whose feature stability index is lower than the feature stability index threshold are removed.
[0010] After eliminating the M recursive features, the subsets are sequentially input into the weighted summation model to obtain the M weighted SHAP values. Select the maximum weighted SHAP value from the M weighted SHAP values, and take the feature subset corresponding to the maximum weighted SHAP value as the optimal feature subset.
[0011] In a preferred embodiment of the present invention, the step of dividing the training set into five folds and performing cross-validation training on each base model to obtain a preliminary prediction feature matrix includes: The training set is randomly divided into 5 training subsets; all training subsets are mutually exclusive. Cross-validation training was performed on each base model using five training subsets; Collect the predicted values for each fold of the validation set; All the predicted values are stacked to form a preliminary prediction feature matrix, the size of which is N×3, where N is the number of samples; The complementarity of the preliminary predicted feature matrix is evaluated based on Shannon entropy to obtain a complementarity index. If the complementarity index is greater than a preset threshold, the complete preliminary predicted feature matrix is retained; otherwise, the base model is pruned and the preliminary predicted feature matrix is reconstructed. The formula for calculating the complementarity index is as follows: ; in, The complementarity index, For the sample size, Let be the empirical entropy of the num-th sample on the triplet composed of the predicted values of the three base models. The maximum possible entropy of the triple is given by . As the normalization factor; when When the value approaches 1, it indicates that the information provided by the three base models is highly complementary.
[0012] In a preferred embodiment of the present invention, training the linear ridge regression model using the preliminary predicted feature matrix includes: Using the preliminary predicted feature matrix as input and the actual nitrogen content of rice as a reference value, a linear ridge regression model is trained; the formula for the linear ridge regression model is: ; Where B is the set of base models. The output prediction value of base model i, To minimize the weighted coefficients of the base model i obtained by minimizing the loss function of the regressor meta-model with L2 regularization, y final The predicted nitrogen content of rice is the output of the linear ridge regression model. The regularization intensity hyperparameter is denoted by ; the regression meta-model loss function simultaneously includes a prediction error term and an L2 norm penalty term for the weighted coefficients.
[0013] In a preferred embodiment of the present invention, after obtaining the predicted nitrogen value of rice, the method further includes: Calculate the mean and variance of the predicted values for the samples for each base model; The coefficient of variation is predicted using the following formula based on the mean and variance of the predicted values: ; Where U(num) is the coefficient of variation for sample num, and avg is the average value. For variance calculation, The set of predicted values for sample num by all base models, where . represents a multiplication operation; the coefficient of variation is used to determine rice regions with high confidence and rice regions with high uncertainty.
[0014] In a preferred embodiment of the present invention, after obtaining the predicted nitrogen value of rice, the method further includes: The key features that contribute most to the nitrogen content retrieval in rice were identified, and a SHAP dependency plot was drawn by combining the key features and the weighted SHAP values. The SHAP dependency plot was used to characterize the nonlinear response relationship between the key bands and the nitrogen content in rice. For each field or each pixel unit, a SHAP waterfall plot and a SHAP interaction value matrix are generated for the predicted nitrogen content of rice. The SHAP waterfall plot is used to show the positive or negative driving effect of spectral reflectance of different bands on the predicted nitrogen content of rice. The SHAP interaction value matrix is used to analyze the influence of the coupling effect between the red edge and near-infrared bands, and between the near-infrared band and the short-wave infrared band on the inversion of nitrogen content of rice.
[0015] In a preferred embodiment of the present invention, the calculation of the characteristic stability index of each spectral feature includes: The characteristic stability index of the j-th spectral feature is calculated using the following formula: ; in, For the first The characteristic stability index of each spectral feature, where K is the total number of folds in the cross-validation. For the first The spectral feature at the th Ranking of the importance of compromise; when When the value is above the stability index threshold, the j-th spectral feature is retained for the calculation of the weighted SAP value.
[0016] This invention also provides a rice nitrogen prediction system based on interpretable ensemble machine learning, comprising: A high-dimensional feature pooling module is used to acquire UAV hyperspectral images, extract spectral features from the UAV hyperspectral images, and combine the spectral features into a high-dimensional feature pool. The optimal feature subset selection module is used to select the optimal feature subset from the high-dimensional feature pool by using recursive feature elimination, cross-validation, and weighted SHAP value sorting. The cross-validation training module is used to divide the optimal feature subset into a training set and a test set, divide the training set into five folds, perform cross-validation training on each base model, and obtain a preliminary prediction feature matrix. The linear ridge regression meta-model training module is used to train the linear ridge regression meta-model using the preliminary prediction feature matrix. The linear ridge regression meta-model consists of three base models. The nitrogen nutrient content calculation module for rice is used to input the test set into the linear ridge regression model. The linear ridge regression model performs weighted integration of the predictions output by each base model to obtain the predicted value of nitrogen in rice.
[0017] The beneficial effects of this invention are as follows: The present invention provides a method for predicting nitrogen levels in rice based on interpretable ensemble machine learning. This method involves acquiring hyperspectral images from a UAV, extracting spectral features from these images, and constructing a high-dimensional feature pool. The high-dimensional feature pool includes raw reflectance, first-derivative spectra, continuum-removed spectra, and vegetation indices. Recursive feature elimination cross-validation combined with weighted SHAP value sorting is used to remove redundant features and noise, selecting the optimal feature subset from the high-dimensional feature pool. The built-in cross-validation mechanism of recursive feature elimination cross-validation makes feature selection decisions based on the average performance of multiple rounds of validation, reducing the risk of overfitting. Combined with weighted SHAP value sorting, the optimal feature subset is automatically determined, exhibiting high sensitivity to nitrogen levels. The optimal feature subset is divided into training and testing sets. The training set is further divided into five folds, and cross-validation training is performed on each base model to obtain a preliminary prediction feature matrix. Using the five-fold cross-validation prediction results of the base models as secondary features, a linear ridge regression meta-model is trained, achieving adaptive weighted ensemble of the advantages of each base model. The linear ridge regression meta-model consists of three base models. The LASSO base model uses L1 regularization to adaptively select and sparsely represent high-dimensional spectral features, retaining key bands strongly correlated with rice nitrogen content. Random forest automatically learns chlorophyll absorption and the complex interactions and nonlinear mappings between nitrogen-sensitive bands through a Bagging strategy integrating multiple decision trees and a stochastic feature subspace method. A backpropagation neural network constructs a shallow network structure with a single hidden layer, fitting the complex continuous relationship between nitrogen and spectral reflectance using a nonlinear activation function to capture local nonlinear features. The test set is input into the linear ridge regression meta-model, which weights and integrates the predictions from each base model to obtain the predicted nitrogen content in rice. This heterogeneous integration strategy significantly reduces the overfitting risk caused by structural biases in a single model and improves the model's generalization robustness across growth stages and varieties. Meanwhile, by combining interpretability tools such as SHAP to provide global and local interpretations of the decision-making process of the integrated model, high-precision and robust inversion of rice nitrogen content is achieved, ensuring the interpretability and reliability of rice nitrogen prediction. Attached Figure Description
[0018] Figure 1 This is a flowchart of the rice nitrogen prediction method based on interpretable ensemble machine learning of the present invention; Figure 2 The training set determination coefficient R0 is the coefficient of determination of a rice nitrogen prediction method based on interpretable ensemble machine learning. 2 picture; Figure 3 The test set determination coefficient R0 of a rice nitrogen prediction method based on interpretable ensemble machine learning is shown. 2 picture; Figure 4This is a scatter plot of the test set residuals of the rice nitrogen prediction method based on interpretable ensemble machine learning of the present invention. Figure 5 This is a test set residual distribution diagram of the rice nitrogen prediction method based on interpretable ensemble machine learning of the present invention. Figure 6 The training set determination coefficient R0 is the coefficient of determination of the multi-model voting ensemble learning method. 2 picture; Figure 7 The test set determination coefficient R0 of the multi-model voting ensemble learning method 2 picture; Figure 8 It is a scatter plot of the test set residuals for a multi-model voting ensemble learning method; Figure 9 This is a residual distribution diagram of the test set for the multi-model voting ensemble learning method; Figure 10 This is a SHAP waterfall plot of a rice nitrogen prediction method based on interpretable ensemble machine learning; Figure 11 It is a SHAP dependency graph based on an interpretable ensemble machine learning method for predicting nitrogen in rice; Figure 12 This is a radial bar chart showing the feature importance of a rice nitrogen prediction method based on interpretable ensemble machine learning; Figure 13 This is a hyperspectral remote sensing aerial photograph taken by a drone over the field. Figure 1 ; Figure 14 This is a hyperspectral remote sensing aerial photograph taken by a drone over the field. Figure 2 ; Figure 15 This is a spectral reflectance diagram of the rice canopy; Figure 16 This is a schematic diagram of the five-point sampling method for detecting the true nitrogen content in rice. Detailed Implementation
[0019] Preferred embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While preferred embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that the invention will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
[0020] Example 1 like Figure 1 As shown, this embodiment provides a method for predicting nitrogen levels in rice based on interpretable ensemble machine learning, including: S1: Acquire hyperspectral images of the UAV, extract spectral features from the hyperspectral images of the UAV, and form a high-dimensional feature pool from the spectral features; S2: The optimal feature subset is selected from the high-dimensional feature pool by using recursive feature elimination cross-validation combined with weighted SHAP value sorting; S3: Divide the optimal feature subset into a training set and a test set, divide the training set into five folds, perform cross-validation training on each base model, and obtain a preliminary prediction feature matrix; S4: The linear ridge regression model is trained using the preliminary predicted feature matrix. The linear ridge regression model consists of three base models. S5: Input the test set into the linear ridge regression model. The linear ridge regression model performs weighted integration of the predictions output by each base model to obtain the predicted value of nitrogen in rice.
[0021] The spectral features include raw reflectance, first-derivative spectrum, continuum-removed spectrum, and vegetation index. The first-derivative spectrum reflects the rate of change of the spectral curve. The continuum-removed spectrum refers to the spectrum after continuum removal. The purpose of continuum removal is to separate and enhance the characteristic absorption peaks of the target substance and eliminate interference from background reflection or illumination conditions. The linear ridge regression model includes a linear basis model, a nonlinear basis model, and a deep learning basis model. The linear basis model is LASSO (Least Absolute Shrinkage and Selection Operator) model, the nonlinear basis model is a random forest, and the deep learning basis model is a backpropagation neural network.
[0022] Before the recursive feature elimination cross-validation combined with weighted SHAP value sorting, the process also includes: The following weighted summation model is used to calculate the weighted SHAP value instead of the fixed-coefficient weighted summation model: (1) in, The weighted SHAP value, The SHAP value of the first interpreter. The SHAP value for the second interpreter. The SHAP value for the third interpreter; The first free parameter that can be learned. These are learnable second free parameters. is a learnable third free parameter; exp is an exponential function with the natural constant as the base. It is optimized and determined in cross-validation by minimizing the prediction residuals. , and Introducing an exponential function makes the weighting coefficients... The sum is always positive. After weighted summation, normalization is applied so that the sum of the normalized weighted coefficients is 1. For example... , , This invention uses an exponential function as the coefficient for the weighted summation of SHAP values. This highlights the role of key features, which are those that contribute significantly to the prediction of nitrogen content in rice, such as spectral reflectance in certain bands. It also amplifies the difference in contribution between key and non-key features, resulting in a larger difference in the weighted SHAP values of subsets after eliminating different recursive features. This allows for better selection of the optimal feature subset based on the weighted SHAP values.
[0023] The first interpreter uses KernelExplainer for the LASSO base model. The second interpreter uses DeepExplainer for the Backpropagation Neural Network (BPNN). The third interpreter uses TreeExplainer for the Random Forest. This invention employs a combined computational approach using KernelExplainer, DeepExplainer, and TreeExplainer to ensure accurate attribution of the internal mechanisms of each base model. If there is a strong correlation between spectral features, TreeExplainer uses the background dataset to handle the correlation between spectral features in the intervention mode. The average predicted value of the background dataset is used as the baseline value. This baseline value is then added to the SHAP value of each spectral feature in the random forest after recursive feature elimination, yielding the SHAP. TE If the correlation between spectral features is weak, TreeExplainer calculates SHAP in default mode. TE The average predicted value of the training set in the random forest is used as the baseline. Then, the SHAP values of each spectral feature of the subset after recursive feature removal in the random forest are added to this baseline to obtain the SHAP. TE The method for determining the correlation between spectral features is as follows: In this embodiment, SHAP is first calculated in the default mode. TE Then calculate SHAP in the intervention mode. TE If the results of the two calculations are the same, it indicates that the correlation between the spectral features is not strong, and the calculation mode of TreeExplainer should be set to the default mode. If the results of the two calculations differ significantly, it indicates that the correlation between the spectral features is strong, and the calculation mode of TreeExplainer should be set to the intervention mode.
[0024] The step of training a linear ridge regression model using the aforementioned preliminary predicted feature matrix includes: Using the preliminary predicted feature matrix as input and the actual nitrogen content of rice as a reference value, a linear ridge regression model is trained; the formula of the linear ridge regression model adopts a weighted form that incorporates local confidence constraints: (2) Where B is the set of base models. LASSO stands for Minimal Absolute Shrinkage and Selection Operator Model, RF stands for Random Forest, and BPNN stands for Backpropagation Neural Network. The output prediction value of base model i, To minimize the weighted coefficients of the base model i obtained by minimizing the loss function of the regressor meta-model with L2 regularization, y final The predicted nitrogen content of rice is the output of the linear ridge regression model. The regularization intensity hyperparameter; the regression meta-model loss function also includes a prediction error term. L2 norm penalty term with weighted coefficients This means that the contribution weights of each base model are no longer simply fixed in a linear weighted manner, but are adaptively shrunk through ridge regression.
[0025] The formula for the loss function of the regression meta-model is: (3) in, Here, num represents the loss function of the regression meta-model, N is the sample index, and N is the number of samples. Let be the true nitrogen content of rice in the num-th sample, and let bias represent the intercept of the linear ridge regression meta-model. This represents the predicted value of the base model i for the num-th sample, corresponding to the preliminary predicted feature matrix P. N×3 The element in the num-th row and i-th column of the matrix. i represents LASSO, RF, or BPNN. If i is LASSO, it corresponds to the LASSO model and the initial predicted feature matrix P. N×3 The element in the first column; if i is RF, then it corresponds to the Random Forest model, and the corresponding preliminary predicted feature matrix P. N×3 The element in the 3rd column; if i is a BPNN, then it corresponds to the backpropagation neural network, and the corresponding preliminary prediction feature matrix P. N×3 The elements in the second column of the matrix. Substitute the elements in the preliminary predicted feature matrix and the actual nitrogen content of rice into formula (3) to train the linear ridge regression model.
[0026] Formula (3) is used to simultaneously train the three base models in the linear ridge regression model. During the training process... Keep getting smaller until The value of the regression meta-model loss function converges, at which point the value of the function converges. To obtain the minimum value, we get The minimum value corresponds to a set of That is, optimal , and .Will , and Substitute the values into formula (2) to determine the weighting coefficients of the three base models. Finally, substitute the test set into formula (2) to derive the predicted nitrogen content of rice.
[0027] This invention employs an L2 penalty term to constrain the weighting coefficients of the three base models, finding the optimal linear combination of weights for the base model predictions to minimize the final prediction error. The L2 penalty term shrinks all weighting coefficients towards zero, thereby stabilizing the model while reducing variance and improving the generalization ability of the linear ridge regression model. However, the L2 penalty term does not make the weighting coefficients exactly zero.
[0028] The method for detecting the true nitrogen content of rice is as follows: rice samples are collected simultaneously while a drone is acquiring hyperspectral images, such as... Figure 16 As shown, a five-point sampling method was used, selecting five representative rice plants with uniform growth from each experimental plot. The collected samples were brought back to the laboratory, washed, and all fresh leaves from each experimental plot were cut, weighed, labeled, and bagged, then placed in an oven. The leaves were blanched at 105 ℃ for 30 min, then the temperature was adjusted to 80 ℃ and dried to constant weight. The dried leaves were then pulverized and passed through a 0.25 mm sieve. Five parallel samples were prepared for each sample, with approximately 0.2500 g of each sample weighed using a 0.01% balance. Finally, the Kjeldahl method was used to determine the nitrogen content of the rice.
[0029] This invention constructs an ensemble regression framework comprising three types of heterogeneous base models: a statistical learner employing LASSO (Least Absolute Shrinkage and Selection Operator) as a linear base model, using L1 regularization to adaptively select and sparsely represent high-dimensional spectral features, retaining key bands strongly correlated with rice nitrogen content, capturing the global linear trend between spectrum and nitrogen, and improving model interpretability. A tree model learner employs random forest as a nonlinear base model, effectively handling collinearity issues among high-dimensional spectral features through a Bagging strategy integrating multiple decision trees and a random feature subspace method, automatically learning the complex interactions and nonlinear mappings between chlorophyll absorption and nitrogen-sensitive bands, and providing feature importance ranking to enhance model transparency. A neural network learner employs backpropagation neural network (BPNN) as a deep learning base model, constructing a shallow network structure with a single hidden layer, receiving key spectral features or vegetation indices as input, and fitting the complex continuous relationship between nitrogen and spectral reflectance through a nonlinear activation function, capturing local nonlinear features.
[0030] A stacking strategy was employed to fuse the prediction outputs of the aforementioned heterogeneous base models: using the five-fold cross-validation prediction results of the base models as secondary features, a linear ridge regression meta-model was trained, achieving adaptive weighted ensemble of the advantages of each base model. This heterogeneous ensemble strategy significantly reduced the overfitting risk caused by the structural bias of a single model and improved the model's generalization robustness across growth stages and varieties. After calculating the predicted nitrogen values for rice, the fertilizer application strategy was optimized by combining the rice's nutrient requirements and soil nutrient supply capacity to improve the nitrogen use efficiency of rice.
[0031] This embodiment provides a rice nitrogen prediction method based on interpretable ensemble machine learning, which includes acquiring UAV hyperspectral images, extracting spectral features from the UAV hyperspectral images, and forming a high-dimensional feature pool from the spectral features. The high-dimensional feature pool includes raw reflectance, first-derivative spectrum, continuum-removed spectrum, and vegetation index. Recursive feature elimination cross-validation combined with weighted SHAP value sorting is used to remove redundant features and noise, selecting the optimal feature subset from the high-dimensional feature pool. The cross-validation mechanism built into the recursive feature elimination cross-validation makes feature selection decisions based on the average performance of multiple rounds of validation, which can reduce the risk of overfitting. Combined with weighted SHAP value sorting, the optimal feature subset is automatically determined, and the optimal feature subset has high sensitivity to nitrogen. The optimal feature subset is divided into a training set and a test set. The training set is divided into five folds, and cross-validation training is performed on each base model to obtain a preliminary prediction feature matrix. Using the five-fold cross-validation prediction results of the base models as secondary features, a linear ridge regression meta-model is trained to achieve adaptive weighted ensemble of the advantages of each base model. The linear ridge regression meta-model consists of three base models. The LASSO base model uses L1 regularization to adaptively select and sparsely represent high-dimensional spectral features, retaining key bands strongly correlated with rice nitrogen content. Random forest automatically learns chlorophyll absorption and the complex interactions and nonlinear mappings between nitrogen-sensitive bands through a Bagging strategy integrating multiple decision trees and a stochastic feature subspace method. A backpropagation neural network constructs a shallow network structure with a single hidden layer, fitting the complex continuous relationship between nitrogen and spectral reflectance using a nonlinear activation function to capture local nonlinear features. The test set is input into the linear ridge regression meta-model, which weights and integrates the predictions from each base model to obtain the predicted nitrogen content in rice. This heterogeneous integration strategy significantly reduces the overfitting risk caused by structural biases in a single model and improves the model's generalization robustness across growth stages and varieties. Meanwhile, by combining interpretability tools such as SHAP to provide global and local interpretations of the decision-making process of the integrated model, high-precision and robust inversion of rice nitrogen content is achieved, ensuring the interpretability and reliability of rice nitrogen prediction.
[0032] Example 2 This embodiment provides a method for predicting nitrogen levels in rice based on interpretable ensemble machine learning. This embodiment describes the differences between it and Embodiment 1.
[0033] The process of using recursive feature elimination, cross-validation, and weighted SHAP value sorting to select the optimal feature subset from the high-dimensional feature pool includes: S21: Divide the data in the high-dimensional feature pool into M feature subsets; S22: Perform recursive feature elimination on each of the feature subsets to obtain M recursive feature elimination subsets; wherein, in each iteration of the recursive feature elimination, calculate the feature stability index of each spectral feature and remove spectral features whose feature stability index is lower than the feature stability index threshold. S23: After eliminating the M recursive features, the subsets are sequentially input into the weighted summation model to obtain M weighted SHAP values; S24: Select the maximum weighted SHAP value from the M weighted SHAP values, and take the feature subset corresponding to the maximum weighted SHAP value as the optimal feature subset.
[0034] Recursive Feature Elimination Cross-Validation (RFECV) is a feature selection method that automatically determines the optimal number of features. It finds the optimal feature subset by recursively removing the least important features and combining this with cross-validation to evaluate model performance. This effectively avoids overfitting while improving the model's generalization ability. M ≥ 2; the more data types in the high-dimensional feature pool, the larger the value of M.
[0035] The recursive feature elimination cross-validation includes: (1) Recursive elimination: Starting from each feature subset, one or more least important features are removed in each round based on feature importance until the feature subset is empty. (2) Cross-validation evaluation: After each round of feature removal, 5-fold cross-validation is used to evaluate the performance of the current feature subset. (3) Automatic selection of the optimal: After the removal process is completed, RFECV will draw a feature number-model score curve and select the feature number corresponding to the highest cross-validation score as the final selection. After adjusting the number of spectral features in the M feature subsets, M recursive feature elimination subsets are obtained.
[0036] In the recursive feature elimination cross-validation process, a feature stability index is introduced as an auxiliary criterion for feature retention. The formula for calculating the feature stability index is as follows: (4) in, For the first The characteristic stability index of each spectral feature, where K is the total number of folds in the cross-validation. For the first The spectral feature at the th Ranking of the importance of compromise; when When the value is higher than the stability index threshold, it indicates that the j-th spectral feature is of high importance and relatively stable in multiple cross-validations, and this spectral feature is then included in the calculation of the weighted SHAP value.
[0037] The formula for the weighted summation model is formula (1) in Example 1. TreeExplainer is for tree models, DeepExplainer is for BPNN, and KernelExplainer is for LASSO. After eliminating each recursive feature, the subset is input into the weighted summation model to calculate M weighted SHAP values. The largest weighted SHAP value is selected from the M weighted SHAP values, and the feature subset corresponding to the largest weighted SHAP value is taken as the optimal feature subset. The weighted SHAP value is used to explain the unified attribution method of machine learning model prediction. Its core function is to quantify the contribution of each feature to the final prediction result of the model and enhance the interpretability of the black box model.
[0038] After eliminating each recursive feature, all spectral features in the subset are input into a weighted summation model to obtain a SHAP value. The average SHAP value of all samples in the corresponding subset after recursive feature elimination is then calculated to obtain the global feature importance of that subset. Compared to traditional feature importance based on tree models, SHAP values can more fairly reflect the actual impact of high-dimensional features on prediction. The greater the marginal contribution of a high-dimensional feature in any interpreter, the larger the SHAP value of the corresponding interpreter. SHAP values can be used for tree models, neural networks, and linear models, and have the same interpretability scale.
[0039] After obtaining the predicted nitrogen value for rice, the process also includes: S61': Identify the key features that contribute most to the nitrogen inversion of rice, and draw a SHAP dependency graph by combining the key features and the weighted SHAP value; the SHAP dependency graph is used to characterize the nonlinear response relationship between the key band and the nitrogen content of rice. S62': For the predicted nitrogen value of rice in each field or each pixel unit, generate a SHAP waterfall plot and a SHAP interaction value matrix; the SHAP waterfall plot is used to show the positive or negative driving effect of spectral reflectance of different bands on the predicted nitrogen value of rice, and the SHAP interaction value matrix is used to analyze the influence of the coupling effect between the red edge and near-infrared, and near-infrared and short-wave infrared bands on the inversion of nitrogen value of rice.
[0040] To address the lack of interpretability in ensemble models due to their black-box nature, this invention introduces the SHAP attribution analysis framework. This invention calculates the mean absolute SHAP value of each spectral feature across all samples. The mean absolute SHAP value is calculated by first taking the absolute value of each SHAP value and then averaging all the absolute SHAP values. The spectral features with the highest mean absolute SHAP values are sorted from largest to smallest, and those with the highest ranking are the key features that have the greatest impact on the model's prediction of rice nitrogen content. A SHAP dependency graph is then plotted to reveal the nonlinear response pattern between the bands corresponding to the key features and rice nitrogen content. This invention uses the `shap.TreeExplainer` function to generate the SHAP dependency graph. Spectral characteristics include B650.29, RARS, DCNI, B734.52, SR, PSSR, B775.6, B444.89, MTCI, and PSND. B650.29 represents the spectral reflectance at 650.29 nm, B734.52 represents the spectral reflectance at 734.52 nm, B775.6 represents the spectral reflectance at 775.6 nm, B444.89 represents the spectral reflectance at 444.89 nm, and B650.29 represents the spectral reflectance at 650.29 nm. RARS represents the reflectance ratio analysis index, DCNI represents the bimodal canopy vegetation index, SR represents the ratio vegetation index, PSSR represents the simple ratio vegetation index for specific pigments, MTCI represents the ground chlorophyll index, and PSND represents the normalized difference in pigments index.
[0041] A SHAP waterfall plot is generated for the nitrogen prediction value of each field or pixel unit, visually showing which spectral reflectance bands positively or negatively drive the nitrogen diagnosis result at that point. For example, if the red-edge band reflectance of a pixel is high (SHAP value is positive), it is determined that the area has sufficient nitrogen. If the red-edge band reflectance of a pixel is low (SHAP value is negative), it is attributed to nitrogen deficiency stress. The SHAP waterfall plot is drawn by first drawing a baseline to determine the starting point, then drawing the ending point based on the rice nitrogen prediction value, and finally drawing feature contribution bars. Each feature contribution bar represents the influence of a feature on the rice nitrogen prediction value. If the starting point of the feature in the SHAP waterfall plot is to the left of the ending point, the SHAP value is positive, corresponding to the feature positively driving the nitrogen diagnosis result at that point. If the starting point of the feature in the SHAP waterfall plot is to the right of the ending point, the SHAP value is negative, corresponding to the feature negatively driving the nitrogen diagnosis result at that point.
[0042] SHAP waterfall plot is used to filter features, remove redundant variables, and complement the features obtained by recursive feature elimination cross-validation. The specific steps are: (1) Train XGBoost based on full features; (2) Draw waterfall plots of typical samples with different nitrogen levels and observe the contribution direction and magnitude of each feature; (3) If the contribution direction of a certain feature fluctuates greatly in multiple samples or is contrary to the physiological mechanism, it is judged as noise removal; (4) Retain features with stable contributions and consistent mechanisms, and take the union of the results of recursive feature elimination cross-validation to obtain the final sensitive subset.
[0043] This invention also calculates the SHAP interaction value matrix, which can decompose the model prediction into main effects and interaction effects. For a model with num features, it will generate a symmetric num×num matrix for each prediction sample. Based on the SHAP interaction value matrix, the coupling effect between the red edge and near-infrared, and near-infrared and short-wave infrared bands is analyzed to influence nitrogen inversion, revealing the synergistic and antagonistic mechanisms between spectral features, thereby further optimizing the feature selection process and improving the accuracy of rice nitrogen prediction. The analysis process is as follows: (1) Calculate the SHAP interaction value matrix for each sample, where the off-diagonal elements represent the joint effect of feature pairs (such as red edge-near-infrared). (2) Extract the SHAP interaction value of the target band pair and observe its sign and magnitude: positive values indicate synergy (the joint contribution is greater than the sum of the main effects), and negative values indicate antagonism. (3) Statistically analyze the distribution of SHAP interaction values according to the rice nitrogen level group to test whether the coupling effect changes with the nitrogen gradient. (4) Combine agronomic mechanisms for explanation: such as the synergistic effect of red edge-near infrared reflects the joint response of chlorophyll and canopy structure, and the antagonism of near infrared-shortwave infrared may originate from the relative changes in water content and dry matter content caused by nitrogen. (5) Construct a combination index with strong synergy, or group and model the synergistic and antagonistic effects to improve the prediction accuracy.
[0044] Example 3 This embodiment provides a method for predicting nitrogen levels in rice based on interpretable ensemble machine learning. This embodiment describes the differences between this embodiment and Embodiments 1 and 2, based on Embodiment 1.
[0045] The step of dividing the training set into five folds and performing cross-validation training on each base model to obtain a preliminary prediction feature matrix includes: S32: Randomly divide the training set into 5 training subsets; wherein all training subsets are mutually exclusive; S33: Perform cross-validation training on each base model using 5 training subsets; S34: Collect the predicted values of each fold of the validation set; S35: Stack all the predicted values to form a preliminary prediction feature matrix, the size of which is N×3, where N is the number of samples; S36: Perform a complementarity evaluation based on Shannon entropy on the preliminary predicted feature matrix to obtain a complementarity index; when the complementarity index is greater than a preset threshold, retain the complete preliminary predicted feature matrix; otherwise, prune the base model and reconstruct the preliminary predicted feature matrix. The formula for calculating the complementarity index is: (5) in, The complementarity index, For the sample size, Let be the empirical entropy of the num-th sample on the triplet composed of the predicted values of the three base models. The maximum possible entropy of the triple is given by . As a normalization factor, empirical entropy is the discrete form of Shannon entropy. A higher empirical entropy indicates that the base model's predicted probabilities for each category are closer to a uniform distribution, but also indicates greater prediction uncertainty. Conversely, a lower empirical entropy indicates that the probability of a certain category is closer to 1, and the confidence level of the base model's predicted values is higher. When... When the C value approaches 1, it indicates that the information provided by the three base models is highly complementary. When the C value approaches 0, it indicates that the information provided by the three base models is highly redundant. In this embodiment, a preset threshold of 0.65 is used as an example. When the complementarity index is less than or equal to the preset threshold, all three base models are pruned to achieve a balance between information complementarity and reducing redundancy. The pruning methods are as follows: For random forests, the growth of decision trees is terminated early by setting hyperparameters, and / or unimportant internal nodes are replaced with leaf nodes from the bottom up. For backpropagation neural networks, neural network weights with absolute values below a certain threshold are removed, or convolutional kernels and channels are removed. For LASSO, a weighted L1 norm term is added after the loss function of standard linear regression, thereby driving the weights corresponding to some irrelevant features to continuously approach zero, eventually becoming zero.
[0046] Before step S32, step S31 is included: dividing the optimal feature subset into a training set and a test set. The five training subsets have no identical samples. Predicted values from each fold of the validation set are collected and stacked to form a preliminary prediction feature matrix P. N×3 Five-fold cross-validation randomly divides the training set into five training subsets of equal size. Four of these subsets are used in turn to train the model, and the remaining subset is used for validation. The average performance metric from the five validations is then obtained. Five-fold cross-validation uses an 80% training set and a 20% validation set, making full use of the data and having relatively low computational cost. Let P... N×3 Input the three base models of formula (2) in Example 1, and then sum the predictions output by the three base models in a weighted manner to obtain the predicted value of rice nitrogen. Train the linear ridge regression model based on the difference between the predicted value of rice nitrogen and the actual nitrogen content of rice.
[0047] The outputs of base models often exhibit high correlation, or collinearity, which severely interferes with coefficient estimation in ordinary linear regression, leading to unstable model performance. The linear ridge regression meta-model is a linear model with built-in L2 regularization constraints and integrates a machine learning model. By introducing an L2 penalty term into the regression meta-model's loss function, it can significantly improve the stability and generalization ability of parameter estimation without significantly reducing fitting accuracy, ensuring a smooth and stable optimal weight combination even when the base models are highly correlated.
[0048] After obtaining the predicted nitrogen value for rice, the process also includes: S64': Calculate the mean and variance of the predicted values for the sample by each base model; S65': Based on the mean and variance of the predicted values, the coefficient of variation is predicted using the following formula: (6) Where U(num) is the coefficient of variation for sample num, and avg is the average value. For variance calculation, The set of predicted values for sample num by all base models, where . represents a multiplication operation; the coefficient of variation is used to determine rice regions with high confidence and rice regions with high uncertainty.
[0049] Regions with coefficients of variation below the threshold are designated as high-confidence rice regions, while regions with coefficients of variation greater than or equal to the threshold are designated as high-uncertainty rice regions. The purpose of high-uncertainty rice regions is to inform users that these regions are affected by mixed pixels, soil background interference, and / or canopy structure anomalies. Nitrogen inversion results need to be verified in conjunction with field surveys. Uncertainty is quantified using the coefficient of variation to distinguish between high-confidence and high-uncertainty rice regions, and the predicted rice nitrogen values output in step S6 are then verified.
[0050] This embodiment also provides a rice nitrogen prediction system based on interpretable ensemble machine learning, including: A high-dimensional feature pooling module is used to acquire UAV hyperspectral images, extract spectral features from the UAV hyperspectral images, and combine the spectral features into a high-dimensional feature pool. The optimal feature subset selection module is used to select the optimal feature subset from the high-dimensional feature pool by using recursive feature elimination, cross-validation, and weighted SHAP value sorting. The cross-validation training module is used to divide the optimal feature subset into a training set and a test set, divide the training set into five folds, perform cross-validation training on each base model, and obtain a preliminary prediction feature matrix. The linear ridge regression meta-model training module is used to train the linear ridge regression meta-model using the preliminary prediction feature matrix. The linear ridge regression meta-model consists of three base models. The nitrogen nutrient content calculation module for rice is used to input the test set into the linear ridge regression model. The linear ridge regression model performs weighted integration of the predictions output by each base model to obtain the predicted value of nitrogen in rice.
[0051] Example 4 This embodiment provides experimental results from different methods to demonstrate the effectiveness of the stacked ensemble learning method of the present invention in predicting nitrogen levels in rice. For example... Figure 2 As shown, the training set determination coefficient R of the rice nitrogen prediction method based on interpretable ensemble machine learning in this invention is... 2 =0.9544. Compared to Figure 6 The training set determination coefficient R of the multi-model voting ensemble learning method 2 =0.8735, the R-value of this invention on the training set is... 2 The coefficient of determination was improved by 0.0809, and both learning methods used the same training set. The coefficient of determination quantifies the proportion of the variance of the dependent variable explained by the independent variable in the regression model, thereby evaluating the model's fit and explanatory power. Therefore, the stacked ensemble learning method provided in this invention has a higher fit and stronger interpretability for rice nitrogen prediction values than the multi-model voting ensemble learning method.
[0052] like Figure 3 As shown, the test set determination coefficient R of the rice nitrogen prediction method based on interpretable ensemble machine learning in this invention is... 2 =0.8852, compared to Figure 7 The test set determination coefficient R of the multi-model voting ensemble learning method 2 =0.8465, the R-value of this invention on the test set is... 2 The improvement was 0.0387, and both learning methods used the same test set.
[0053] Figure 4 This is a test set residual scatter plot of the rice nitrogen prediction method based on interpretable ensemble machine learning of the present invention. The horizontal axis of the residual scatter plot is the predicted value, and the vertical axis is the residual. Figure 4 The residuals are randomly distributed near the zero line, with no obvious trend. Figure 8 This is a scatter plot of the test set residuals for a multi-model voting ensemble learning method. Figure 8 The residuals below the zero line are distributed in a funnel shape, and there are more outliers above the zero line. Figure 4 and Figure 8 The results demonstrate that the method provided by this invention captures more information, and the residuals are merely random errors.
[0054] Figure 5 This is a residual distribution plot of the test set for the rice nitrogen prediction method based on interpretable ensemble machine learning of the present invention. The horizontal axis of the residual distribution plot is the residual, and the vertical axis is the frequency. Figure 5 The histogram has good left-right symmetry, with the peak value located near 0, and the middle of the histogram is high while the sides are low. Figure 9 This is a residual distribution plot of the test set for the multi-model voting ensemble learning method. Figure 9 The histogram has a higher degree of symmetry than the left-right ratio. Figure 5 Poor, the left side has a higher frequency, the right side has a lower frequency, and the peak value deviates from 0 by a greater margin than... Figure 5 The frequency is large, and the left side of the histogram is close to the frequency of the middle part of the histogram.
[0055] Figure 12 This is a radial bar chart showing the feature importance of the method provided by this invention, such as... Figure 12 As shown, the top six most important features are B650.29 (17.3%), RARS (15.4%), DCNI (13.7%), B734.52 (13.6%), SR (11.7%), and PSSR (10.5%). Other spectral features have an importance of less than 10%. Therefore, the key features include B650.29, RARS, DCNI, B734.52, SR, and PSSR.
[0056] Figure 11 It is a SHAP dependency graph based on an interpretable ensemble machine learning method for predicting nitrogen in rice. Figure 11 The horizontal axis represents the value of B650.29, and the vertical axis represents the value of SHAP. The value of SHAP first increases and then decreases as the value of B650.29 increases, and the value of SHAP varies within the range of [-0.4, 0.3]. It can be seen that B650.29 has a significant impact on the value of SHAP. The above results verify that B650.29 is a key feature.
[0057] Figure 10 This is a SHAP waterfall plot based on an interpretable ensemble machine learning method for predicting nitrogen levels in rice. Figure 10 The waterfall plots of all spectral features show negative values, indicating that the combination of spectral feature values in this invention has a reducing effect on the predicted nitrogen content in rice. Figure 10 Under the given spectral feature values, each spectral feature causes the predicted value of rice nitrogen to be lower than the model's baseline value. In other words, each spectral feature of this application pushes the predicted value of rice nitrogen from the baseline to a lower level. Figure 10 The results demonstrate that the spectral features selected in this invention all affect the process of the model predicting nitrogen in rice.
[0058] like Figure 13 and Figure 14As shown, the agronomical traits of rice grown in different paddy fields differ, mainly in color; some paddy fields have a greenish hue, while others have a yellowish hue. Chlorophyll molecules contain nitrogen, so sufficient nitrogen in the leaves increases chlorophyll synthesis. Conversely, nitrogen deficiency hinders chlorophyll synthesis, causing the leaves to turn yellow. Figure 15 It is the spectral reflectance of the rice canopy, by Figure 15 It can be seen that the rice canopy has a high reflectivity in the range of 750nm-925nm.
[0059] This embodiment also provides a computer device, which may be a server. The computer device includes a processor, memory, a network interface, and a database connected via a system bus. The processor in this computer design provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communication with external terminals via a network connection.
[0060] This embodiment also provides a computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the rice nitrogen prediction method based on interpretable ensemble machine learning described in any one of Embodiments 1-3. It is understood that the computer-readable storage medium in this embodiment can be a volatile readable storage medium or a non-volatile readable storage medium.
[0061] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, apparatus, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.
[0062] The above description is only a preferred embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural changes made based on the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method for predicting nitrogen levels in rice based on interpretable ensemble machine learning, characterized in that, include: Acquire hyperspectral images of the UAV, extract spectral features from the UAV hyperspectral images, and form a high-dimensional feature pool from the spectral features; The optimal feature subset is selected from the high-dimensional feature pool by using recursive feature elimination cross-validation combined with weighted SHAP value sorting. The optimal feature subset is divided into a training set and a test set. The training set is divided into five folds. Cross-validation training is performed on each base model to obtain a preliminary prediction feature matrix. The preliminary predicted feature matrix is used to train a linear ridge regression model, which consists of three base models. The test set is input into the linear ridge regression model, which performs a weighted integration of the predictions output by each base model to obtain the predicted value of nitrogen in rice.
2. The rice nitrogen prediction method based on interpretable ensemble machine learning according to claim 1, characterized in that, The linear ridge regression meta-model includes a linear basis model, a nonlinear basis model, and a deep learning basis model. The linear basis model is LASSO, the nonlinear basis model is random forest, and the deep learning basis model is backpropagation neural network. The spectral features include raw reflectance, first derivative spectrum, continuum-removed spectrum, and vegetation index.
3. The rice nitrogen prediction method based on interpretable ensemble machine learning according to claim 2, characterized in that, Before the recursive feature elimination cross-validation combined with weighted SHAP value sorting, the process also includes: The weighted SAP value is calculated using the following weighted summation model: ; in, The weighted SHAP value, The SHAP value of the first interpreter. The SHAP value for the second interpreter. The SHAP value for the third interpreter; The first free parameter that can be learned. These are learnable second free parameters. is a learnable third free parameter; exp is an exponential function with the natural constant as the base.
4. The rice nitrogen prediction method based on interpretable ensemble machine learning according to claim 3, characterized in that, The process of using recursive feature elimination, cross-validation, and weighted SHAP value sorting to select the optimal feature subset from the high-dimensional feature pool includes: The data in the high-dimensional feature pool is divided into M feature subsets; Recursive feature elimination is performed on each of the feature subsets to obtain M recursive feature elimination subsets; wherein, in each iteration of recursive feature elimination, the feature stability index of each spectral feature is calculated, and spectral features whose feature stability index is lower than the feature stability index threshold are removed. After eliminating the M recursive features, the subsets are sequentially input into the weighted summation model to obtain the M weighted SHAP values. Select the maximum weighted SHAP value from the M weighted SHAP values, and take the feature subset corresponding to the maximum weighted SHAP value as the optimal feature subset.
5. The rice nitrogen prediction method based on interpretable ensemble machine learning according to claim 1, characterized in that, The step of dividing the training set into five folds and performing cross-validation training on each base model to obtain a preliminary prediction feature matrix includes: The training set is randomly divided into 5 training subsets; all training subsets are mutually exclusive. Cross-validation training was performed on each base model using five training subsets; Collect the predicted values for each fold of the validation set; All the predicted values are stacked to form a preliminary prediction feature matrix, the size of which is N×3, where N is the number of samples; The complementarity of the preliminary predicted feature matrix is evaluated based on Shannon entropy to obtain a complementarity index. If the complementarity index is greater than a preset threshold, the complete preliminary predicted feature matrix is retained; otherwise, the base model is pruned and the preliminary predicted feature matrix is reconstructed. The formula for calculating the complementarity index is as follows: ; in, The complementarity index, For the sample size, Let be the empirical entropy of the num-th sample on the triplet composed of the predicted values of the three base models. The maximum possible entropy of the triple is given by . As the normalization factor; when When the value approaches 1, it indicates that the information provided by the three base models is highly complementary.
6. The rice nitrogen prediction method based on interpretable ensemble machine learning according to claim 1, characterized in that, The step of training a linear ridge regression model using the aforementioned preliminary predicted feature matrix includes: Using the preliminary predicted feature matrix as input and the actual nitrogen content of rice as a reference value, a linear ridge regression model is trained; the formula for the linear ridge regression model is: ; Where B is the set of base models. The output prediction value of base model i, To minimize the weighted coefficients of the base model i obtained by minimizing the loss function of the regressor meta-model with L2 regularization, y final The predicted nitrogen content of rice is the output of the linear ridge regression model. The regularization intensity hyperparameter is denoted by ; the regression meta-model loss function simultaneously includes a prediction error term and an L2 norm penalty term for the weighted coefficients.
7. The rice nitrogen prediction method based on interpretable ensemble machine learning according to claim 1, characterized in that, After obtaining the predicted nitrogen value for rice, the process also includes: Calculate the mean and variance of the predicted values for the samples for each base model; The coefficient of variation is predicted using the following formula based on the mean and variance of the predicted values: ; Where U(num) is the coefficient of variation for sample num, and avg is the average value. For variance calculation, The set of predicted values for sample num by all base models, where . represents a multiplication operation; the coefficient of variation is used to determine rice regions with high confidence and rice regions with high uncertainty.
8. The rice nitrogen prediction method based on interpretable ensemble machine learning according to claim 3, characterized in that, After obtaining the predicted nitrogen value for rice, the process also includes: The key features that contribute most to the nitrogen content retrieval in rice were identified, and a SHAP dependency plot was drawn by combining the key features and the weighted SHAP values. The SHAP dependency plot was used to characterize the nonlinear response relationship between the key bands and the nitrogen content in rice. For each field or each pixel unit, a SHAP waterfall plot and a SHAP interaction value matrix are generated for the predicted nitrogen content of rice. The SHAP waterfall plot is used to show the positive or negative driving effect of spectral reflectance of different bands on the predicted nitrogen content of rice. The SHAP interaction value matrix is used to analyze the influence of the coupling effect between the red edge and near-infrared bands, and between the near-infrared band and the short-wave infrared band on the inversion of nitrogen content of rice.
9. The rice nitrogen prediction method based on interpretable ensemble machine learning according to claim 4, characterized in that, The calculation of the characteristic stability index for each spectral feature includes: The characteristic stability index of the j-th spectral feature is calculated using the following formula: ; in, For the first The characteristic stability index of each spectral feature, where K is the total number of folds in the cross-validation. For the first The spectral feature at the th Ranking of the importance of compromise; when When the value is above the stability index threshold, the j-th spectral feature is retained for the calculation of the weighted SAP value.
10. A rice nitrogen prediction system based on interpretable ensemble machine learning, characterized in that, include: A high-dimensional feature pooling module is used to acquire UAV hyperspectral images, extract spectral features from the UAV hyperspectral images, and combine the spectral features into a high-dimensional feature pool. The optimal feature subset selection module is used to select the optimal feature subset from the high-dimensional feature pool by using recursive feature elimination, cross-validation, and weighted SHAP value sorting. The cross-validation training module is used to divide the optimal feature subset into a training set and a test set, divide the training set into five folds, perform cross-validation training on each base model, and obtain a preliminary prediction feature matrix. The linear ridge regression meta-model training module is used to train the linear ridge regression meta-model using the preliminary prediction feature matrix. The linear ridge regression meta-model consists of three base models. The nitrogen nutrient content calculation module for rice is used to input the test set into the linear ridge regression model. The linear ridge regression model performs weighted integration of the predictions output by each base model to obtain the predicted value of nitrogen in rice.