Method for predicting total number of bacterial colonies in water body based on multi-source data spatial heterogeneous random forest
By constructing a spatially heterogeneous random forest model based on multi-source data and integrating data from water quality, meteorology, and land use, the problem of rapid and accurate prediction of total bacterial count in water bodies was solved, thereby improving the management capability of microbial pollution risk in water sources.
Patent Information
- Application Number
- CN202610017097.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-07
- Publication Date
- 2026-02-03
AI Technical Summary
Existing water quality monitoring systems cannot quickly and accurately predict the total number of bacterial colonies in water bodies. Traditional regression models have limited applicability and are difficult to effectively integrate multi-source data and spatial heterogeneity factors, affecting the rapid identification and emergency response to microbial pollution in water sources.
We employ a spatial heterogeneous random forest method based on multi-source data to integrate data on water quality, meteorology, and land use, and construct a robust prediction model for total bacterial count in water bodies. The prediction accuracy is improved by quantifying spatial heterogeneity.
It enables rapid and accurate prediction of total bacterial count in water bodies, provides convenient management basis, and improves the reliability and practicality of risk control for microbial pollution in water sources.
Smart Images

Figure CN121459952A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of water quality monitoring and treatment technology, specifically relating to a method for predicting the total number of bacterial colonies in forest water bodies based on spatially heterogeneous random forest data from multiple sources. Background Technology
[0002] Total bacterial count in water bodies is a crucial microbiological indicator for evaluating water quality and safety, directly reflecting the degree of pathogenic microorganism contamination. Accurate prediction of the total bacterial count in water sources is essential for ensuring drinking water safety and preventing water source pollution. While existing water quality monitoring systems can detect various physicochemical parameters in real time, such as pH, turbidity, ammonia nitrogen, dissolved oxygen, and permanganate index, the determination of microbiological indicators, such as the total bacterial count, still largely relies on traditional laboratory culture methods. This method is cumbersome and time-consuming, typically requiring 24–48 hours to obtain a relatively accurate total bacterial count. This lag restricts the rapid identification and emergency response capabilities for microbial contamination in water sources. Therefore, it is necessary to develop a convenient and rapid method for predicting the total bacterial count in water sources to strengthen water source management and ensure water supply safety.
[0003] The distribution of total bacterial count in water sources typically exhibits skewed characteristics. Traditional regression models, limited by their strict data distribution assumptions, have relatively limited applicability and often produce poor predictive results. Random forests, as an ensemble learning algorithm, possess excellent anti-overfitting capabilities and high-dimensional data processing capabilities, and have demonstrated advantages in environmental prediction, making them a preferred framework for predicting total bacterial count in water sources. However, for the specific scenario of total bacterial count in water sources, how to effectively integrate multi-source data, including water quality, meteorological, and land use characteristics, and explicitly incorporate spatial heterogeneity factors to construct a robust and accurate model still requires further consideration. Therefore, it is necessary to clarify key input features and, by quantifying spatial heterogeneity and embedding it into the random forest framework, develop a multi-source data fusion spatial machine learning method for predicting total bacterial count in water sources. This would enable rapid and accurate prediction of total bacterial count in water sources, providing technical support for drinking water safety management. Summary of the Invention
[0004] To address the aforementioned issues, this invention proposes a method for predicting the total number of bacterial colonies in forest water bodies based on spatially heterogeneous random forest water bodies using multi-source data. This method possesses excellent high-dimensional data processing capabilities and can capture complex correlations between multidimensional variables, thereby improving the accuracy of predicting the total number of bacterial colonies in water bodies. It provides a convenient and rapid management basis for the risk control of microbial pollution in water sources and is both reliable and practical.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: A method for predicting the total number of bacterial colonies in forest water bodies based on spatially heterogeneous random forest data from multiple sources includes the following steps: S1. Collect long-term daily water quality data from multiple water sources in the region and preprocess the daily water quality data; S2. Collect daily meteorological data for the corresponding period in the districts and counties where each water source is located, and preprocess the daily meteorological data. S3. Obtain the area of different land use types within a 5km upstream watershed of each water source intake; S4. Supplement the spatial information of water sources and synthesize a multi-source dataset covering total bacterial count in water bodies, water source type, water quality physicochemical indicators, meteorological indicators, land use indicators, and spatially heterogeneous indicators; S5. Construct a spatially heterogeneous random forest regression model framework, using the total number of water colonies in the multi-source dataset synthesized in step S4 as the dependent variable and other indicators as independent variables, train the regression prediction model for the total number of water colonies in the water source, and then use the trained regression prediction model for the total number of water colonies to predict the total number of water colonies.
[0006] Preferably, in step S1, the daily water quality monitoring data includes total bacterial count data, ammonia nitrogen data, turbidity data, and permanganate index data; in step S2, the daily meteorological data includes average daily temperature data and average daily rainfall data.
[0007] Preferably, in step S1, the preprocessing of the daily water quality monitoring data specifically includes: S11. Conduct quality control on daily water quality test data. Quality control includes removing abnormal data by type, abnormal data by value, and duplicate data. S12. Take the logarithm of the total number of bacterial colonies in the water body in the daily water quality test data, and assign 0 to the original value or the value of not detected. S13. Remove daily observation samples where any indicator has a null value after processing in steps S11 and S12. In step S2, the preprocessing of the daily meteorological data specifically includes: S21. Perform quality control on daily meteorological data. Quality control includes removing abnormal data by type, abnormal data by value, and duplicate data. S22. Perform missing value processing on daily meteorological data. The missing value processing adopts multiple imputation method to fill missing values. By establishing multiple reasonable imputation models, several sets of complete datasets are generated. The imputation results of each set are comprehensively evaluated and the optimal estimate is merged to obtain the filled value and complete the missing value filling.
[0008] Preferably, in steps S11 and S21, the removal of abnormal data by type involves removing non-numerical data, where non-numerical data includes characters and null values; the removal of abnormal numerical data involves removing data that exceeds a set numerical range; and the removal of duplicate data involves removing data with duplicate timestamps.
[0009] Preferably, the specific process of step S3 is as follows: S31. Obtain DEM data around the water intake and generate river network vector data based on the DEM data; where DEM data refers to digital elevation model. S32. Based on the characteristics of river network vector data and combined with the coordinate location of the water intake, generate vector data of the watershed area 5 km upstream of the water intake; S33. Obtain land use data around the water intake, use the generated vector data of the watershed 5 km upstream of the water intake to crop the land use data, and count the area of different land use types in the cropped area.
[0010] Preferably, in step S3, the areas of the different land use types include water area, forest area, cultivated land area, submerged vegetation area, construction land area, bare land area, and pasture area.
[0011] Preferably, the specific process of step S31 is as follows: S311. Fill depressions in the DEM data around the water intake. S312. Use the DEM data after depression filling to generate flow direction and flow rate; S313. Extract the raster river network according to the condition that the flow rate is > 500, and vectorize the extracted raster river network to generate river network vector data containing the vector river network. The specific process of step S32 is as follows: S321. Using proximity analysis tools and combining them with the actual terrain, the water intake point is located on the vector river network generated in step S313. S322. Select the river network upstream of the point and generate raster data of the catchment area with the water intake as the water collection point; S323. Convert the raster-format water collection area generated in step S322 into a vector surface, and merge the sub-water collection areas in the vector surface. S324. Establish a buffer zone with a radius of 5 km centered on the water intake. Use the buffer zone trimming step S323 to merge the water catchment area vector surface to obtain the vector data of the watershed range 5 km upstream of each water intake.
[0012] Preferably, in step S4, the process of supplementing the spatial information of water sources involves generating a unique number for each water source and adding the number and the latitude and longitude coordinates of each water source to the daily data sample as the spatial heterogeneity index in the multi-source dataset.
[0013] Preferably, the specific process of step S5 is as follows: S51. Based on the random forest machine learning algorithm framework, a spatial heterogeneity explanation is introduced to construct a spatial heterogeneous random forest regression model framework. S52. The multi-source dataset synthesized in step S4 is divided using the five-fold cross-validation method. The synthesized multi-source dataset is divided into 5 equal parts, and the five-fold cross-validation is repeated in turn. In each round, 1 part of the multi-source dataset is selected as the test set, and the other data is aggregated as the training set. S53. The spatial heterogeneous random forest regression model is trained using training set data. The total number of water colonies is used as the dependent variable, and the water source type, water quality physicochemical indicators, meteorological indicators, land use indicators, and spatial heterogeneous indicators are used as explanatory variables. The grid search method is used for hyperparameter tuning to realize the construction of a regression prediction model for the total number of water colonies based on multi-source data spatial heterogeneous random forest. S54. The performance of the trained water body total bacterial count regression prediction model is evaluated by mean absolute error, mean square error, and coefficient of determination. The hyperparameters of the water body total bacterial count regression prediction model are adjusted by selecting the hyperparameter combination with the best model performance. S55. Apply the trained water body total bacterial count regression prediction model to the corresponding water intake. Take the same steps every day to preprocess the water quality physicochemical data and meteorological data, and combine them with the water source type, land use data and spatial heterogeneous indicators as explanatory variables to input into the water body total bacterial count regression prediction model. The output result is the logarithm of the daily water body total bacterial count at the water intake, with the base 10. S56. Using the output of step S55, perform an exponential calculation with base 10 to obtain the predicted value of the total number of bacterial colonies in the water body of the water source each day.
[0014] Preferably, in step S5, the calculation formula for the spatial heterogeneous random forest regression model framework is as follows: , , , , ,in, Let be the response variable, representing the total colony count observed in the i-th sample; i is the sample number. Represents the response variable Y i Follows the mean μ i variance is The normal distribution; μ i The conditional mean parameter of the response variable distribution; The variance of the model residuals; This is a fixed effect; Calculated for the random forest model; Let be the water quality indicator feature vector for the i-th sample, which includes three sub-features: ammonia nitrogen data, turbidity data, and permanganate index data. The water source type for the i-th sample; Let be the meteorological indicator feature vector of the i-th sample, which covers two sub-features: daily average temperature and daily average rainfall. The land use index feature vector for the i-th sample covers seven sub-features: water area, forest area, cultivated land area, submerged vegetation area, construction land area, bare land area, and pasture area. Spatial random effects; Let b be a vector with elements b1, b2, ... b n These represent the unique spatial random effects values of the 1st to nth water sources; T is the matrix transpose symbol. The spatial random effects vector follows a pattern with a mean of 0 and a covariance matrix of... The multivariate normal distribution; Let be the covariance matrix formed by the interrelationships among all n water sources; Variance represents the spatial variation of the overall random effect. This is a spatial correlation matrix, with values ranging from [0,1], representing the spatial correlation between different water sources; Spatial correlation matrix The Middle j The element in the k-th row represents the spatial correlation strength between water source j and water source k; This refers to the spatial decay rate parameter; Let be the Euclidean distance between sampling point j and sampling point k calculated using the spatial coordinates of the water source; j is sampling point j; k is sampling point k.
[0015] After adopting the above technical solution, the present invention has the following beneficial effects: The spatial heterogeneous random forest water colony total count prediction method based on multi-source data is direct and effective. In model feature selection, it integrates weather data, water quality physicochemical data, and land use data, and explicitly incorporates spatial heterogeneity considerations, thus possessing good interpretability for water colony total count. During the data quality control stage, outlier identification and missing value imputation reduce the impact of abnormal data on model construction and accuracy evaluation. Furthermore, as a multi-source data fusion spatial machine learning algorithm, the present invention outperforms traditional regression models in predicting water colony total count. It has excellent high-dimensional data processing capabilities, can capture complex correlations between multidimensional variables, thereby improving the accuracy of water colony total count prediction. This provides a convenient and rapid management basis for the risk control of microbial pollution in water sources, demonstrating reliability and practicality. Attached Figure Description
[0016] Figure 1 This is a flowchart of the present invention. Detailed Implementation
[0017] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0018] like Figure 1 As shown, the method for predicting the total number of bacterial colonies in water bodies of spatially heterogeneous random forests based on multi-source data includes the following steps: S1. Collect long-term daily water quality data from multiple water sources in the region and preprocess the daily water quality data; In step S1, the daily water quality test data includes total bacterial count data, ammonia nitrogen data, turbidity data, and permanganate index data. In step S1, the preprocessing of the daily water quality monitoring data specifically includes: S11. Perform quality control on daily water quality test data. Quality control includes removing abnormal data by type, abnormal data by value, and duplicate data. S12. Take the logarithm of the total number of bacterial colonies in the water body in the daily water quality test data, and assign 0 to the original value or the value of not detected. S13. Remove daily observation samples where any indicator has a null value after processing in steps S11 and S12. S2. Collect daily meteorological data for the corresponding period in the districts and counties where each water source is located, and preprocess the daily meteorological data; In step S2, the daily meteorological data includes daily average temperature data and daily average rainfall data; In step S2, the preprocessing of the daily meteorological data specifically includes: S21. Perform quality control on daily meteorological data. Quality control includes removing abnormal data by type, abnormal data by value, and duplicate data. S22. Perform missing value processing on daily meteorological data. The missing value processing adopts multiple imputation method to fill missing values. By establishing multiple reasonable imputation models, several sets of complete datasets are generated. The imputation results of each set are comprehensively evaluated and the optimal estimate is merged to obtain the filled value and complete the missing value filling. In steps S11 and S21, removing abnormal data by type means removing non-numerical data, where non-numerical data includes characters and null values; removing abnormal numerical data means removing data that exceeds a set numerical range; removing duplicate data means removing data with duplicate timestamps. S3. Obtain the area of different land use types within a 5km upstream watershed of each water source intake; The specific process of step S3 is as follows: S31. Obtain DEM data around the water intake and generate river network vector data based on the DEM data; where DEM data refers to digital elevation model. The specific process of step S31 is as follows: S311. Fill depressions in the DEM data around the water intake. S312. Use the DEM data after depression filling to generate flow direction and flow rate; S313. Extract the raster river network according to the condition that the flow rate is > 500, and vectorize the extracted raster river network to generate river network vector data containing the vector river network. S32. Based on the characteristics of river network vector data and combined with the coordinate location of the water intake, generate vector data of the watershed area 5 km upstream of the water intake; The specific process of step S32 is as follows: S321. Using proximity analysis tools and combining them with the actual terrain, the water intake point is located on the vector river network generated in step S313. S322. Select the river network upstream of the point and generate raster data of the catchment area with the water intake as the water collection point; S323. Convert the raster-format water collection area generated in step S322 into a vector surface, and merge the sub-water collection areas in the vector surface. S324. Establish a buffer zone with a radius of 5 km centered on the water intake. Use the buffer zone to cut the merged water catchment vector surface in step S323 to obtain the vector data of the watershed range 5 km upstream of each water intake. S33. Obtain land use data around the water intake, use the generated vector data of the watershed range 5 km upstream of the water intake to crop the land use data, and count the area of different land use types in the cropped area. In step S3, the areas of the different land use types include water area, forest area, cultivated land area, submerged vegetation area, construction land area, bare land area, and pasture area; S4. Supplement the spatial information of water sources and synthesize a multi-source dataset covering total bacterial count in water bodies, water source type, water quality physicochemical indicators, meteorological indicators, land use indicators, and spatially heterogeneous indicators; In step S4, the process of supplementing the spatial information of water sources involves generating a unique number for each water source and adding the number and the latitude and longitude coordinates of each water source to the daily data sample as the spatial heterogeneity index in the multi-source dataset. S5. Construct a spatial heterogeneous random forest regression model framework, using the total number of water colonies in the multi-source dataset synthesized in step S4 as the dependent variable and other indicators as independent variables, train the water colony total number regression prediction model, and then use the trained water colony total number regression prediction model to predict the total number of water colonies. The specific process of step S5 is as follows: S51. Based on the random forest machine learning algorithm framework, a spatial heterogeneity explanation is introduced to construct a spatial heterogeneous random forest regression model framework. S52. The multi-source dataset synthesized in step S4 is divided using the five-fold cross-validation method. The synthesized multi-source dataset is divided into 5 equal parts, and the five-fold cross-validation is repeated in turn. In each round, 1 part of the multi-source dataset is selected as the test set, and the other data is aggregated as the training set. S53. The spatial heterogeneous random forest regression model is trained using training set data. The total number of water colonies is used as the dependent variable, and the water source type, water quality physicochemical indicators, meteorological indicators, land use indicators, and spatial heterogeneous indicators are used as explanatory variables. The grid search method is used for hyperparameter tuning to realize the construction of a regression prediction model for the total number of water colonies based on multi-source data spatial heterogeneous random forest. S54. The performance of the trained water body total bacterial count regression prediction model is evaluated by mean absolute error, mean square error, and coefficient of determination. The hyperparameters of the water body total bacterial count regression prediction model are adjusted by selecting the hyperparameter combination with the best model performance. S55. Apply the trained water body total bacterial count regression prediction model to the corresponding water intake. Take the same steps every day to preprocess the water quality physicochemical data and meteorological data, and combine them with the water source type, land use data and spatial heterogeneous indicators as explanatory variables to input into the water body total bacterial count regression prediction model. The output result is the logarithm of the daily water body total bacterial count at the water intake, with the base 10. S56. Using the output of step S55, perform an exponential calculation with base 10 to obtain the predicted value of the total number of bacterial colonies in the water body of the water source every day. In step S5, the calculation formula for the spatial heterogeneous random forest regression model framework is as follows: , , , , ,in, Let be the response variable, representing the total colony count observed in the i-th sample; i is the sample number. Represents the response variable Y i Follows the mean μ i variance is The normal distribution; μ i The conditional mean parameter of the response variable distribution; The variance of the model residuals; This is a fixed effect; Calculated for the random forest model; Let be the water quality indicator feature vector for the i-th sample, which includes three sub-features: ammonia nitrogen data, turbidity data, and permanganate index data. The water source type for the i-th sample; Let be the meteorological indicator feature vector of the i-th sample, which covers two sub-features: daily average temperature and daily average rainfall. The land use index feature vector for the i-th sample covers seven sub-features: water area, forest area, cultivated land area, submerged vegetation area, construction land area, bare land area, and pasture area. Spatial random effects; Let b be a vector with elements b1, b2, ... b n These represent the unique spatial random effects values of the 1st to nth water sources; T is the matrix transpose symbol. The spatial random effects vector follows a pattern with a mean of 0 and a covariance matrix of... The multivariate normal distribution; Let be the covariance matrix formed by the interrelationships among all n water sources; Variance represents the spatial variation of the overall random effect. This is a spatial correlation matrix, with values ranging from [0,1], representing the spatial correlation between different water sources; Spatial correlation matrix The Middle j The element in the k-th row represents the spatial correlation strength between water source j and water source k; This refers to the spatial decay rate parameter; Let be the Euclidean distance between sampling point j and sampling point k calculated using the spatial coordinates of the water source; j is sampling point j; k is sampling point k.
[0019] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for predicting the total number of bacterial colonies in forest water bodies based on spatially heterogeneous random forest data from multiple sources, characterized in that: Includes the following steps: S1. Collect long-term daily water quality data from multiple water sources in the region and preprocess the daily water quality data; S2. Collect daily meteorological data for the corresponding period in the districts and counties where each water source is located, and preprocess the daily meteorological data. S3. Obtain the area of different land use types within a 5km upstream watershed of each water source intake; S4. Supplement the spatial information of water sources and synthesize a multi-source dataset covering total bacterial count in water bodies, water source type, water quality physicochemical indicators, meteorological indicators, land use indicators, and spatially heterogeneous indicators; S5. Construct a spatially heterogeneous random forest regression model framework, using the total number of water colonies in the multi-source dataset synthesized in step S4 as the dependent variable and other indicators as independent variables, train the regression prediction model for the total number of water colonies in the water source, and then use the trained regression prediction model for the total number of water colonies to predict the total number of water colonies.
2. The method for predicting the total number of bacterial colonies in forest water bodies based on spatially heterogeneous random forest data as described in claim 1, characterized in that, In step S1, the daily water quality monitoring data includes total bacterial count, ammonia nitrogen, turbidity, and permanganate index data; in step S2, the daily meteorological data includes average daily temperature and average daily rainfall data.
3. The method for predicting the total number of bacterial colonies in forest water bodies based on spatially heterogeneous random forest data as described in claim 2, characterized in that, In step S1, the preprocessing of the daily water quality monitoring data specifically includes: S11. Conduct quality control on daily water quality test data. Quality control includes removing abnormal data by type, abnormal data by value, and duplicate data. S12. Take the logarithm of the total number of bacterial colonies in the water body in the daily water quality test data, and assign 0 to the original value or the value of not detected. S13. Remove daily observation samples where any indicator has a null value after processing in steps S11 and S12. In step S2, the preprocessing of the daily meteorological data specifically includes: S21. Perform quality control on daily meteorological data. Quality control includes removing abnormal data by type, abnormal data by value, and duplicate data. S22. Perform missing value processing on daily meteorological data. The missing value processing adopts multiple imputation method to fill missing values. By establishing multiple reasonable imputation models, several sets of complete datasets are generated. The imputation results of each set are comprehensively evaluated and the optimal estimate is merged to obtain the filled value and complete the missing value filling.
4. The method for predicting the total number of bacterial colonies in forest water bodies based on spatially heterogeneous random forest data as described in claim 3, characterized in that: In steps S11 and S21, removing abnormal data by type means removing non-numerical data, where non-numerical data includes characters and null values; removing abnormal numerical data means removing data that exceeds a set numerical range; and removing duplicate data means removing data with duplicate timestamps.
5. The method for predicting the total number of bacterial colonies in forest water bodies based on spatially heterogeneous random forest data as described in claim 1, characterized in that, The specific process of step S3 is as follows: S31. Obtain DEM data around the water intake and generate river network vector data based on the DEM data; where DEM data refers to digital elevation model. S32. Based on the characteristics of river network vector data and combined with the coordinate location of the water intake, generate vector data of the watershed area 5 km upstream of the water intake; S33. Obtain land use data around the water intake, use the generated vector data of the watershed 5 km upstream of the water intake to crop the land use data, and count the area of different land use types in the cropped area.
6. The method for predicting the total number of bacterial colonies in forest water bodies based on spatially heterogeneous random forest data as described in claim 1, characterized in that: In step S3, the areas of the different land use types include water area, forest area, cultivated land area, submerged vegetation area, construction land area, bare land area, and pasture area.
7. The method for predicting the total number of bacterial colonies in forest water bodies based on spatially heterogeneous random forest data as described in claim 5, characterized in that, The specific process of step S31 is as follows: S311. Fill depressions in the DEM data around the water intake. S312. Use the DEM data after depression filling to generate flow direction and flow rate; S313. Extract the raster river network according to the condition that the flow rate is > 500, and vectorize the extracted raster river network to generate river network vector data containing the vector river network. The specific process of step S32 is as follows: S321. Using proximity analysis tools and combining them with the actual terrain, the water intake point is located on the vector river network generated in step S313. S322. Select the river network upstream of the point and generate raster data of the catchment area with the water intake as the water collection point; S323. Convert the raster-format water collection area generated in step S322 into a vector surface, and merge the sub-water collection areas in the vector surface. S324. Establish a buffer zone with a radius of 5 km centered on the water intake. Use the buffer zone trimming step S323 to merge the water catchment area vector surface to obtain the vector data of the watershed range 5 km upstream of each water intake.
8. The method for predicting the total number of bacterial colonies in forest water bodies based on spatially heterogeneous random forest data as described in claim 1, characterized in that: In step S4, the process of supplementing the spatial information of water sources involves generating a unique number for each water source and adding the number and the latitude and longitude coordinates of each water source to the daily data sample as the spatial heterogeneity index in the multi-source dataset.
9. The method for predicting the total number of bacterial colonies in forest water bodies based on spatially heterogeneous random forest data as described in claim 1, characterized in that, The specific process of step S5 is as follows: S51. Based on the random forest machine learning algorithm framework, a spatial heterogeneity explanation is introduced to construct a spatial heterogeneous random forest regression model framework. S52. The multi-source dataset synthesized in step S4 is divided using the five-fold cross-validation method. The synthesized multi-source dataset is divided into 5 equal parts, and the five-fold cross-validation is repeated in turn. In each round, 1 part of the multi-source dataset is selected as the test set, and the other data is aggregated as the training set. S53. The spatial heterogeneous random forest regression model is trained using training set data. The total number of water colonies is used as the dependent variable, and the water source type, water quality physicochemical indicators, meteorological indicators, land use indicators, and spatial heterogeneous indicators are used as explanatory variables. The grid search method is used for hyperparameter tuning to realize the construction of a regression prediction model for the total number of water colonies based on multi-source data spatial heterogeneous random forest. S54. The performance of the trained water body total bacterial count regression prediction model is evaluated by mean absolute error, mean square error, and coefficient of determination. The hyperparameters of the water body total bacterial count regression prediction model are adjusted by selecting the hyperparameter combination with the best model performance. S55. Apply the trained water body total bacterial count regression prediction model to the corresponding water intake. Take the same steps every day to preprocess the water quality physicochemical data and meteorological data, and combine them with the water source type, land use data and spatial heterogeneous indicators as explanatory variables to input into the water body total bacterial count regression prediction model. The output result is the logarithm of the daily water body total bacterial count at the water intake, with the base 10. S56. Using the output of step S55, perform an exponential calculation with base 10 to obtain the predicted value of the total number of bacterial colonies in the water body of the water source each day.
10. The method for predicting the total number of bacterial colonies in forest water bodies based on spatially heterogeneous random forest data as described in claim 1, characterized in that, In step S5, the calculation formula for the spatial heterogeneous random forest regression model framework is as follows: , , , , ,in, Let be the response variable, representing the total colony count observed in the i-th sample; i is the sample number. Represents the response variable Y i Follows the mean μ i variance is The normal distribution; μ i The conditional mean parameter of the response variable distribution; The variance of the model residuals; This is a fixed effect; Calculated for the random forest model; Let be the water quality indicator feature vector for the i-th sample, which includes three sub-features: ammonia nitrogen data, turbidity data, and permanganate index data. The water source type for the i-th sample; Let be the meteorological indicator feature vector of the i-th sample, which covers two sub-features: daily average temperature and daily average rainfall. The land use index feature vector for the i-th sample covers seven sub-features: water area, forest area, cultivated land area, submerged vegetation area, construction land area, bare land area, and pasture area. Spatial random effects; Let b be a vector with elements b1, b2, ... b n These represent the unique spatial random effects values of the 1st to nth water sources; T is the matrix transpose symbol. The spatial random effects vector follows a pattern with a mean of 0 and a covariance matrix of... The multivariate normal distribution; Let be the covariance matrix formed by the interrelationships among all n water sources; Variance represents the spatial variation of the overall random effect. This is a spatial correlation matrix, with values ranging from [0,1], representing the spatial correlation between different water sources; Spatial correlation matrix The Middle j The element in the k-th row represents the spatial correlation strength between water source j and water source k; This refers to the spatial decay rate parameter; Let be the Euclidean distance between sampling point j and sampling point k calculated using the spatial coordinates of the water source; j is sampling point j; k is sampling point k.
Citation Information
Patent Citations
Quantitative prediction method for pollution degree of offshore water body based on pollution indicating flora
CN110308255A
River water quality prediction method and system based on machine learning coupling hydrological model
CN120875113A