Rural domestic water demand short-term prediction method, system, device and medium based on ensemble learning
The method for short-term prediction of rural domestic water demand based on the Stacking ensemble learning model solves the problems of insufficient prediction accuracy and overfitting in existing technologies, achieves more efficient prediction of rural domestic water demand, and improves the reliability and practicality of the model.
Patent Information
- Application Number
- CN202610338405.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-19
- Publication Date
- 2026-06-23
AI Technical Summary
Existing rural domestic water demand prediction models have insufficient prediction accuracy and are prone to overfitting, resulting in low reliability.
A short-term prediction method for rural domestic water demand based on a Stacking ensemble learning model is adopted. By acquiring historical meteorological and water supply data, a prediction model for rural domestic water demand is constructed. Random forest, extreme gradient boosting, and support vector regression models are used as base classifiers, and a meta-learner is used for model training in the second layer. Combined with data preprocessing and hyperparameter optimization, overfitting is avoided.
It significantly improves the accuracy and engineering applicability of short-term rural water use forecasting, avoids the risk of overfitting, and enhances the overall predictive performance of the model.
Smart Images

Figure CN122264392A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of water resource management technology, and in particular relates to a method, system, equipment and medium for short-term prediction of rural domestic water demand based on ensemble learning. Background Technology
[0002] Rural domestic water demand forecasting is a core component of rural water resources planning and management, directly impacting rural drinking water safety project planning, optimized water supply system scheduling, and rational water resource allocation. Accurate short-term forecasts help water conservancy departments prepare water supply scheduling, emergency plans, and optimized water plant operation schedules in advance.
[0003] However, current rural water demand forecasting mainly relies on traditional statistical and machine learning methods, which suffer from insufficient model prediction accuracy and a significant risk of overfitting, resulting in low reliability. Summary of the Invention
[0004] The purpose of this invention is to provide a method, system, device, and medium for short-term prediction of rural domestic water demand based on ensemble learning, so as to solve the problems existing in the prior art.
[0005] To achieve the above objectives, the present invention provides a short-term prediction method for rural domestic water demand based on ensemble learning, comprising:
[0006] S1: Obtain input data, which includes historical meteorological data of the area to be predicted and historical water supply data of each water plant in the area to be predicted;
[0007] S2: Calculate the per capita rural domestic water demand coefficient in the short term based on the historical water supply data of each water plant in the area to be predicted;
[0008] S3: Input the historical meteorological data of the area to be predicted and the rural per capita water demand coefficient in the short term into the rural water demand prediction model for prediction, and obtain the predicted value of the rural per capita water demand coefficient; wherein, the rural water demand prediction model is constructed based on the Stacking ensemble learning model.
[0009] Optionally, the historical meteorological data of the area to be predicted in step S1 includes daily average temperature, daily maximum temperature, daily minimum temperature and daily average relative humidity.
[0010] Optionally, after obtaining the input data in step S1, the method further includes:
[0011] The input data is processed by handling missing values, outliers, and data standardization to obtain preprocessed input data.
[0012] Optionally, step S2 specifically includes:
[0013] The daily water consumption data of each water plant in the forecast area are averaged to obtain the average daily water supply of each water plant.
[0014] Taking each water plant as a unit, the daily water supply of each water plant is divided by the average daily water supply of the corresponding water plant to obtain the rural per capita water demand coefficient.
[0015] Optionally, the training process of the rural domestic water demand prediction model in step S3 specifically includes:
[0016] Acquire training data, which includes historical water supply data, historical meteorological data, and historical rural per capita domestic water demand coefficient data;
[0017] An initial rural domestic water demand prediction model was constructed, in which the first layer base classifiers were selected from random forest model, extreme gradient boosting model and support vector regression model; the second layer used a learner as a meta-model.
[0018] The training data is divided into an initial training set and an initial test set based on preset rules;
[0019] The initial training set is input into the base classifiers of the initial rural domestic water demand prediction model for cross-validation and hyperparameter optimization. The prediction results of each base classifier are concatenated to obtain the meta-learner training set. Based on the initial test set, each base learner is used to make predictions, and the prediction results are used as the meta-learner test set.
[0020] The training and test sets of the meta-learner are input into the meta-model for prediction, and the meta-model is trained based on the objective loss function to obtain the trained rural domestic water demand prediction model.
[0021] The implementation steps of the ensemble learning model - Stacking model - are as follows:
[0022] (1) Divide the original training set into a training set and a test set. The training set is used to train the overall Stacking ensemble learning model, and the test set is used to test the model.
[0023] (2) Each learner learns and predicts independently based on the training set. The output of the base learner on the training set is used as a new input feature to form a new training set, which is then input into the second layer. The base learner is used to make predictions using the test set, and these predictions are used as a new test set for the final prediction by the meta-learner.
[0024] In the second layer, a meta-learner is trained using the predictions from the base learners. The meta-learner can be any machine learning model, such as logistic regression or support vector machines. The formula and method for training the meta-learner are similar to those for training a single model, using cross-validation to select the optimal hyperparameters. To prevent overfitting, the first-layer base learner uses cross-validation to filter the data during training. The dataset is randomly divided into K parts, with one part used as the test set each time, and the remaining K-1 parts used as the training set. This process is repeated K times to obtain K different sets of model parameters (the training and test samples change each time). These K sets of models with different parameter values are then used to predict on the same validation set to obtain the final prediction result. The specific implementation process of the Stacking algorithm is as follows... Figure 1 As shown, for sample data that has already been divided into training and test sets, cross-validation is used to divide the training set, with K typically set to 5. Four parts are then used alternately as training data, and the remaining part as the validation set to train the model. This generates five different training and validation sets, resulting in five different parameter configurations for the same model. Each of these five models with different parameter configurations is used to predict on its corresponding validation set. The predictions from these five validation sets are then concatenated to form a new training set. Similarly, for the same test set, the five different parameter configurations of the same model will generate five sets of predictions. The average of these five predictions is taken as the prediction value for the model on the test set. Assuming the first layer has three base learners, using 5-fold cross-validation, this process needs to be repeated twice, resulting in a total of three new training sets and three new test sets. These three training sets and three test sets are then merged to obtain the final training and test sets, with the data size being three times the original. These final training and test sets are then used to train the second-layer meta-model, thus obtaining the second-layer model. Once the parameters of both models are determined, the data can be directly substituted into the model for prediction.
[0025] GridSearch: It iterates through all possible combinations of specified parameter candidate values, evaluates the performance of each combination, and finally selects the best-performing parameter combination.
[0026] GridSearchCV is a powerful tool in the scikit-learn library for hyperparameter optimization. It searches for the optimal combination of parameters in a specified parameter grid by exhaustive search.
[0027] Bayesian optimization: This method uses Bayesian methods to build a probabilistic model of the objective function, inferring the next possible optimal parameter values based on existing evaluation results, thereby progressively optimizing the parameters. Bayesian optimization estimates the objective function through Gaussian process regression and can be used when the objective function is complex.
[0028] Secondly, to achieve the above objectives, this invention provides a short-term prediction system for rural domestic water demand based on ensemble learning, comprising:
[0029] The data acquisition module is used to acquire input data, which includes historical meteorological data of the area to be predicted and historical water supply data of each water plant in the area to be predicted; and to calculate the rural per capita domestic water demand coefficient in the short term based on the historical water supply data of each water plant in the area to be predicted.
[0030] The rural domestic water demand short-term prediction module is used to input historical meteorological data of the area to be predicted and the rural per capita domestic water demand coefficient in the short term into the rural domestic water demand prediction model for prediction, and obtain the predicted value of the rural per capita domestic water demand coefficient; wherein, the rural domestic water demand prediction model is built based on the Stacking ensemble learning model.
[0031] Thirdly, to achieve the above objectives, the present invention provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to perform the short-term prediction method for rural domestic water demand based on ensemble learning described in the first aspect.
[0032] Fourthly, to achieve the above objectives, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a short-term prediction method for rural domestic water demand based on ensemble learning as described in the first aspect.
[0033] The technical effects of this invention are as follows:
[0034] This invention introduces an ensemble learning framework, which integrates the advantages of different algorithms and improves the overall prediction effect. At the same time, ensemble learning avoids the risk of overfitting and does not require too many parameter tuning steps and feature selection. Ultimately, it significantly improves the overall effect and engineering practicality of short-term rural water use prediction. Attached Figure Description
[0035] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0036] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0037] Figure 1 This is a flowchart of the model training process in an embodiment of the present invention;
[0038] Figure 2 This illustrates the correlation between various meteorological factors and the per capita water demand coefficient for rural residents in this embodiment of the invention.
[0039] Figure 3 This is the correlation between the rural per capita domestic water demand coefficient for the previous seven days and the rural per capita domestic water demand coefficient for the current day in this embodiment of the invention.
[0040] Figure 4 This is a stacking diagram showing the relationship between the actual water demand coefficient and the predicted water demand coefficient under different average humidity conditions in this embodiment of the invention.
[0041] Figure 5 This is a stacking diagram showing the relationship between the actual water demand coefficient and the predicted water demand coefficient under different average temperatures in this embodiment of the invention.
[0042] Figure 6 This is a stacking diagram showing the relationship between the actual water demand coefficient and the predicted water demand coefficient under different maximum temperatures in this embodiment of the invention.
[0043] Figure 7 This is a stacking diagram showing the relationship between the actual water demand coefficient and the predicted water demand coefficient under different minimum temperatures in this embodiment of the invention.
[0044] Figure 8 This is a stacking diagram showing the relationship between the actual water demand coefficient and the predicted water demand coefficient under different yesterday's water demand coefficients in an embodiment of the present invention.
[0045] Figure 9 This is a stacking diagram showing the relationship between the actual water demand coefficient and the predicted water demand coefficient under different previous day water demand coefficients in an embodiment of the present invention.
[0046] Figure 10 This is a stacking diagram showing the relationship between the actual water demand coefficient and the predicted water demand coefficient under different three-day-ahead water demand coefficients in an embodiment of the present invention.
[0047] Figure 11 This is a comparison chart of the actual water demand coefficient and the predicted water demand coefficient of the Stacking ensemble learning training set in an embodiment of the present invention.
[0048] Figure 12 This is a comparison chart of the actual water demand coefficient and the predicted water demand coefficient of the Stacking ensemble learning test set in this embodiment of the invention;
[0049] Figure 13 This is a flowchart illustrating the implementation of an embodiment of the present invention. Detailed Implementation
[0050] Various exemplary embodiments of the present invention will now be described in detail. This detailed description should not be considered as a limitation of the present invention, but rather as a more detailed description of certain aspects, features, and embodiments of the present invention.
[0051] It should be understood that the terminology used in this invention is merely for describing particular embodiments and is not intended to limit the invention. Furthermore, with respect to numerical ranges in this invention, it should be understood that each intermediate value between the upper and lower limits of the range is also specifically disclosed. Every smaller range between any stated value or intermediate value within a stated range, and any other stated value or intermediate value within said range, is also included in this invention. The upper and lower limits of these smaller ranges may be independently included or excluded from the range.
[0052] Various modifications and variations can be made to the specific embodiments described in this specification without departing from the scope or spirit of the invention, as will be apparent to those skilled in the art. Other embodiments derived from this specification will also be obvious to those skilled in the art. This application specification and embodiments are merely exemplary.
[0053] The terms “include,” “including,” “have,” “contain,” etc., used in this article are all open-ended terms, meaning that they include but are not limited to.
[0054] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0055] Example 1
[0056] like Figure 1 - Figure 13 As shown, this embodiment provides a short-term prediction method for rural domestic water demand based on ensemble learning, including: acquiring input data, which includes historical meteorological data of the area to be predicted and historical water supply data of each water plant in the area to be predicted; calculating the rural per capita domestic water demand coefficient in the short term based on the historical water supply data of each water plant in the area to be predicted; inputting the historical meteorological data of the area to be predicted and the rural per capita domestic water demand coefficient in the short term into the rural domestic water demand prediction model for prediction, and obtaining the predicted value of the rural per capita domestic water demand coefficient; wherein, the rural domestic water demand prediction model is constructed based on the Stacking ensemble learning model.
[0057] The rural domestic water demand data used in this embodiment are derived from the daily actual water supply data recorded by typical rural water supply projects in various districts and counties of Chongqing Municipality, covering the period from January 1, 2020 to December 31, 2023. This data was collected through on-site surveys. Since the design scale of the selected typical projects is larger than the actual water supply scale, it is assumed that the actual water supply of each project is determined based on the needs of water users, i.e., meeting the principle of "supply based on demand." Therefore, the actual water supply data of the water plants can be used to characterize the actual water demand of rural residents. Furthermore, meteorological data are sourced from the China Meteorological Administration's Meteorological Data Center, with a daily data frequency. Data elements include maximum temperature, minimum temperature, average temperature, average relative humidity, rainfall, average wind speed, average air pressure, maximum air pressure, and minimum air pressure. The annual domestic water consumption data used are from the "Chongqing Water Resources Bulletin," while data on population size, per capita disposable income, and annual average temperature are from the "Chongqing Statistical Yearbook."
[0058] (1) Missing Value Handling: Missing values can affect the accuracy of data analysis and modeling. Handling missing values can improve the performance and reliability of the model. In addition, missing value handling can ensure the integrity of sample data and reduce bias caused by missing values. Common methods for handling missing values include deletion, imputation, and interpolation. There are many reasons for missing rural domestic water demand data. Data incompleteness may occur during data collection at different times, locations, and devices; errors may occur during data entry or transmission; lightning strikes may prevent the acquisition of complete rural domestic water demand data. Missing values in rural domestic water demand data need to be checked and handled.
[0059] ① Identify missing values. Rural domestic water demand data mainly contains missing values in fields such as rural population and rural domestic water demand. Use Excel to check the missing value of each feature.
[0060] ② For missing data, consult official releases or obtain supplementary data from other channels. If water demand data for the current day or previous days cannot be obtained due to lightning strikes, it can be directly excluded if the impact on the overall analysis is minimal.
[0061] (2) Outlier Handling: Outliers may skew the data distribution, affecting the accuracy of statistical analysis, causing errors in the analysis results, and reducing the performance of the model. Outliers in rural domestic water demand can be identified and handled through methods such as box plots, Z-scores, and interquartile range (IQR). In this embodiment, outliers are handled using the interquartile range (IQR) method. In rural domestic water demand research, the IQR method is the preferred choice due to its robustness, non-parametric characteristics, intuitiveness, and adaptability to small samples. It can effectively identify real anomalies (such as extreme records caused by equipment failure or data entry errors), while avoiding misjudgments caused by distribution assumptions or extreme value interference, ensuring the accuracy of subsequent statistical analysis (such as regression models or water demand prediction). The calculation process of the interquartile range (IQR) method is as follows.
[0062] Calculate the quartiles: Q1 is the first quartile (25th percentile); Q3 is the third quartile (75th percentile).
[0063] Calculate the interquartile range (IQR): IQR = Q3 - Q1
[0064] Determine outlier boundaries: lower bound is Q1 - 1.5 × IQR; upper bound is Q3 + 1.5 × IQR.
[0065] Outlier removal: Remove all points (outliers) that fall outside the range (Q1-1.5×IQR, Q3+1.5×IQR).
[0066] (3) Data standardization: Subsequently, the collected data needs to be used to make predictions through multiple models and the predicted values need to be merged. Using the original data may lead to overfitting. Data standardization can help the model converge to the optimal solution faster, improve the robustness of the model, and avoid overfitting.
[0067] Data standardization involves scaling sample attributes to a specified range. Standardization is frequently used in processing metrics for machine learning models. This method removes unit constraints from the data, directly converting attribute values into dimensionless pure numerical values, facilitating comparisons of attributes with different units or magnitudes. Common standardization algorithms include min-max standardization and z-score standardization.
[0068] ①Maximum-Minimum Standardization: For a certain attribute x in the sample dataset... (i) Let i = 1, 2, ..., d, and let the standardized interval be [P, Q], Z min Z is the minimum value of this attribute in the sample dataset. max It is the maximum value of this attribute in the sample dataset. Let Z be the value of this attribute in a certain sample, and Z be the standardized value. n The calculation process follows formula (1):
[0069] Equation (1)
[0070] In the formula, c = (QP) / (Z) max -Z min ), d=Q-(c*Z max )
[0071] ②z-score standardization: for a certain attribute x in the sample dataset (i) Let i = 1, 2, ..., d, and calculate its mean. and standard deviation :
[0072] Equation (2)
[0073] Equation (3)
[0074] Then, the standardized attribute values are calculated based on (4):
[0075] Equation (4)
[0076] After z-score standardization, the mean of all attributes in the dataset is zero, and the standard deviation is scaled to 1. Compared to min-max standardization, z-score standardization does not limit the range of values; this embodiment uses z-score standardization.
[0077] Input Indicator Acquisition: Since the rural water supply projects surveyed in this prediction are distributed across different districts and counties of the city, and the baseline water usage levels vary across these districts and counties, a method was developed to eliminate the differences in water usage between water plants in different districts and counties, ensuring that the model's prediction results are applicable to different areas of the city. Firstly, the daily water consumption data of each water plant was averaged. That is, taking each water plant as a unit, the daily water supply data was divided by the plant's multi-year average daily water supply to obtain the rural per capita domestic water demand coefficient, which was then used as the model's input indicator.
[0078] Model input: Input features include historical data at time t, Xt=[x t−1 ,x t−2 ,...,x t−p ], where p=7 is the size of the time window (unit: days), and the features include daily average temperature (unit: ℃), daily maximum temperature (unit: ℃), daily minimum temperature (unit: ℃), daily average relative humidity (unit: %), rural per capita water demand coefficient yesterday, rural per capita water demand coefficient the day before yesterday, and rural per capita water demand coefficient three days ago.
[0079] Model output: Predicts the per capita water demand coefficient for rural residents on any given day.
[0080] (4) Data set partitioning: In this embodiment, the per capita water demand data of rural residents in various districts and counties of Chongqing are selected as samples, totaling 3008 sets. 80% of the data sets are randomly selected as the training set for training the model. The remaining 20% of the sample data is used as the test set to evaluate the model's predictive ability on unknown data and the model's performance.
[0081] Correlation Analysis: When predicting the per capita water demand coefficient for rural residents, correlation analysis was conducted between the per capita water demand coefficient data and various meteorological factors (daily average temperature TEM_Avg, maximum temperature TEM_Max, minimum temperature TEM_Min, average air pressure PRS_Avg, maximum air pressure PRS_Max, minimum air pressure PRS_Min, average relative humidity RHU_Avg, rainfall PRE_Time_2020, and average wind speed WIN_S_2mi_Avg). Furthermore, the influencing factors on daily water usage habits and the per capita daily water demand coefficient for rural residents were also analyzed. This process helps to better understand the relationships between these indicators and allows for the selection of appropriate indicators for prediction. The correlation analysis of each indicator was presented using a heatmap, and the results are as follows. Figure 2 , 3 As shown.
[0082] Depend on Figure 2 It can be seen that the correlation strength between various meteorological factors and the rural per capita water demand coefficient, from high to low, is as follows: daily average temperature (TEM-Avg), minimum temperature (TEM-Min), maximum temperature (TEM-Max), average relative humidity (RHU-Avg), average wind speed (WIN_S_2mi_Avg), maximum air pressure (PRS-Max), minimum air pressure (PRS-Min), average air pressure (PRS-Avg), rainfall (PRE_Time_2020), average relative humidity (RHU-Avg), maximum air pressure (PRS-Max), minimum air pressure (PRS-Min), and average air pressure (PRS-Avg), all of which are negatively correlated. The remaining factors are positively correlated. The daily average temperature (TEM-Avg), minimum temperature (TEM-Min), maximum temperature (TEM-Max), and average relative humidity (RHU-Avg) have relatively high correlation coefficients with the rural per capita water demand coefficient, and the relationship between them can be used for prediction. Figure 3 It can be seen that the rural per capita water demand coefficient for the first seven days and the rural per capita water demand coefficient for the day are both positively correlated. Therefore, the rural per capita water demand coefficient for the first three days, which has a higher correlation, is selected as the characteristic value.
[0083] Evaluation Metrics: Choosing appropriate evaluation metrics is crucial for assessing model performance. Different problems require different metrics. Selecting suitable metrics can better reflect the model's performance in solving a specific problem, helping to determine the model's effectiveness and reliability. Commonly used metrics for evaluating the prediction accuracy of numerical (continuous) data include Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), and Goodness of Fit (R²). 2 )wait.
[0084] Equation (5)
[0085] Equation (6)
[0086] Equation (7)
[0087] The total number of test samples is represented by n. This represents the actual value of the per capita water demand coefficient for rural residents. The predicted value representing the daily per capita water demand coefficient for rural residents. The mean absolute error (MAE) represents the average water demand coefficient per capita in rural areas; the smaller the value, the higher the model accuracy. The mean absolute percentage error (MAPE) reflects the relative error between the actual and predicted values; the smaller the value, the more accurate the prediction. The mean squared error reflects the dispersion of the error distribution; the smaller the value, the better. R0 2 It reflects the goodness of fit, ranging from [0,1].
[0088] The basic idea behind Stacking ensemble learning is that when modeling on large datasets, using a single learner can lead to poor generalization performance and computational getting stuck in local minima. Stacking models are an effective ensemble learning framework that improves model performance by integrating multiple models. Stacking models combine the advantages of different algorithms, improving overall prediction results. Furthermore, ensemble learning avoids the risk of overfitting and does not require excessive parameter tuning or feature selection. Therefore, Stacking ensemble learning is used for modeling.
[0089] The training process is as follows:
[0090] (1) Perform preprocessing operations such as constructing derived features and normalization on the original data.
[0091] (2) Model selection and parameter tuning. The first-layer base classifier is selected from RF, XGBoost, and SVR. The second layer usually uses only one learner as the meta-model, and the optimal hyperparameters are selected through grid search and cross-validation.
[0092] (3) Stacking ensemble process. 80% of the training data is used to train the fusion model, and 20% is used to evaluate model performance. Each base classifier is trained using ten-fold cross-validation. The predictions of individual classifiers are concatenated together to obtain a new training sample for the second-layer classifier. The new training sample is used to train the second-layer meta-learner in the Stacking ensemble framework.
[0093] (4) Input the test set into the model to obtain the prediction results of Stacking.
[0094] Experimental environment and parameter adjustments: Python software was used.
[0095] The parameters of different models are tuned, and the optimal parameters are selected using methods such as grid search.
[0096] Empirical Analysis of Stacking Ensemble Learning Models: This study explores the configuration of stacking ensemble learning models, obtaining the MAE, MAPE values, and R-values of the ensemble model. 2 The results are shown in Table 1 below.
[0097] As shown in Table 1, the MAPE of SVR-RF-XGBoost is 1.46 (lowest). 2 With a maximum value of 0.98, this combination offers the best prediction accuracy. Its low MAPE and high R-value... 2 The values indicate that this combination can accurately predict the target variable and has a strong ability to explain data variability. Based on RMSE, MAE, and R... 2 The metrics lead to the conclusion that when dealing with complex datasets, single traditional models (such as SVR and RF) may not be sufficient to provide optimal predictive performance, while stacking ensemble learning is better able to capture complex patterns in the data.
[0098] Figures 4-10 The graphs show the relationship between actual and predicted water demand coefficients under different average humidity, average temperature, maximum temperature, minimum temperature, yesterday's water demand coefficient, the day before yesterday's water demand coefficient, and the water demand coefficient three days ago, using the Stacking ensemble learning model. Figures 11-12 The figures show a comparison between the actual and predicted water demand coefficients when using a Stacking ensemble learning model to analyze the training and test datasets. Figure 4It can be seen that when RHUavg (average relative humidity) is in the range of 60% to 80%, the per capita water demand coefficient for rural residents is concentrated in the range of 0.9 to 1.2, which is the core dense area, and the predicted value highly overlaps with the actual value. When the average relative humidity deviates from this range (less than 60% or greater than 80%), it indicates that the dispersion of per capita water demand for rural residents increases, but the trend is consistent and the deviation is small. Figure 5 It can be seen that when the TEM Avg (average temperature) is in the range of 15℃-25℃, the per capita water demand coefficient for rural residents is concentrated between 0.9 and 1.2, with the predicted values highly overlapping with the actual values; in extreme ranges (below 10℃ or above 30℃), the predicted points are slightly more dispersed, but the overall trend is consistent. Figure 6 It can be seen that when the TEM Max (maximum temperature) is in the range of 20℃-30℃, the per capita water demand coefficient for rural residents is concentrated between 0.9 and 1.2, indicating that the per capita water demand for rural residents is most stable under moderate high temperatures (20℃-30℃). Prediction points are sparse in extreme ranges (below 15℃ or above 35℃), but the deviation is small. Figure 7 It can be seen that when the TEM Min (minimum temperature) is in the range of 10℃-20℃, the per capita water demand coefficient for rural residents is concentrated between 0.9 and 1.2; in extreme ranges (below 5℃ or above 25℃), the predicted points are slightly more dispersed, but the trend is consistent. From Figures 8-12 It can be seen that the per capita water demand coefficient of rural residents yesterday, the day before yesterday, and three days ago is positively correlated with the per capita water demand coefficient of rural residents on the current day. The predicted value in the core interval highly overlaps with the actual value. The predicted points in the extreme interval (less than 0.8 or greater than 1.2) are slightly dispersed, but the deviation is small.
[0099] In summary, the stacking model demonstrates high accuracy and good fit in predicting the per capita water demand coefficient for rural residents. The results show that when the average relative humidity is between 60% and 80%, the per capita water demand coefficient for rural residents mainly ranges from 0.90 to 1.20, and decreases as the average relative humidity increases. Similarly, when the average temperature is between 15 and 25°C, the water demand coefficient also ranges from 0.90 to 1.20. The distribution of the water demand coefficient is most stable when the highest temperature is between 20 and 30°C, and also stable when the lowest temperature is between 10 and 20°C. Furthermore, the per capita water demand coefficient for rural residents increases continuously with increases in average temperature, highest temperature, and lowest temperature. The daily water demand coefficient increases continuously with the increase in the per capita water demand coefficient of the previous day, the day before yesterday, and the previous three days.
[0100] Stacking Ensemble Learning Model Prediction: To more comprehensively evaluate the applicability of the optimal ensemble model, meteorological information for a specific week (June 11, 2025 - June 17, 2025) was selected from the China Meteorological Administration, including average temperature, maximum temperature, minimum temperature, average relative humidity; and the rural per capita water demand coefficient for the past three days were used as input values, with the output value being the rural per capita water demand coefficient for that day. The data and results are shown in Table 2.
[0101] Average temperature fluctuated dramatically (range 7.5°C), showing no monotonic trend. The peak temperature on day 3 (29.8°C) did not correspond to the peak water demand; instead, due to the lag effect and rising humidity, water demand decreased (73.6 L / d). The highest temperature remained stable at 34°C for the first three days, then dropped over the next four days (average 31.3°C). The lowest temperature fluctuated less (range 5°C), with the trough on day 4 (17°C) coinciding with the lowest water demand point (69.4 L / d). Average relative humidity showed a continuous upward trend (slope ≈ 6.5% / day), peaking on day 7 (83.1%). Rural per capita domestic water demand correlated with the coefficient, decreasing over the first four days (a decrease of 23.3%, from 90.5 L / d to 69.4 L / d), then stabilizing over the next three days (average 70.8 L / d). The rate of decline was steep in the early stage (9.3% decrease on the first two days) and then slowed down in the later stage (5.7% decrease on the third and fourth days), which is consistent with the "decline-stable" pattern commonly found in water resources research.
[0102] Data shows that the per capita water demand in rural areas (output value) exhibits a significant dynamic evolution pattern with input factors: From a meteorological perspective, fluctuations in average temperature, maximum temperature, and minimum temperature, along with changes in average relative humidity, collectively shape the water demand value. Water demand is relatively high during periods of high temperature and low humidity (e.g., when the average temperature is 23.8℃ and the relative humidity is 41.1%, the water demand reaches 90.5 L / d), while it gradually decreases under conditions of high temperature and high humidity or low temperature. Regarding lifestyle habits, the continuous decrease in the water demand coefficient over the past three days anchors the inertia of rural domestic water use behavior, driving a synchronous decline in both the daily water demand coefficient and the actual water demand. Overall, the per capita water demand in rural areas is the result of the synergistic coupling of meteorological factors (temperature and humidity) and behavioral factors (historical water demand coefficient). Meteorological factors construct the environmental constraints on water demand, while historical coefficients maintain behavioral inertia. The combination of these two factors causes the water demand to exhibit a dynamic adjustment pattern as temperature rises, humidity increases, and historical coefficients decline.
[0103] This embodiment also provides a short-term prediction system for rural domestic water demand based on ensemble learning, comprising:
[0104] The data acquisition module is used to acquire input data, which includes historical meteorological data of the area to be predicted and historical water supply data of each water plant in the area to be predicted; and to calculate the rural per capita domestic water demand coefficient in the short term based on the historical water supply data of each water plant in the area to be predicted.
[0105] The rural domestic water demand short-term prediction module is used to input historical meteorological data of the area to be predicted and the rural per capita domestic water demand coefficient in the short term into the rural domestic water demand prediction model for prediction, and obtain the predicted value of the rural per capita domestic water demand coefficient; wherein, the rural domestic water demand prediction model is built based on the Stacking ensemble learning model.
[0106] In practice, this embodiment also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor runs the computer program to enable the electronic device to perform the aforementioned method for short-term prediction of rural domestic water demand based on ensemble learning.
[0107] In practice, this embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned method for short-term prediction of rural domestic water demand based on ensemble learning.
[0108] The above description is merely a preferred embodiment of this application, but the scope of protection of this application 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 this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A short-term prediction method for rural domestic water demand based on ensemble learning, characterized in that, include: S1: Obtain input data, which includes historical meteorological data of the area to be predicted and historical water supply data of each water plant in the area to be predicted; S2: Calculate the per capita rural domestic water demand coefficient in the short term based on the historical water supply data of each water plant in the area to be predicted; S3: Input the historical meteorological data of the area to be predicted and the rural per capita water demand coefficient in the short term into the rural water demand prediction model for prediction, and obtain the predicted value of the rural per capita water demand coefficient; wherein, the rural water demand prediction model is constructed based on the Stacking ensemble learning model.
2. The method for short-term prediction of rural domestic water demand based on ensemble learning according to claim 1, characterized in that, The historical meteorological data of the area to be predicted in step S1 includes daily average temperature, daily maximum temperature, daily minimum temperature, and daily average relative humidity.
3. The method for short-term prediction of rural domestic water demand based on ensemble learning according to claim 1, characterized in that, After obtaining the input data in step S1, the method further includes: The input data is processed by handling missing values, outliers, and data standardization to obtain preprocessed input data.
4. The method for short-term prediction of rural domestic water demand based on ensemble learning according to claim 3, characterized in that, Step S2 specifically includes: The daily water consumption data of each water plant in the forecast area are averaged to obtain the average daily water supply of each water plant. Taking each water plant as a unit, the daily water supply of each water plant is divided by the average daily water supply of the corresponding water plant to obtain the rural per capita water demand coefficient.
5. The method for short-term prediction of rural domestic water demand based on ensemble learning according to claim 1, characterized in that, The training process of the rural domestic water demand prediction model in step S3 specifically includes: Acquire training data, which includes historical water supply data, historical meteorological data, and historical rural per capita domestic water demand coefficient data; An initial rural domestic water demand prediction model was constructed, in which the first layer base classifiers were selected from random forest model, extreme gradient boosting model and support vector regression model; the second layer used a learner as a meta-model. The training data is divided into an initial training set and an initial test set based on preset rules; The initial training set is input into the base classifiers of the initial rural domestic water demand prediction model for cross-validation and hyperparameter optimization. The prediction results of each base classifier are concatenated to obtain the meta-learner training set. Based on the initial test set, each base learner is used to make predictions, and the prediction results are used as the meta-learner test set. The training and test sets of the meta-learner are input into the meta-model for prediction, and the meta-model is trained based on the objective loss function to obtain the trained rural domestic water demand prediction model.
6. A short-term prediction system for rural domestic water demand based on ensemble learning, characterized in that, include: The data acquisition module is used to acquire input data, which includes historical meteorological data of the area to be predicted and historical water supply data of each water plant in the area to be predicted; and to calculate the rural per capita domestic water demand coefficient in the short term based on the historical water supply data of each water plant in the area to be predicted. The rural domestic water demand short-term prediction module is used to input historical meteorological data of the area to be predicted and the rural per capita domestic water demand coefficient in the short term into the rural domestic water demand prediction model for prediction, and obtain the predicted value of the rural per capita domestic water demand coefficient; wherein, the rural domestic water demand prediction model is built based on the Stacking ensemble learning model.
7. An electronic device, characterized in that, The device includes a memory and a processor, the memory being used to store a computer program, and the processor running the computer program to enable the electronic device to perform a method for short-term prediction of rural domestic water demand based on ensemble learning according to any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements a method for short-term prediction of rural domestic water demand based on ensemble learning as described in any one of claims 1-5.
