Stacked integrated machine learning water quality remote sensing inversion method and system based on model contribution degree self-optimization weighting

By using a stacked ensemble machine learning method based on self-optimizing weighted model contribution, the problems of insufficient accuracy and computational redundancy in water quality remote sensing inversion in complex water environments are solved, and efficient water quality parameter prediction is achieved.

CN120932119APending Publication Date: 2025-11-11GUILIN UNIVERSITY OF TECHNOLOGY
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510999617.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-21
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

Existing water quality remote sensing inversion methods lack accuracy in complex water environments, especially in karst rivers. Traditional methods cannot effectively handle complex optical environments and water quality differences, and stacked ensemble machine learning methods suffer from computational redundancy and increased memory usage.

Method used

A stacked ensemble machine learning method based on model contribution self-optimization weighting was adopted. The water body range was extracted by correcting the normalized water body index, Sentinel-2 image data was screened, band combination and feature elimination were performed, the contribution of the base model was dynamically evaluated and weighted, and finally a water quality remote sensing inversion model was constructed.

Benefits of technology

It significantly improves the prediction accuracy of water quality parameters and the computational efficiency of the model, is applicable to complex aquatic environments, reduces computational resource consumption, and achieves high-precision water quality parameter inversion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120932119A_ABST
    Figure CN120932119A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of water quality monitoring methods, and particularly discloses a stacking integrated machine learning water quality remote sensing inversion method and system based on model contribution degree self-optimization weighting, and the method comprises the following steps: extracting a surface water body range and corresponding water quality monitoring data, integrating the water quality monitoring data into a daily average water quality data set, and calculating the daily average water quality data set; selecting wave bands B2, B3, B4, B5, B6, B7, B8 and B8A, and matching the in-situ water quality monitoring data with the reflectivity of the Sentinel-2 wave band; combining the B2-B8A in pairs to obtain seven mathematical changes, and generating waveband combination features; screening an optimal wave band combination, and carrying out model training to obtain a base model prediction result; and selecting the base model with the optimal determination coefficient R2 as a meta-model, constructing a new feature data set, inputting the new feature data set into the meta-model for final training, and outputting a water quality remote sensing inversion result. By adopting the technical scheme, the high-precision prediction of the water quality parameters is realized by dynamically evaluating the prediction performance of the base model and automatically optimizing the contribution weight of the base model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of water quality monitoring methods, and relates to a stacked ensemble machine learning method and system for water quality remote sensing inversion based on model contribution degree self-optimization weighting. Background Technology

[0002] Rivers are among the most important aquatic ecosystems globally, closely linked to the survival and development of human society. Over 40% of the world's population lives near rivers, coastal areas, and lakes, and this proportion continues to increase. In recent years, human activities and natural changes, such as industrial wastewater discharge, increased domestic sewage, reservoir and dam construction, and water temperature fluctuations, have led to problems such as declining water quality, eutrophication, and ecosystem degradation in rivers. Therefore, strengthening water quality monitoring, protecting aquatic environments, and improving the ability to rapidly and dynamically monitor water quality have become urgent and critical issues that need to be addressed.

[0003] Traditional water quality monitoring is time-consuming, labor-intensive, and unable to achieve large-scale monitoring. In contrast, remote sensing technology has advantages such as wide coverage, low cost, and long-term monitoring capability, providing a cost-effective and efficient method for water quality monitoring.

[0004] Currently, remote sensing-based water quality inversion methods mainly include three types: empirical models, analytical models, and semi-empirical models. However, these methods face many challenges when applied to inland water bodies. Inland water bodies typically exhibit complex optical environments, with significant differences in water quality and optically active substances. The temporal variations in the composition and concentration of these substances can significantly affect the accuracy of water quality inversion.

[0005] Furthermore, existing water quality remote sensing inversion algorithms are mostly applicable to large inland lakes and surface rivers. In the unique hydrological environment of karst rivers, due to the alkalinity of the water and the influence of a dual hydrogeological structure (interaction between surface and underground rivers), their optical characteristics differ significantly from those of traditional water bodies. Currently, high-precision quantitative inversion methods for such complex water bodies are still relatively lacking.

[0006] With the development of artificial intelligence, machine learning methods have been widely used in water quality monitoring due to their ability to capture the complex nonlinear fitting process in remote sensing water quality inversion. However, single machine learning methods suffer from limited learning capacity and are prone to overfitting. In contrast, stacked ensemble machine learning methods, which integrate multiple machine learning algorithms, can enhance the model's generalization ability and thus further improve its predictive power. However, stacked ensemble machine learning methods also introduce problems such as increased computational redundancy and memory usage. Summary of the Invention

[0007] The purpose of this invention is to provide a stacked ensemble machine learning method and system for water quality remote sensing inversion based on model contribution self-optimization weighting, so as to achieve high-precision prediction of water quality parameters.

[0008] To achieve the above objectives, the basic solution of this invention is: a stacked ensemble machine learning method for water quality remote sensing inversion based on model contribution self-optimization weighting, comprising the following steps:

[0009] S1, using the modified normalized water index mNDWI, to extract the extent of surface water bodies;

[0010] S2, acquire the geographic coordinates of all automatic monitoring stations within the surface water body and water quality monitoring data at a resolution of w hours, including total phosphorus (TP) concentration and pH value, and integrate the w-hour resolution data into a daily average water quality dataset using the arithmetic mean method, where w is an integer greater than 1;

[0011] S3. Based on cloud cover thresholds, Sentinel-2 image data were filtered, selecting B2 (Blue), B3 (Green), B4 (Red), B5 (Red edge 1), B6 ​​(Red edge 2), B7 (Red edge 3), B8 (NIR), and B8A (Narrow NIR).

[0012] The B5, B6, B7, and B8A bands were resampled to a spatial resolution of 10m, and the in-situ water quality monitoring data were matched with the reflectance of the Sentinel-2 band at the corresponding spatiotemporal locations.

[0013] S4. By combining B2-B8A in pairs, seven mathematical transformations are obtained, including Bi+Bj, Bi-Bj, Bi*Bj, Bi / Bj, (Bi-Bj) / (Bi+Bj), (Bi*Bj) / (Bi+Bj), and (Bi-Bj) / (Bi*Bj), generating 196 band combination features, where i≠j, i=2,3,4,5,6,7,8,8A; j=2,3,4,5,6,7,8,8A;

[0014] Correlation analysis was used to eliminate interference from highly correlated features, and recursive feature elimination and random forest algorithms were employed to select the optimal band combination.

[0015] S5 uses TP concentration, pH value and optimal band combination as input variables, and divides the training set and test set in a 7:3 ratio.

[0016] The optimal hyperparameters of the base model are determined by grid search, and the model is trained using five-fold cross-validation to obtain the prediction results of the base model.

[0017] Choose the coefficient of determination R 2 The optimal base model is used as the meta-model. Based on the cross-validation results, the contribution score of each base model is calculated. Base models with contribution scores exceeding the threshold are selected and weighted according to their contribution ratios to construct a new feature dataset. This dataset is then input into the meta-model for final training, and the water quality remote sensing inversion results are output.

[0018] The working principle and beneficial effects of this basic scheme are as follows: This technical scheme establishes a universal water quality parameter inversion model based on stacked ensemble machine learning. By dynamically evaluating the predictive performance of the base model and automatically optimizing its contribution weight, it significantly reduces the consumption of computing resources while ensuring the accuracy of the model, providing a new technical solution for remote sensing inversion of water quality parameters in complex water environments.

[0019] Furthermore, step S1 specifically involves using the difference in reflectance values ​​between target objects in different bands to extract the water surface area via mNDWI, ensuring that the sampling location is a water pixel:

[0020]

[0021] Where, ρ Green It is the surface reflectivity in the green light band, ρ SWIR It refers to the surface reflectivity in the shortwave infrared band;

[0022] When mNDWI>0, the pixel is classified as a water body; otherwise, it is classified as a non-water body pixel.

[0023] By utilizing the difference in reflectance values ​​between target objects in different bands, the water surface range is extracted using mNDWI to ensure that the sampling location is a water pixel.

[0024] Furthermore, in step S3, based on the GEE MAP library in Python, the Sentinel-2A image is filtered by setting a cloud cover threshold of <20% to remove cloud interference;

[0025] Bands B2, B3, B4, B5, B6, B7, B8, and B8A were selected, and a cubic convolution algorithm was used to resample bands B5, B6, B7, and B8A to a spatial resolution of 10m; the Sentinel-2A remote sensing reflectance Rrs was obtained by dividing the bottom atmospheric reflectance BOA product by π.

[0026] The time window is set to ±3 days. Spatiotemporal matching is performed on the in-situ water quality monitoring data within the 3-day time window before and after the satellite transit date. The in-situ water quality monitoring data is matched with the remote sensing reflectance of the Sentinel-2 band at the corresponding spatiotemporal location to ensure data synchronization.

[0027] Centered on the geographical location of the monitoring station, the mean remote sensing reflectance of the corresponding 3×3 pixel window in the Sentinel-2 image is extracted. Spatial averaging effectively reduces the uncertainty caused by pixel-scale noise and positioning error, and finally obtains a multi-band remote sensing reflectance dataset corresponding to the spatiotemporal water quality parameters.

[0028] Preprocessing remote sensing data is beneficial for subsequent use.

[0029] Furthermore, step S4 eliminates interference from highly correlated features through correlation analysis, and uses recursive feature elimination and random forest algorithm to select the optimal band combination as the model input features.

[0030] Calculate the correlation coefficient, remove highly correlated features with a correlation coefficient greater than 0.95, and the correlation coefficient is:

[0031]

[0032] Among them, R xy Let x be the correlation coefficient between variables x and y; n be the sample size; x i y represents the value of the i-th sample in the first band combination; i This represents the value of the i-th sample in the second band combination. The mean values ​​for different bands of the Sentinel-2 image; The mean of the mathematical transformation results of Sentinel-2 images; correlation coefficient R xy Set to 0.95, when |R xy When |>0.95, redundancy is considered to exist between features;

[0033] The Recursive Feature Emission (RFE)-Random Forest algorithm is applied to select the optimal band combination as the model input features, specifically:

[0034] The initial random forest model is trained using the band combinations remaining after removing highly correlated band combinations, and the importance score of each band combination is calculated.

[0035] Stability was verified using 5-fold cross-validation. The data was divided into 5 equal parts, and the model was trained on 4 parts in turn and tested on the remaining part. In Python, the Recursive Feature Elimination Cross-Validation (RFECV) module from the scikit-learn library was used in conjunction with a random forest regressor to obtain R0. 2 Rate and record, specifically:

[0036] Each iteration divides the data into 5 parts, uses 4 of them in turn to train the random forest model, and makes predictions on the remaining 1 part of the test set;

[0037] The coefficient of determination R is calculated by comparing the true values ​​and predicted values ​​on the test set.2 This reflects the model's ability to explain the variance of the target variable:

[0038]

[0039] Where n is the number of samples; y i It is the true value of the i-th sample; It is the average of the sample; It is the predicted value of the i-th sample;

[0040] The final R was recorded after 5 verifications. 2 The mean is used as an indicator of the stability of this band combination. If R 2 A value close to 1 and a small variance indicate that the band combination has good and stable predictive ability.

[0041] After removing the two bands with the lowest importance scores in each iteration, the model is retrained with the remaining bands and the cross-validation process is repeated.

[0042] Continue iterating until the model is cross-validated in R. 2 The score no longer increases, and the final retained band combination is the optimal feature band combination. When the 9th band combination is reached, the model's R-value... 2 Since it is the largest, the optimal feature combination for translating total phosphorus (TP) concentration was finally determined to be a combination of 9 bands.

[0043] Pearson correlation coefficient analysis was used to remove highly correlated features with a correlation coefficient greater than 0.95, eliminating redundant information. The Recursive Feature Elimination-Random Forest (RFE-RF) algorithm was applied to select the optimal band combination as the model input features.

[0044] Furthermore, in step S5, for various base models, including: Linear Regression, Random Forest Regressor, Extreme Gradient Boosting Regression (XGBRegressor, AdaBoostRegressor), and Decision Tree Regressor, Grid Search is used to optimize hyperparameters and obtain the optimal parameter combination for each model.

[0045] The base model is trained using the five-fold cross-validation method to obtain the prediction results {P1, P2, P3, P4, P5}, which are represented as follows:

[0046] P i =f i (x), i = 1, 2, ..., 5

[0047] Among them, P iFor the predicted TP concentration; f i (x) represents the prediction result of the i-th base model.

[0048] By training the model and integrating multiple algorithms, the model can effectively capture the complex nonlinear relationships between water quality parameters.

[0049] Furthermore, the XGBRegressor model was selected as the meta-model, and the prediction results {P1,P2,P3,P4,P5} output by the base model were used as the initial input features and input into the meta-model for training.

[0050] The predictive contribution of each base model is evaluated using the cross-validation contribution metric, which is:

[0051]

[0052] Among them, C i is the contribution score of the i-th base model; K is the cross-validation fold number; Let be the determination coefficient of the i-th base model on the k-th fold validation set; This represents the baseline performance of the meta-model on the k-th fold validation set.

[0053] Based on contribution score C i Dynamically select the optimal base model combination and calculate the weighting coefficients, retaining C. i The base model is defined by τ, where τ is a dynamic threshold, initially set to 0.05; the contribution of the base model is normalized, and its weights are calculated:

[0054]

[0055] Among them, w i S is the weighting coefficient, S is the set of optimal basis models, and T is the temperature coefficient;

[0056] The predicted results of the selected base models are weighted according to their contribution and used as the input features X of the meta-model. meta :

[0057] X meta ={w1P1,w2P2,…,w m P m}

[0058] Among them, P i Let be the predicted value of the i-th base model, and m be the number of optimal base models;

[0059] X meta The input is trained in the meta-model to obtain the final prediction result:

[0060]

[0061] in, This represents the final prediction result for TP; f meta This represents the prediction results from the meta-model.

[0062] Using the coefficient of determination (R²) 2 The optimal base model is used as the meta-model, thereby significantly improving the accuracy of water quality parameter prediction and enhancing the applicability of the model.

[0063] The present invention also provides a stacked ensemble machine learning water quality remote sensing inversion system based on model contribution self-optimization weighting, including a processing unit, wherein the processing unit executes the method described in the present invention to realize water quality remote sensing inversion.

[0064] This system, based on processing units, constructs a stacked ensemble model with self-optimizing weighted model contribution. Based on a rigorous quantification of contribution optimization strategy, it not only improves the computational efficiency of the model but also provides a more reliable solution for water quality parameter inversion under complex environments. Attached Figure Description

[0065] Figure 1 This is a flowchart illustrating the stacked ensemble machine learning method for water quality remote sensing inversion based on self-optimizing weighted model contribution, as described in this invention. Detailed Implementation

[0066] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0067] In the description of this invention, it should be understood that the terms "longitudinal", "lateral", "up", "down", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.

[0068] In the description of this invention, unless otherwise specified and limited, it should be noted that the terms "installation", "connection" and "linking" should be interpreted broadly. For example, they can refer to mechanical or electrical connections, or internal connections between two components. They can be direct connections or indirect connections through an intermediate medium. Those skilled in the art can understand the specific meaning of the above terms according to the specific circumstances.

[0069] This invention discloses a stacked ensemble machine learning method for water quality remote sensing inversion based on Model Contribution Self-optimizing Weighting (MCSW). By dynamically evaluating the predictive performance of the base models and automatically optimizing their contribution weights, it significantly reduces computational resource consumption while maintaining model accuracy, providing a new technical solution for remote sensing inversion of water quality parameters in complex water environments. Figure 1 As shown, the stacked ensemble machine learning method for water quality remote sensing inversion based on model contribution self-optimization weighting includes the following steps:

[0070] S1, using the Modified Normalized Difference Water Index (mNDWI), extracts the extent of surface water bodies, specifically:

[0071] Load Sentinel-2 Level-2A surface reflectance data into Google Earth Engine (GEE), define the study area and time range, set the cloud cover to be less than 20%, and use the mNDWI formula ((green band - infrared band) ÷ (green band + infrared band)) to calculate the mNDWI value of each pixel in the satellite image. If the mNDWI value is > 0, it is a water body, and the extent of surface water bodies can be obtained.

[0072] S2. Obtain the geographic coordinates of all automatic monitoring stations within the surface water body area and water quality monitoring data at a resolution of w hours (if using data from national control section water quality automatic monitoring stations, the sampling frequency of these stations is once every 4 hours, so a 4-hour resolution is possible; if manual sampling is used, this time depends on the data format used, and finally, a daily average value needs to be calculated to obtain daily water quality data in a unified format). This includes total phosphorus (TP) concentration and pH value. The w-hour resolution data is integrated into a daily average water quality dataset using the arithmetic mean method to ensure the temporal consistency of the data, where w is an integer greater than 1.

[0073] S3, based on the cloud cover threshold (<20%, referring to the upper limit of the percentage of cloud-covered area in a single Sentinel-2 image. When the satellite is taking pictures, there may be clouds obscuring ground objects, so a threshold is set to exclude images with severe cloud obstruction, thereby ensuring the availability of data), filters Sentinel-2 image data, selecting B2 (Blue band), B3 (Green band), B4 (Red band), B5 (Red edge 1), B6 ​​(Red edge 2), B7 (Red edge 3), B8 (NIR), and B8A (Narrow NIR).

[0074] The official bands defined by Sentinel-2 are mainly: B1, B2, B3, B4, B5, B6, B7, B8, B8A, B9, B10, B11, and B12. Band B8A is a subdivision of band B8 and is also a key band for vegetation monitoring, belonging to the surface observation bands. Band B9 is a water vapor band, specifically used for atmospheric correction and not directly for surface analysis. If B8A were named B9, it would lead to confusion in band numbering and functional classification.

[0075] Using methods such as cubic convolution, nearest neighbor, or bilinear interpolation, the B5, B6, B7, and B8A bands were resampled to a spatial resolution of 10m. The in-situ water quality monitoring data was then matched with the reflectance of the Sentinel-2 band at the corresponding spatiotemporal location (the remote sensing reflectance of the above 8 bands, which refers to the ratio of the upward propagation of water radiance (Lw) per unit area on the water surface to the incident solar irradiance (Ed) at the top of the atmosphere, which is the intensity of light reflected back from the water surface by satellite sensors and can directly reflect the characteristics of the water body itself).

[0076] S4. Pairwise combinations of B2-B8A yield 7 mathematical transformations, including Bi+Bj, Bi-Bj, Bi*Bj, Bi / Bj, (Bi-Bj) / (Bi+Bj), (Bi*Bj) / (Bi+Bj), and (Bi-Bj) / (Bi*Bj), generating 196 band combination features (based on the above 8 single bands, pairwise combinations are performed, and a total of C(8,2) = 28 band combinations are generated using the permutation and combination method. For each band, 7 mathematical transformations are applied, ultimately resulting in 28 × 7 = 196 band combinations), where i ≠ j, i = 2, 3, 4, 5, 6, 7, 8, 8A; j = 2, 3, 4, 5, 6, 7, 8, 8A;

[0077] High-correlation feature interference was eliminated through correlation analysis (threshold 0.95), and the optimal band combination was selected by recursive feature elimination and random forest algorithm (RFE-RF).

[0078] S5 uses TP concentration, pH value and optimal band combination as input variables, and divides the training set and test set in a 7:3 ratio.

[0079] The optimal hyperparameters of the base model (including linear regression, random forest, etc.) are determined by grid search, and the model is trained by five-fold cross-validation to obtain the prediction results of the base model.

[0080] Choose the coefficient of determination R 2 The optimal base model is used as the meta-model. Based on the cross-validation results, the contribution score of each base model is calculated. Base models with contribution scores exceeding a threshold are selected and weighted according to their contribution ratios to construct a new feature dataset {P1, P2, ..., P}. n The input meta-model is used for final training, and the output water quality remote sensing inversion results are used to achieve high-precision prediction of water quality parameters.

[0081] This invention establishes a universal water quality parameter inversion model based on stacked ensemble machine learning and optimizes the selection strategy of the base model in stacked ensemble machine learning.

[0082] In a preferred embodiment of the present invention, step S1 specifically involves using the difference in reflectance values ​​between target objects in different wavebands to extract the water surface range via mNDWI, ensuring that the sampling location is a water pixel:

[0083]

[0084] Where, ρ Green It is the surface reflectivity in the green light band, ρ SWIR It refers to the surface reflectivity in the shortwave infrared band;

[0085] When mNDWI>0, the pixel is classified as a water body; otherwise, it is classified as a non-water body pixel.

[0086] In a preferred embodiment of the present invention, in step S3, Sentinel-2A images are filtered based on a cloud cover threshold of <20% using the GEE MAP library in Python to remove cloud interference;

[0087] Bands B2, B3, B4, B5, B6, B7, B8, and B8A were selected and resampled to 10m spatial resolution using a cubic convolution algorithm. The BOA (Bottom-of-Atmosphere) product (a Sentinel-2 Level-2A data product representing surface reflectance, SR) has been corrected using Sen2Cor or MAJA atmospheric correction to remove atmospheric scattering (Rayleigh scattering), aerosol absorption, and water vapor effects. Dividing by π converts surface reflectance to remote sensing reflectance Rrs (sr) -1 (This is to facilitate matching with water quality parameters) Divide by π to obtain the Sentinel-2A remote sensing reflectance Rrs;

[0088] The time window is set to ±3 days. Spatiotemporal matching is performed on the in-situ water quality monitoring data within the 3-day time window before and after the satellite transit date. The in-situ water quality monitoring data is matched with the remote sensing reflectance of the Sentinel-2 band at the corresponding spatiotemporal location to ensure data synchronization.

[0089] Centered on the geographical location of the monitoring station, the mean remote sensing reflectance of the corresponding 3×3 pixel window in the Sentinel-2 image is extracted. Spatial averaging effectively reduces the uncertainty caused by pixel-scale noise and positioning error, and finally obtains a multi-band remote sensing reflectance dataset corresponding to the spatiotemporal water quality parameters.

[0090] In a preferred embodiment of the present invention, step S4 involves eliminating interference from highly correlated features through correlation analysis and using recursive feature elimination and random forest algorithm to select the optimal band combination as the model input feature.

[0091] Calculate the correlation coefficient, remove highly correlated features with a correlation coefficient greater than 0.95, and the correlation coefficient is:

[0092]

[0093] Among them, R xy Let x be the correlation coefficient between variables x and y; n be the sample size; x i y represents the value of the i-th sample in the first band combination; i This represents the value of the i-th sample in the second band combination. The mean values ​​for different bands of the Sentinel-2 image; The mean of the mathematical transformation results of Sentinel-2 images; correlation coefficient R xy Set to 0.95, when |R xy When |>0.95, redundancy is considered to exist between features;

[0094] The Recursive Feature Emission (RFE)-Random Forest algorithm is applied, using feature importance as the evaluation criterion to iteratively select the optimal band combination with the most explanatory power as the input feature of the model. The specific steps for selecting the optimal band combination as the model input feature are as follows:

[0095] The initial random forest model is trained using the band combinations remaining after removing highly correlated band combinations, and the importance score of each band combination is calculated.

[0096] Stability was verified using 5-fold cross-validation. The data was divided into 5 equal parts, and the model was trained on 4 parts in turn and tested on the remaining part. In Python, the Recursive Feature Elimination Cross-Validation (RFECV) module from the scikit-learn library was used in conjunction with a random forest regressor to obtain R0. 2 Rate and record, specifically:

[0097] Each iteration divides the data into 5 parts, uses 4 of them in turn to train the random forest model, and makes predictions on the remaining 1 part of the test set;

[0098] The coefficient of determination R is calculated by comparing the true values ​​and predicted values ​​on the test set. 2 This reflects the model's ability to explain the variance of the target variable:

[0099]

[0100] Where n is the number of samples; y i It is the true value of the i-th sample; It is the average of the sample; It is the predicted value of the i-th sample;

[0101] The final R was recorded after 5 verifications. 2 The mean is used as an indicator of the stability of this band combination. If R 2 A value close to 1 and a small variance indicate that the band combination has good and stable predictive ability.

[0102] After removing the two bands with the lowest importance scores in each iteration, the model is retrained with the remaining bands and the cross-validation process is repeated.

[0103] Continue iterating until the model is cross-validated in R. 2 The score no longer increases, and the final retained band combination is the optimal feature band combination. When the 9th band combination is reached, the model's R-value... 2 Since it is the largest, the optimal feature combination for translating total phosphorus (TP) concentration was finally determined to be a combination of 9 bands, as shown in Table 1.

[0104] Table 1 Optimal Band Combinations for TP Concentration Retrieval

[0105]

[0106] In a preferred embodiment of the present invention, in step S5, for multiple base models, including: Linear Regression, Random Forest Regressor, Extreme Gradient Boosting Regression (XGBRegressor, AdaBoostRegressor), and Decision Tree Regressor, Grid Search is used to optimize hyperparameters to obtain the optimal parameter combination for each model, as shown in Table 2.

[0107] Table 2. Hyperparameters of each base model in TP prediction.

[0108]

[0109] The base model is trained using the five-fold cross-validation method to obtain the prediction results {P1, P2, P3, P4, P5}, which are represented as follows:

[0110] P i =f i (x), i = 1, 2, ..., 5

[0111] Among them, P i For the predicted TP concentration; f i (x) represents the prediction result of the i-th base model.

[0112] Five representative regression models were selected as base models, including Linear Regression (LR), Random Forest (RF), Extreme Gradient Boosting (XGBRegressor, XGBoost), Adaptive Boosting (AdaBoostRegressor, AdaBoost), and Decision Tree (DT).

[0113] By integrating these five algorithms, the model can effectively capture the complex nonlinear relationships between water quality parameters.

[0114] In addition, the coefficient of determination (R²) is used. 2 The optimal base model is used as the meta-model, thereby significantly improving the accuracy of water quality parameter prediction and enhancing the applicability of the model.

[0115] In a preferred embodiment of the present invention, the XGBRegressor model is selected as the meta-model, and the prediction results {P1,P2,P3,P4,P5} output by the base model are used as initial input features and input into the meta-model for training.

[0116] To improve the performance of the meta-model and the computational efficiency of the stacked model, the cross-validation contribution metric is used to evaluate the predictive contribution of each base model, as follows:

[0117]

[0118] Among them, C i is the contribution score of the i-th base model; K is the cross-validation fold number; Let be the determination coefficient of the i-th base model on the k-th fold validation set; This represents the baseline performance of the meta-model on the k-th fold validation set.

[0119] Based on contribution score C i The optimal base model combination is dynamically selected (XGBRegressorRandomForestRegressor and DecisionTreeRegressor can be ultimately selected as the final base models) and weighted coefficients are calculated, retaining C. i The base model is defined by τ, where τ is a dynamic threshold, initially set to 0.05; the contribution of the base model is normalized, and its weights are calculated:

[0120]

[0121] Among them, w i Here, S is the weighting coefficient, S is the set of optimal base models, and T is the temperature coefficient, with a default value of 0.01.

[0122] The predicted results of the selected base models are weighted according to their contribution and used as the input features X of the meta-model. meta :

[0123] X meta ={w1P1,w2P2,…,w m P m}

[0124] Among them, P i Let be the predicted value of the i-th base model, and m be the number of optimal base models;

[0125] X meta The input is trained in the meta-model to obtain the final prediction result:

[0126]

[0127] in, This represents the final prediction result for TP; f meta This represents the prediction results from the meta-model.

[0128] The dynamic optimization method based on model contribution quantifies the actual contribution of each base model to the integrated framework to achieve intelligent combination screening. By establishing a model contribution evaluation system, a dynamic contribution threshold is used for preliminary screening, and then the synergistic contribution effect of each model combination is evaluated. Finally, based on the principle of optimal contribution, a water quality parameter prediction model with high accuracy and high interpretability is constructed.

[0129] The accuracy of the inverted TP concentration was verified by using the same dataset to evaluate the accuracy of stacked ensemble machine learning, random forest, extreme gradient boosting, and the proposed stacked ensemble model based on model contribution self-optimization weighting. The coefficient of determination (R²) was selected. 2 The prediction accuracy of each model is evaluated using metrics such as root mean square error (RMSE) and mean absolute error (MAE). The formulas for calculating each evaluation metric are as follows:

[0130]

[0131] Where n is the number of samples; y i It is the true value of the i-th sample; It is the average of the sample; R is the predicted value of the i-th sample; 2 The larger the value of , and the smaller the values ​​of MAE and RMSE, the better the model fits.

[0132] This invention also provides a stacked ensemble machine learning water quality remote sensing inversion system based on self-optimizing weighted model contribution, comprising a processing unit that executes the method described in this invention to achieve water quality remote sensing inversion. The processing unit includes a stacked ensemble machine learning (EL) framework and a dynamic contribution evaluation (DCE) module. Based on a rigorous contribution quantification optimization strategy, it not only improves the computational efficiency of the model but also provides a more reliable solution for water quality parameter inversion under complex environments.

[0133] By implementing multi-level feature learning through the EL framework and combining it with the DCE module to quantify and optimize the prediction contribution of the base model in real time, the accuracy and stability of water quality parameter concentration inversion from remote sensing images are significantly improved, thereby enabling large-scale water quality monitoring and demonstrating excellent applicability in complex water environments.

[0134] This invention proposes a stacked ensemble model (MCSW) based on self-optimizing weighted model contribution, used for remote sensing inversion of total phosphorus concentration in inland water bodies. Its R... 2The accuracy reached 0.8747, which is an improvement of 0.006-0.056 compared to the traditional model. This model can effectively improve the remote sensing inversion accuracy of TP concentration in inland water bodies.

[0135] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0136] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

Claims

1. A stacked ensemble machine learning method for water quality remote sensing inversion based on self-optimizing weighted model contribution, characterized in that, Includes the following steps: S1, using the modified normalized water index mNDWI, to extract the extent of surface water bodies; S2, acquire the geographic coordinates of all automatic monitoring stations within the surface water body and water quality monitoring data at a resolution of w hours, including total phosphorus (TP) concentration and pH value, and integrate the w-hour resolution data into a daily average water quality dataset using the arithmetic mean method, where w is an integer greater than 1; S3. Based on cloud cover thresholds, Sentinel-2 image data were filtered, selecting B2 (Blue), B3 (Green), B4 (Red), B5 (Red edge 1), B6 ​​(Red edge 2), B7 (Red edge 3), B8 (NIR), and B8A (Narrow NIR). The B5, B6, B7, and B8A bands were resampled to a spatial resolution of 10m, and the in-situ water quality monitoring data were matched with the reflectance of the Sentinel-2 band at the corresponding spatiotemporal locations. S4. By combining B2-B8A in pairs, seven mathematical transformations are obtained, including Bi+Bj, Bi-Bj, Bi*Bj, Bi / Bj, (Bi-Bj) / (Bi+Bj), (Bi*Bj) / (Bi+Bj), and (Bi-Bj) / (Bi*Bj), generating 196 band combination features, where i≠j, i=2,3,4,5,6,7,8,8A; j=2,3,4,5,6,7,8,8A; Correlation analysis was used to eliminate interference from highly correlated features, and recursive feature elimination and random forest algorithms were employed to select the optimal band combination. S5 uses TP concentration, pH value and optimal band combination as input variables, and divides the training set and test set in a 7:3 ratio. The optimal hyperparameters of the base model are determined by grid search, and the model is trained using five-fold cross-validation to obtain the prediction results of the base model. Choose the coefficient of determination R 2 The optimal base model is used as the meta-model. Based on the cross-validation results, the contribution score of each base model is calculated. Base models with contribution scores exceeding the threshold are selected and weighted according to their contribution ratios to construct a new feature dataset. This dataset is then input into the meta-model for final training, and the water quality remote sensing inversion results are output.

2. The water quality remote sensing inversion method based on self-optimizing weighted stacked ensemble machine learning according to claim 1, characterized in that, Step S1 specifically involves using the difference in reflectance values ​​between target objects in different bands to extract the water surface area via mNDWI, ensuring that the sampling location is a water pixel: Where, ρ Green It is the surface reflectivity in the green light band, ρ SWIR It refers to the surface reflectivity in the shortwave infrared band; When mNDWI>0, the pixel is classified as a water body; otherwise, it is classified as a non-water body pixel.

3. The water quality remote sensing inversion method based on self-optimizing weighted stacked ensemble machine learning according to claim 1, characterized in that, In step S3, based on the GEE MAP library in Python, the Sentinel-2A image is filtered by setting a cloud cover threshold of <20% to remove cloud interference; Bands B2, B3, B4, B5, B6, B7, B8, and B8A were selected, and a cubic convolution algorithm was used to resample these bands to a spatial resolution of 10m. The Sentinel-2A remote sensing reflectance Rrs was obtained by dividing the atmospheric bottom reflectance (BOA) product by π. A time window of ±3 days was set, and in-situ water quality monitoring data within the 3-day time window before and after the satellite's transit date were spatiotemporally matched. The in-situ water quality monitoring data were matched with the remote sensing reflectance of the Sentinel-2 band at the corresponding spatiotemporal location to ensure data synchronization. Centered on the geographical location of the monitoring station, the mean remote sensing reflectance of the corresponding 3×3 pixel window in the Sentinel-2 image is extracted. Spatial averaging effectively reduces the uncertainty caused by pixel-scale noise and positioning error, and finally obtains a multi-band remote sensing reflectance dataset corresponding to the spatiotemporal water quality parameters.

4. The water quality remote sensing inversion method based on self-optimizing weighted stacked ensemble machine learning according to claim 1, characterized in that, Step S4 involves eliminating interference from highly correlated features through correlation analysis and using recursive feature elimination and random forest algorithms to select the optimal band combination as the model input features. Calculate the correlation coefficient, remove highly correlated features with a correlation coefficient greater than 0.95, and the correlation coefficient is: Among them, R xy Let x be the correlation coefficient between variables x and y; n be the sample size; x i y represents the value of the i-th sample in the first band combination; i This represents the value of the i-th sample in the second band combination. The mean values ​​for different bands of the Sentinel-2 image; The mean of the mathematical transformation results of Sentinel-2 images; correlation coefficient R xy Set to 0.95, when |R xy When |>0.95, redundancy is considered to exist between features; The Recursive Feature Emission (RFE)-Random Forest algorithm is applied to select the optimal band combination as the model input features, specifically: The initial random forest model is trained using the band combinations remaining after removing highly correlated band combinations, and the importance score of each band combination is calculated. Stability was verified using 5-fold cross-validation. The data was divided into 5 equal parts, and the model was trained on 4 parts in turn and tested on the remaining part. In Python, the Recursive Feature Elimination Cross-Validation (RFECV) module from the scikit-learn library was used in conjunction with a random forest regressor to obtain R0. 2 Rate and record, specifically: Each iteration divides the data into 5 parts, uses 4 of them in turn to train the random forest model, and makes predictions on the remaining 1 part of the test set; The coefficient of determination R is calculated by comparing the true values ​​and predicted values ​​on the test set. 2 This reflects the model's ability to explain the variance of the target variable: Where n is the number of samples; y i It is the true value of the i-th sample; It is the average of the sample; It is the predicted value of the i-th sample; The final R was recorded after 5 verifications. 2 The mean is used as an indicator of the stability of this band combination. If R 2 A value close to 1 and a small variance indicate that the band combination has good and stable predictive ability. After removing the two bands with the lowest importance scores in each iteration, the model is retrained with the remaining bands and the cross-validation process is repeated. Continue iterating until the model is cross-validated in R. 2 The score no longer increases, and the final retained band combination is the optimal feature band combination. When the 9th band combination is reached, the model's R-value... 2 The largest is the total phosphorus (TP) concentration, so the best characteristic combination for the inversion of total phosphorus (TP) concentration was finally determined to be a combination of 9 bands.

5. The water quality remote sensing inversion method based on self-optimizing weighted stacked ensemble machine learning according to claim 1, characterized in that, In step S5, for various base models, including linear regression, random forest regression, extreme gradient boosting regression, and decision tree regression, grid search is used to optimize hyperparameters and obtain the optimal parameter combination for each model. The base model is trained using the five-fold cross-validation method to obtain the prediction results {P1, P2, P3, P4, P5}, which are represented as follows: P i =f i (x),i=1,2,...,5 Among them, P i For the predicted TP concentration; f i (x) represents the prediction result of the i-th base model.

6. The water quality remote sensing inversion method based on self-optimizing weighted stacked ensemble machine learning according to claim 5, characterized in that, The XGBRegressor model was selected as the meta-model, and the prediction results {P1,P2,P3,P4,P5} output by the base model were used as the initial input features and input into the meta-model for training. The predictive contribution of each base model is evaluated using the cross-validation contribution metric, which is: Among them, C i is the contribution score of the i-th base model; K is the cross-validation fold number; Let be the determination coefficient of the i-th base model on the k-th fold validation set; This represents the baseline performance of the meta-model on the k-th fold validation set. Based on contribution score C i Dynamically select the optimal base model combination and calculate the weighting coefficients, retaining C. i The base model is defined by τ, where τ is a dynamic threshold, initially set to 0.05; the contribution of the base model is normalized, and its weights are calculated: Among them, w i S is the weighting coefficient, S is the set of optimal basis models, and T is the temperature coefficient; The predicted results of the selected base models are weighted according to their contribution and used as the input features X of the meta-model. meta : X meta ={w1P1,w2P2,…,w m P m } Among them, P i Let be the predicted value of the i-th base model, and m be the number of optimal base models; X meta The input is trained in the meta-model to obtain the final prediction result: in, This represents the final prediction result for TP; f meta This represents the prediction results from the meta-model.

7. A stacked ensemble machine learning water quality remote sensing inversion system based on model contribution self-optimization weighting, characterized in that, The system includes a processing unit that performs the method described in any one of claims 1-6 to achieve water quality remote sensing inversion.

Citation Information

Cited By

  • Water body nutritive salt remote sensing inversion method based on multi-source fusion and machine learning model

    CN121765197A