A variable weight-based urban water supply amount deep learning prediction method and system
By preprocessing historical data from urban water plants and calculating sample weights, a variable-weight long short-term memory network model is constructed. This solves the problem of insufficient prediction accuracy of water supply during peak periods in the traditional LSTM model, achieving higher prediction accuracy and lower energy consumption.
Patent Information
- Application Number
- CN202411925397.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2044-12-25
AI Technical Summary
Traditional LSTM models cannot meet the actual scheduling needs in urban water supply forecasting, especially during peak periods, leading to operational difficulties for water pumping stations.
By acquiring historical data from urban water plants for data preprocessing, calculating time-based sample weights, constructing a variable-weight long short-term memory network model, introducing a weighted loss function, and optimizing the water supply prediction of the LSTM model.
It significantly improved the accuracy of water supply demand forecasting during peak periods, met actual dispatching needs, and reduced the energy consumption of water supply pumping stations.
Smart Images

Figure CN119940605B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of urban water supply and drainage prediction technology, and in particular to a deep learning prediction method and system for urban water supply based on variable weights. Background Technology
[0002] Because urban water supply networks exhibit significant lag in pressure and flow regulation, water pumping stations must adjust current water supply and storage in advance based on predictions of future demand to cope with peak or emergency water usage. Therefore, water companies typically need to conduct short-term water demand forecasts. On the one hand, by predicting demand in advance, they can meet users' requirements for water volume and pressure at different times; on the other hand, more efficient pumping station switching operations can reduce energy consumption in water supply.
[0003] Currently, short-term water demand forecasting methods are mainly divided into two categories: time series methods and related factor forecasting methods. Time series methods are built based on the temporal sequence of historical water use data and are suitable for data with obvious seasonality, trends, and periodicity. They can better express the different properties of the data sequence, with a typical example being the ARIMA model. Related factor forecasting methods refer to various methods built based on factors influencing water use data. They can better handle nonlinear mapping relationships between variables and include both traditional machine learning methods and deep learning models. In addition, forecasting models represented by deep learning are gradually emerging. The LSTM (Long Short-Term Memory) model overcomes the shortcomings of RNNs, namely the vanishing gradient phenomenon, by introducing a gating mechanism, and can effectively remember long-term historical information without forgetting short-term memory. Therefore, LSTM is widely used in time series forecasting and has achieved good results in the financial, transportation, and energy sectors.
[0004] However, urban water demand exhibits multiple peak periods throughout the day, during which demand fluctuates dramatically in a short period, posing a significant challenge to the operation of water supply pumping stations. At other times, demand changes relatively smoothly, requiring less intervention from pumping stations. While traditional LSTM models offer high overall accuracy, their prediction accuracy during peak periods still falls short of actual scheduling needs.
[0005] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the Invention
[0006] The main objective of this application is to propose a deep learning prediction method and system for urban water supply based on variable weights, which can improve the prediction accuracy of water supply demand during peak periods, thereby enabling the accuracy of peak water demand prediction to meet actual scheduling needs.
[0007] To achieve the above objectives, one aspect of this application proposes a deep learning prediction method for urban water supply based on variable weights, the method comprising:
[0008] Historical data of urban water plants are acquired and preprocessed to obtain preprocessed historical data of urban water plants.
[0009] Based on the preprocessed historical data of urban water plants, time-based sample weights are calculated to obtain the sample weight values of historical data of urban water plants.
[0010] Based on the long short-term memory neural network, the weight values of the historical data samples of the urban water plant are introduced to construct a long short-term memory network model based on variable weights.
[0011] The water supply prediction results are obtained by using the long short-term memory network model with variable weights to predict the water supply of the preprocessed historical data of the urban water plant.
[0012] In some embodiments, the step of acquiring historical data of urban water plants and performing data preprocessing to obtain preprocessed historical data of urban water plants includes:
[0013] Acquire historical data from urban water plants, including urban water demand data, water pressure data, and temperature data.
[0014] Data cleaning is performed on the historical data of urban water plants to obtain cleaned historical data of urban water plants.
[0015] The missing values of the cleaned historical data of the urban water plant were supplemented by linear value method to obtain the supplemented historical data of the urban water plant.
[0016] Based on the 3σ principle, outlier detection processing was performed on the supplemented historical data of urban water plants to obtain the detected historical data of urban water plants.
[0017] The historical data of urban water plants after testing were subjected to time resampling to obtain preprocessed historical data of urban water plants.
[0018] In some embodiments, the expression for the linear value method is as follows:
[0019]
[0020] In the above formula, x0, y0, x1, and y1 represent known coordinate values, and x and y represent the coordinate values of the target location.
[0021] In some embodiments, the step of calculating time-based sample weights based on the preprocessed historical data of urban water plants to obtain sample weight values for the historical data of urban water plants includes:
[0022] The peak and off-peak periods of the preprocessed historical data of the urban water plant are obtained, and the distance values are calculated to obtain the distance values between the peak and off-peak periods of the historical data of the urban water plant.
[0023] Determine the importance index multiple between the peak period and the trough period;
[0024] Based on the importance index multiple, and combined with the distance between peak and off-peak periods in the historical data of the urban water plant, a time-based sample weight calculation is performed to obtain the preliminary sample weight values of the historical data of the urban water plant.
[0025] The initial weight values of the historical data samples of urban water plants are scaled to obtain the weight values of the historical data samples of urban water plants.
[0026] In some embodiments, the calculation expression for the initial weight values of the historical data samples of urban water plants is as follows:
[0027]
[0028] In the above formula, w t0 This represents the preliminary historical data sample weights for urban water plants, where 'a' represents the importance index multiple, and 'd' represents the weights. t This represents the distance between peak and off-peak periods in the historical data of the city's water plant, where t represents time, and max(·) indicates the operation of taking the maximum value.
[0029] In some embodiments, the expression for scaling the initial weight values of the urban water plant historical data samples is specifically as follows:
[0030]
[0031] In the above formula, w t0 w represents the preliminary historical data sample weights for urban water plants. t denoted by , where N represents the total number of training samples and t represents the time point.
[0032] In some embodiments, the construction of a variable-weight long short-term memory network model based on a long short-term memory neural network, by introducing the weight values of historical data samples from the urban water plant, includes:
[0033] Based on the long short-term memory neural network, feature selection is performed using the Pearson correlation coefficient to obtain the selected long short-term memory neural network.
[0034] Based on the loss function of the selected long short-term memory neural network, a weighted processing of the weight values of the historical data samples of the urban water plant is added to obtain a weighted long short-term memory network model.
[0035] The weighted long short-term memory network model was processed by adjusting the learning rate and batch size using the PyTorch algorithm to obtain a long short-term memory network model based on variable weights.
[0036] In some embodiments, the expression for the loss function of the variable-weight long short-term memory network model is as follows:
[0037]
[0038] In the above formula, L′ represents the loss function of the long short-term memory network model based on variable weights, and N represents the total number of training samples. y represents the model's predicted value. t w represents the sample observations. t This represents the weight value of historical data samples from the city's water plant, and t represents the time period.
[0039] In some embodiments, the long short-term memory network model based on the variable weights predicts the water supply volume of the preprocessed historical data of urban water plants to obtain the urban water supply prediction result, including:
[0040] The preprocessed historical data of urban water plants is divided into training and testing sets.
[0041] The variable-weight long short-term memory network model is trained using the training set to obtain the trained variable-weight long short-term memory network model.
[0042] Based on the trained variable-weight long short-term memory network model, water supply is predicted for the test set to obtain preliminary urban water supply results.
[0043] The preliminary urban water supply data is inversely normalized to obtain the predicted urban water supply data.
[0044] To achieve the above objectives, another aspect of this application proposes a deep learning prediction system for urban water supply based on variable weights, the system comprising:
[0045] The first module is used to acquire historical data of urban water plants and perform data preprocessing to obtain preprocessed historical data of urban water plants.
[0046] The second module is used to perform time-based sample weight calculation based on the preprocessed historical data of urban water plants to obtain the sample weight value of the historical data of urban water plants.
[0047] The third module is used to construct a long short-term memory network model based on variable weights by introducing the weight values of historical data samples from the city's water plant, based on a long short-term memory neural network.
[0048] The fourth module is used to predict the water supply volume of the preprocessed historical data of the urban water plant based on the variable weight long short-term memory network model, and obtain the urban water supply prediction result.
[0049] The embodiments of this application include at least the following beneficial effects: This application provides a deep learning prediction method and system for urban water supply based on variable weights. This scheme obtains historical data of urban water plants and performs data preprocessing. Then, it calculates time-based sample weights based on the preprocessed historical data of urban water plants to obtain sample weight values of historical data of urban water plants. Furthermore, based on a long short-term memory neural network, it introduces the sample weight values of historical data of urban water plants to construct a long short-term memory network model based on variable weights. By introducing a weighted loss function, it effectively solves the limitations of traditional LSTM models in predicting water supply demand with unbalanced importance of different periods, significantly improves the prediction accuracy of water supply demand during peak periods, and enables the accuracy of peak water demand prediction to meet actual scheduling needs. Attached Figure Description
[0050] Figure 1 This is a flowchart of a deep learning prediction method for urban water supply based on variable weights provided in an embodiment of this application;
[0051] Figure 2 This is a schematic diagram of the structure of a deep learning prediction system for urban water supply based on variable weights provided in an embodiment of this application;
[0052] Figure 3 This is a schematic diagram of the structure of a traditional LSTM model provided in the embodiments of this application;
[0053] Figure 4 This is a schematic diagram illustrating the principle of the variable-weight long short-term memory network model provided in the embodiments of this application;
[0054] Figure 5 This is a time series diagram of historical data of urban water plants provided in the embodiments of this application;
[0055] Figure 6 This is a histogram diagram illustrating the distribution of historical data of urban water plants provided in an embodiment of this application;
[0056] Figure 7 This is a correlation diagram of historical data of urban water plants provided in the embodiments of this application;
[0057] Figure 8This is a schematic diagram illustrating the relationship between the water demand of a water company and the sample weights provided in an embodiment of this application.
[0058] Figure 9 This is a schematic diagram of the prediction results of the Long Short-Term Memory Network model based on variable weights provided in the embodiments of this application. Detailed Implementation
[0059] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit it. In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with those of this application; they are merely examples of systems and methods consistent with some aspects of the embodiments of this application as detailed in the appended claims.
[0060] It is understood that the terms “first,” “second,” etc., used in this application may be used herein to describe various concepts, but unless otherwise stated, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the words “if,” “when,” or “in response to a determination” as used herein may be interpreted as “when…” or “when…” or “in response to a determination.”
[0061] As used in this application, the terms "at least one", "multiple", "each", "any", etc., "at least one" includes one, two or more, "multiple" includes two or more, "each" refers to each of the corresponding multiples, and "any" refers to any one of the multiples.
[0062] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0063] Reference Figure 1 , Figure 1 A flowchart illustrating a deep learning method for predicting urban water supply based on variable weights, provided in this embodiment of the invention, is shown below. Figure 1 The method includes the following steps:
[0064] S100. Obtain historical data of urban water plants and perform data preprocessing to obtain preprocessed historical data of urban water plants.
[0065] It should be noted that in some embodiments, step S100 may include: S110, acquiring historical data of the urban water plant, the historical data of the urban water plant including urban water demand data, water pressure data and temperature data; S120, cleaning the historical data of the urban water plant to obtain cleaned historical data of the urban water plant; S130, supplementing missing values in the cleaned historical data of the urban water plant using the linear value method to obtain supplemented historical data of the urban water plant; S140, performing outlier detection processing on the supplemented historical data of the urban water plant based on the 3σ principle to obtain detected historical data of the urban water plant; S150, performing time resampling processing on the detected historical data of the urban water plant to obtain preprocessed historical data of the urban water plant.
[0066] In some specific embodiments, data collection, mainly including water demand, pressure, and temperature, is performed using intelligent sensors integrated into the water pump.
[0067] Further data preprocessing is required. For the collected raw data, data cleaning, missing value imputation, outlier handling, and time resampling are necessary. Missing value imputation mainly uses the linear value method. Assuming we know the coordinates (x0, y0) and (x1, y1), to obtain the value of x at a certain position on the line within the interval [x0, x1], the relevant calculation formula is as follows:
[0068]
[0069] In the above formula, x0, y0, x1, and y1 represent known coordinate values, and x and y represent the coordinate values of the target location.
[0070] Outlier handling employs the 3σ principle, classifying sample points more than three standard deviations from the mean as outliers and correcting them to three standard deviations to avoid adverse effects on prediction results. Time series processing primarily involves resampling the running data to ensure consistency in time intervals across different data sources. Depending on the data collection frequency, resampling includes upsampling and downsampling. Upsampling increases the data frequency, transforming it into smaller time intervals, while downsampling decreases the data frequency, transforming it into larger time intervals.
[0071] S200. Calculate the time-based sample weights based on the preprocessed historical data of urban water plants to obtain the sample weight values of the historical data of urban water plants.
[0072] It should be noted that, in some embodiments, step S200 may include:
[0073] S210. Obtain the peak and off-peak periods of the preprocessed historical data of the urban water plant, and calculate the distance between the peak and off-peak periods of the historical data of the urban water plant.
[0074] In this embodiment, the water demand distribution characteristics are analyzed first. Urban tap water demand exhibits a relatively obvious daily periodicity, generally with multiple peak and trough periods throughout the 24 hours of a day. Data analysis can pinpoint peak and trough periods, and the sample points at time t are compared with those at peak periods t... peak and the trough period t vALLEY distance d T As the basis for calculating sample weights, the relevant calculation formulas are as follows:
[0075] d T =min(|tt) PEAk |,|tt valley |)
[0076] In the above formula, d t This represents the distance between peak and off-peak periods in historical data for a city water plant, where t represents time, and min(·) indicates the minimum value operation. peak t represents peak hours. valley Indicates a low point in the day.
[0077] Where time t happens to be either a peak or a trough, d t d equals 0; when it is in between, d t There is a maximum value.
[0078] S220. Determine the importance index ratio between peak and off-peak periods;
[0079] S230. Based on the importance index multiple, and combined with the distance between peak and off-peak periods in the historical data of urban water plants, time-based sample weights are calculated to obtain preliminary sample weight values for the historical data of urban water plants.
[0080] S240. The initial weight values of the historical data samples of urban water plants are scaled to obtain the weight values of the historical data samples of urban water plants.
[0081] In some specific embodiments, further time-based sample weighting is used, stipulating that the importance of the highest peak is a times the importance of the lowest trough, then according to d t The initial weights are calculated using the following expression:
[0082]
[0083] In the above formula, w T0 This represents the preliminary historical data sample weights for urban water plants, where 'a' represents the importance index multiple, and 'd' represents the weights.t This represents the distance between peak and off-peak periods in the historical data of the city's water plant, where t represents time, and max(·) indicates the operation of taking the maximum value.
[0084] Where time t happens to be either a peak or a trough, i.e., d t equals 0, w t0 When 'a' equals 't', the weight is the largest; when time 't' is furthest from the peak or trough period, i.e., 'd'... t equals max(d) t ), w t0 When the value equals 1, the weight is at its minimum. To ensure consistency in sample weights, the weight values are scaled, and the expression is as follows:
[0085]
[0086] In the above formula, w t0 w represents the preliminary historical data sample weights for urban water plants. t denoted by , where N represents the total number of training samples and t represents the time point.
[0087] S300: Based on the Long Short-Term Memory Neural Network, a Long Short-Term Memory Network Model with Variable Weights is constructed by introducing the weight values of historical data samples from urban water plants.
[0088] It should be noted that, in some embodiments, step S300 may include:
[0089] S310. Based on the long short-term memory neural network, feature selection is performed using the Pearson correlation coefficient to obtain the selected long short-term memory neural network.
[0090] In this embodiment, LSTM (Long Short-Term Memory Neural Network) is a special type of recurrent neural network (RNN) that excels at processing sequential data. The core of LSTM lies in its unit structure, which effectively solves the gradient vanishing and gradient exploding problems that are common in traditional RNNs, thereby better capturing long-term dependencies in sequential data.
[0091] Among them, such as Figure 3 As shown, LSTM specifically includes a forget gate, an input gate, an update cell state, and an output gate.
[0092] The forget gate is used to read the hidden state h from the previous time step. t-1 and the current input x t Output a forgetting vector f t This indicates which information needs to be discarded.
[0093] The input gate is used to read the hidden state h from the previous time step. t-1and the current input x t Output an input vector i t and a candidate cell state c t This indicates which information needs to be added to the cell state.
[0094] Updating the cell state is done using the forgetting vector f t The cell state c from the previous moment t-1 Discard the information in the input vector i and use the input vector i T Candidate cell state c t The information is added to the cell state to obtain the cell state c at the current time. T .
[0095] The output gate is used to read the cell state c at the current moment. t and the current input x t Output a single output vector o t This indicates which information needs to be output.
[0096] The calculation formulas for each step in the LSTM workflow are as follows:
[0097] Forgotten Gate: f t =σ(W f ·[h t -1,x t ]+b f )
[0098] Input gate: i t =σ(W i ·[h t -1,x t ]+b i )
[0099] Output gate: o t =σ(W o ·[h t -1,x t ]+b o )
[0100] Unit state: c t =tanh(W c ·[h t -1,x t ]+b c )
[0101] Hidden state: h t =o t ·tanh(c t )
[0102] Update unit state: c t =f tc t -1+i t ·c t
[0103] In the above formula: f t i t o t Let c represent the output vectors of the forget gate, input gate, and output gate, respectively. t h represents the cell state at the current moment. t Let W represent the hidden state at the current time step, σ represent the sigmoid function, tanh represent the hyperbolic tangent function, and W represent the hidden state at the current time step. f W i W c W o Let b represent the weight matrices for the forget gate, input gate, cell state, and output gate, respectively. f b i b c b o These represent the bias vectors for the forget gate, input gate, cell state, and output gate, respectively.
[0104] Feature selection can eliminate irrelevant or redundant features, thereby reducing the number of features, improving model accuracy, and reducing runtime. The Pearson correlation coefficient measures the linear correlation between each feature and the target value. The correlation coefficient is a dimensionless statistical indicator, with a range of -1 ≤ r ≤ 1. A correlation coefficient less than 0 indicates a negative correlation, greater than 0 indicates a positive correlation, and 0 indicates no correlation. The larger the absolute value of the Pearson correlation coefficient, the stronger the correlation between the two variables. By setting a correlation threshold, features are selected for model training. The calculation formula is shown below:
[0105]
[0106] In the above formula, r represents the Pearson correlation coefficient, and X and Y represent the eigenvalue and target value, respectively. and These represent their respective means.
[0107] S320. Based on the loss function of the selected long short-term memory neural network, a weighted processing of the weight values of historical data samples from urban water plants is added to obtain a weighted long short-term memory network model.
[0108] In this embodiment, as Figure 4 As shown, the loss function based on variable weights for LSTM is established. By adding variable sample weights to the basic loss function of the basic LSTM model, the loss value for different observations is adjusted. The relevant formulas are shown below:
[0109] Basic loss function:
[0110] Loss function based on variable weights:
[0111] In the above formula, L represents the basic loss function, L′ represents the loss function of the long short-term memory network model based on variable weights, and N represents the total number of training samples. y represents the model's predicted value. t w represents the sample observations. t This represents the weight value of historical data samples from the city's water plant, and t represents the time period.
[0112] S330. The learning rate and batch size of the weighted long short-term memory network model are adjusted using the PyTorch algorithm to obtain a long short-term memory network model based on variable weights.
[0113] In some specific embodiments, model training is based on PyTorch, a deep learning framework based on Torch that simplifies the construction and training process of deep learning models. The model described above is trained using PyTorch, and model training performance is ensured by adjusting the learning rate and batch size.
[0114] The S400 model, based on a variable weighted long short-term memory network, predicts the water supply volume of preprocessed historical data of urban water plants, and obtains the prediction results of urban water supply volume.
[0115] It should be noted that in some embodiments, step S400 may include: S410, performing data partitioning on the preprocessed historical data of the urban water plant to obtain a training set and a test set; S420, training a variable-weight long short-term memory network model using the training set to obtain a trained variable-weight long short-term memory network model; S430, predicting water supply volume on the test set based on the trained variable-weight long short-term memory network model to obtain preliminary urban water supply volume results; S440, performing inverse normalization on the preliminary urban water supply volume results to obtain urban water supply volume prediction results.
[0116] In some specific embodiments, the sample data is first divided. The processed time series dataset is divided into training and test sets in an 8:2 ratio, meaning 80% of the data is used to train the model, and the remaining 20% is used to evaluate the model's performance and further validate the model's effectiveness. After training, predictions are made on the test set, and the prediction results are inversely normalized. The root mean square error (RMSE) and decision coefficient (R²) are selected. 2 Two performance metrics are used to evaluate the training results.
[0117] In summary, this invention employs a weighted long short-term memory (LSTM) network model for water demand forecasting. By introducing a weighted loss function, it effectively addresses the limitations of traditional LSTM models in predicting water demand with unbalanced time-time importance, significantly improving the prediction accuracy for peak-hour water demand. This overcomes the aforementioned shortcomings of existing technologies in accurately predicting urban tap water supply during peak and off-peak periods, thereby guiding water plants to adjust pump station combinations in a timely manner to minimize energy consumption while meeting the needs of downstream residents.
[0118] Finally, a simulation experiment was conducted on the embodiment of the present invention, as shown below:
[0119] Based on the operational data of a water plant in a certain city from March 1, 2020 to February 28, 2023, the above method is described in detail.
[0120] First, data from 26,280 samples were collected over 3 years (365 days × 24 hours) from March 1, 2020 to February 28, 2023, including characteristics such as water demand, pressure, and temperature. The data was preprocessed to remove outliers and missing values. Specifically... Figure 5 , Figure 6 as well as Figure 7 As shown.
[0121] Furthermore, using a 24-hour time window, and setting a = 2, the maximum weight of the sample is twice the minimum weight. For example... Figure 8 The figure shows the normalized water demand and its sample weights for a total of 240 hours from February 1, 2023 to February 28, 2023.
[0122] Then, based on the correlation coefficient method, historical water demand, pressure, and temperature are selected as features to predict water demand.
[0123] Finally, the root mean square error (RMSE) and decision coefficient (R²) were selected. 2 Two performance metrics were used to compare the standard LSTM model and the weighted LSTM model. The experimental results are shown in Table 1.
[0124] Table 1 Comparison of LSTM Model Evaluation Results
[0125] \ RMSE <![CDATA[R 2 ]]> PRMSE Original LSTM 1043.16 91.53% 1347.15 Weighted LSTM 1032.76 91.79% 1214.17 Sample size 5251 5251 919
[0126] like Figure 9As shown, the period from February 19th to February 28th, 2023 was selected as the demonstration sample, and the actual data values, the predicted values of the original LSTM model, and the predicted values of the weighted LSTM model were obtained. Based on the comparison of the actual values, the model performance of the original LSTM model, and the predicted values of the weighted LSTM model, it can be intuitively concluded that both models generally perform close to the actual values, with good results and relatively consistent performance. However, for the prediction of peak values, the weighted LSTM model is significantly better than the original LSTM model.
[0127] Please see Figure 2 This application also provides a deep learning prediction system for urban water supply based on variable weights, which can implement the above-mentioned deep learning prediction method for urban water supply based on variable weights. The system includes:
[0128] The first module 201 is used to acquire historical data of urban water plants and perform data preprocessing to obtain preprocessed historical data of urban water plants.
[0129] The second module 202 is used to perform time-based sample weight calculation based on the preprocessed historical data of urban water plants to obtain the sample weight value of historical data of urban water plants.
[0130] The third module 203 is used to construct a long short-term memory network model based on variable weights by introducing the weight values of the historical data samples of the urban water plant based on the long short-term memory neural network.
[0131] The fourth module 204 is used to predict the water supply based on the preprocessed historical data of the urban water plant using the variable weight long short-term memory network model, and to obtain the urban water supply prediction result.
[0132] It is understood that the content of the above method embodiments is applicable to this system embodiment. The specific functions implemented in this system embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0133] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.
Claims
1. A deep learning method for predicting urban water supply based on variable weights, characterized in that, The method includes the following steps: Historical data of urban water plants are acquired and preprocessed to obtain preprocessed historical data of urban water plants. Based on the preprocessed historical data of urban water plants, time-based sample weights are calculated to obtain the sample weight values of the historical data of urban water plants. Based on the long short-term memory neural network, the weight values of the historical data samples of the urban water plant are introduced to construct a long short-term memory network model based on variable weights. Based on the variable-weight long short-term memory network model, the water supply of the preprocessed urban water plant historical data is predicted to obtain the urban water supply prediction result. Specifically, based on the preprocessed historical data of urban water plants, time-based sample weight calculations are performed to obtain the sample weight values of the historical data of urban water plants, including: The peak and off-peak periods of the preprocessed historical data of the urban water plant are obtained, and the distance values are calculated to obtain the distance values between the peak and off-peak periods of the historical data of the urban water plant. Determine the importance index multiple between the peak period and the trough period; Based on the importance index multiple, and combined with the distance between peak and off-peak periods in the historical data of the urban water plant, a time-based sample weight calculation is performed to obtain the preliminary sample weight values of the historical data of the urban water plant. The initial weight values of the historical data samples of urban water plants are scaled to obtain the weight values of the historical data samples of urban water plants. The method for constructing a variable-weight long short-term memory network model based on a long short-term memory neural network, by incorporating historical data sample weights from the urban water plant, includes: Based on the long short-term memory neural network, feature selection is performed using the Pearson correlation coefficient to obtain the selected long short-term memory neural network. Based on the loss function of the selected long short-term memory neural network, a weighted processing of the weight values of the historical data samples of the urban water plant is added to obtain a weighted long short-term memory network model. The weighted long short-term memory network model was processed by adjusting the learning rate and batch size using the PyTorch algorithm to obtain a long short-term memory network model based on variable weights.
2. The method according to claim 1, characterized in that, Historical data of urban water plants was acquired and preprocessed to obtain preprocessed historical data of urban water plants, including: Acquire historical data from urban water plants, including urban water demand data, water pressure data, and temperature data. Data cleaning is performed on the historical data of urban water plants to obtain cleaned historical data of urban water plants. The missing values of the cleaned historical data of the urban water plant were supplemented by linear value method to obtain the supplemented historical data of the urban water plant. Based on the 3σ principle, outlier detection processing was performed on the supplemented historical data of urban water plants to obtain the detected historical data of urban water plants. The historical data of urban water plants after testing were subjected to time resampling to obtain preprocessed historical data of urban water plants.
3. The method according to claim 2, characterized in that, The expression for the linear value is as follows: ; In the above formula, , , , Indicates known coordinate values. , The coordinates of the target location.
4. The method according to claim 1, characterized in that, The specific formula for calculating the weight values of the preliminary historical data samples of urban water plants is as follows: ; In the above formula, This indicates the preliminary sample weight values for historical data of urban water plants. Indicates the multiple of importance indicators. This represents the distance between peak and off-peak periods in historical data for urban water plants. Indicates time, This indicates the operation of taking the maximum value.
5. The method according to claim 1, characterized in that, The expression for scaling the initial historical data sample weights of urban water plants is shown below: ; In the above formula, This indicates the preliminary sample weight values for historical data of urban water plants. This represents the weight value of historical data samples from urban water plants. This represents the total number of training samples. Indicates the time.
6. The method according to claim 1, characterized in that, The specific expression for the loss function of the variable-weight long short-term memory network model is as follows: ; In the above formula, This represents the loss function of a long short-term memory network model based on variable weights. This represents the total number of training samples. This represents the model's predicted value. Represents sample observations. This represents the weight value of historical data samples from urban water plants. Indicates the time.
7. The method according to claim 1, characterized in that, The long short-term memory network model based on the variable weights predicts the water supply volume of the preprocessed historical data of the urban water plant, and obtains the urban water supply prediction results, including: The preprocessed historical data of urban water plants is divided into training and testing sets. The variable-weight long short-term memory network model is trained using the training set to obtain the trained variable-weight long short-term memory network model. Based on the trained variable-weight long short-term memory network model, water supply is predicted for the test set to obtain preliminary urban water supply results. The preliminary urban water supply data is inversely normalized to obtain the predicted urban water supply data.
8. A deep learning prediction system for urban water supply based on variable weights, characterized in that, The system includes: The first module is used to acquire historical data of urban water plants and perform data preprocessing to obtain preprocessed historical data of urban water plants. The second module is used to perform time-based sample weight calculation based on the preprocessed historical data of urban water plants to obtain the sample weight value of the historical data of urban water plants. The third module is used to construct a long short-term memory network model based on variable weights by introducing the weight values of historical data samples from the city's water plant, based on a long short-term memory neural network. The fourth module is used to predict the water supply based on the preprocessed historical data of the urban water plant using the variable-weight long short-term memory network model, and to obtain the urban water supply prediction result. The step of calculating time-based sample weights based on the preprocessed historical data of urban water plants to obtain sample weight values for the historical data of urban water plants includes: The peak and off-peak periods of the preprocessed historical data of the urban water plant are obtained, and the distance values are calculated to obtain the distance values between the peak and off-peak periods of the historical data of the urban water plant. Determine the importance index multiple between the peak period and the trough period; Based on the importance index multiple, and combined with the distance between peak and off-peak periods in the historical data of the urban water plant, a time-based sample weight calculation is performed to obtain the preliminary sample weight values of the historical data of the urban water plant. The initial weight values of the historical data samples of urban water plants are scaled to obtain the weight values of the historical data samples of urban water plants. The method for constructing a variable-weight long short-term memory network model based on a long short-term memory neural network, by incorporating historical data sample weights from the urban water plant, includes: Based on the long short-term memory neural network, feature selection is performed using the Pearson correlation coefficient to obtain the selected long short-term memory neural network. Based on the loss function of the selected long short-term memory neural network, a weighted processing of the weight values of the historical data samples of the urban water plant is added to obtain a weighted long short-term memory network model. The weighted long short-term memory network model was processed by adjusting the learning rate and batch size using the PyTorch algorithm to obtain a long short-term memory network model based on variable weights.
Citation Information
Patent Citations
Water level prediction method based on weight correction and DRSN-LSTM model
CN115099500A
Method for predicting rotating stall of axial flow compressor on the basis of stacked long short-term memory network
WO2023056614A1