Short-time water supply prediction method based on improved Bayesian optimization algorithm

By improving Bayesian optimization algorithm and building the CNN-BiLSTM model, the problem of insufficient prediction accuracy and generalization capabilities of traditional water supply prediction methods in nonlinear and long-term data dependence is solved, and more efficient and accurate short-term water supply prediction is achieved.

CN119558471AInactive Publication Date: 2025-03-04ZHEJIANG NINGSHUI WATER TECH CO LTD

Patent Information

Application Number
CN202411633437.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-15
Publication Date
2025-03-04
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When traditional water supply prediction methods face nonlinear and long-term dependent water supply data, the prediction accuracy and generalization ability are poor, and it is difficult to capture and learn the characteristic relationship of historical data. The parameter adjustment is complex and time-consuming, and it is strong subjective but not objective enough, and there are problems of uncertainty and poor generalization.

Method used

A short-time water supply prediction method based on an improved Bayesian optimization algorithm is adopted, and a CNN-BiLSTM short-time water supply prediction model is constructed through steps such as data preprocessing, parameter tuning, model training and prediction execution. The improved Bayesian optimization algorithm is used to tune the model parameters to improve prediction accuracy and speed.

Benefits of technology

It improves the accuracy and speed of short-term water supply prediction, reduces parameter adjustment and attempt time, improves the prediction performance and accuracy of the model, and avoids the problems of complexity and uncertainty in traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119558471A_ABST
    Figure CN119558471A_ABST
Patent Text Reader

Abstract

The invention discloses a short-time water supply prediction method based on an improved Bayesian optimization algorithm, and the method has the advantages that the limitations of complex parameter adjustment, low prediction convergence speed, long time consumption, poor generalization, low prediction precision and the like of a conventional water supply prediction method in the face of complex water supply system data are overcome, the advantages of CNN (Convolutional Neural Network) and BiLSTM (Bidirectional Long Short Term Memory) are combined, and the prediction accuracy is improved. According to the method, a deep learning model capable of capturing local features and a long-term dependency relationship in water supply data at the same time is provided, an update type data storage mode is adopted, and historically stored data is continuously updated through data input by a user, so that the trained model is perfected, and the prediction precision is improved. Besides, through the improved Bayesian optimization algorithm, the network structure and parameter configuration of the model can be automatically adjusted, the parameter adjustment and optimization efficiency of the model is improved, human intervention is reduced, and the prediction precision and real-time performance of the model are improved, so that effective support is provided for management and optimization of the urban water supply system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of water supply prediction, and in particular to a short-term water supply prediction method based on an improved Bayesian optimization algorithm. Background Art

[0002] The water supply system is an important part of urban infrastructure. Reasonable water supply scheduling and management are of great significance to ensure the normal operation of the city, save water resources and improve the utilization rate of water resources. With the acceleration of urbanization, the fluctuation and change of water supply are becoming more and more complex. Water supply managers are faced with problems such as inaccurate water supply forecasting and poor timeliness. Especially in the face of seasonal changes, population fluctuations, climate anomalies and other factors, traditional water supply forecasting models are difficult to meet the needs.

[0003] At present, traditional water supply forecasting methods such as linear regression, time series models (such as ARIMA), back propagation neural network (BPNN), etc., can play a certain role in forecasting when the data features are relatively simple, but they have obvious limitations, especially when facing nonlinear and long-term dependent water supply data, their forecasting accuracy and generalization ability are poor, and it is difficult to capture and learn the characteristic relationship of historical data. In addition, with the development of smart water services, water supply forecasting not only needs to process large-scale, high-dimensional historical data, but also needs to have real-time update and forecasting capabilities, which puts higher requirements on traditional models.

[0004] ① Linear regression model: This method mainly establishes a linear relationship between the characteristic variable (independent variable) and the predicted target variable (dependent variable), and estimates the parameters of each independent variable through the commonly used least squares method, then fits the data to calculate the residual value to verify its normality, and finally inputs the future independent variable to calculate the future value;

[0005] ②ARIMA model: This model prediction method is actually similar to linear regression. It believes that there is a linear relationship between the current data value and the historical value, and between the fitted value and the historical value. The least squares method is used to estimate the parameter values ​​in this linear relationship. However, it combines autoregression AR(q) with moving average MA(p) and stationary difference, requiring the input model data to be stationary. After stationary, autocorrelation and partial autocorrelation diagrams are drawn to confirm the possible values ​​of q and p respectively, forming multiple possible fitting models. The model is fitted and the best model is selected using certain criteria (such as Bayesian minimum information criterion BIC). Then, the normality of the model is verified by the residual of the fitting, and finally the prediction is made.

[0006] ③BPNN model: It is a nonlinear model. Generally, the input is multiple eigenvalues. It imitates the biological nervous system and forms a mesh structure. The core idea is to adjust the weights and biases through the back propagation of errors until the accuracy requirements are met or the maximum number of iterations is reached. Its structure consists of an input layer, a hidden layer, and an output layer. The core calculation is completed in the hidden layer. Its main steps include forward propagation (assigning random weights), activation functions (Sigmoid, ReLU, Tanh, etc.) to convert outputs, calculate losses (calculate the error between actual values ​​and fitted values), back propagation (using the chain rule to calculate the gradient of the loss function for each weight and bias), and optimization algorithms (such as gradient descent) to update weights and biases. Repeat the above steps until the preset accuracy requirements are met or the maximum number of iterations is reached.

[0007] For example, in the publicly published paper "Railway Passenger Volume Forecast and Empirical Analysis Based on Linear Regression Model", univariate and multivariate linear regression models were established with Zhengzhou's railway passenger volume and influencing factors as original data; the univariate regression model is established for each influencing factor, while the multivariate regression model is established as a whole; the influence of each factor is judged by analyzing the variable coefficient of the univariate regression model of each factor and the significance and goodness of fit of the overall regression equation; the establishment of the multivariate regression equation is to test the multicollinearity of the model and use the stepwise regression analysis method to correct it to form the best multivariate model. The prediction results show that the relative errors in 2017 and 2018 were controlled within 2%, and the prediction effect was good.

[0008] In the recently published journal paper "Prediction of the Proportion of Digital Economy in GDP Based on ARIMA and BP Neural Network Models", ARIMA and BP neural networks were used to extract the linear and nonlinear characteristics of the time series of the proportion of digital economy in GDP, and models were established and predicted respectively; the former established an ARIMA (1, 2, 2) model with a prediction accuracy of 98.32% and an error variance of 0.46; the latter determined a 1-7-1 three-layer BP neural network with a prediction accuracy of 98.71% and an error variance of 0.31; then the two sets of prediction values ​​were weighted and added using the equal weighting method and the inverse variance weighting method, and the prediction accuracies of the two weighting methods were 98.80% and 98.71%, and the error variances were 0.30 and 0.31, respectively;

[0009] The above three models have all studied time series to a certain extent and achieved relatively good prediction results, but they all have some defects. For example, in the linear regression model, it is one-sided to select several influencing factors as independent variables to fit the linear model based on personal subjective judgment; not only that, in most cases, the data is a mixture of linear and nonlinear features, and it is difficult to learn comprehensive features using only linear models. Therefore, in the second paper, ARIMA is combined with BP neural network, and weights are assigned in parallel to obtain combined prediction results, and a higher-precision prediction value is obtained. However, the combination method of this method is to calculate the weights simply from the prediction error of the test set. If only combined prediction is performed in the test set, the accuracy will definitely be improved, and the prediction of the future will be uncertain, because the generalization ability of multiple model combinations is different; in general, the above three models have defects such as general learning ability, complex and time-consuming parameter adjustment, strong subjectivity and lack of objectivity, strong uncertainty, poor generalization, mechanization of the prediction process and difficulty in user application. Summary of the invention

[0010] A technical problem to be solved by the present application is to overcome the defects of the above-mentioned related technologies and provide a short-term water supply prediction method with fast and accurate prediction speed while prioritizing parameter adjustment.

[0011] The technical solution adopted by the present invention to solve the above technical problems is: a short-term water supply prediction method based on an improved Bayesian optimization algorithm, which specifically includes the following steps:

[0012] Step 1: Data preprocessing: Select the raw data for prediction based on the water supply data and features input by the user;

[0013] Step 2: Parameter tuning: Use the improved Bayesian optimization algorithm to tune multiple parameters of the model and select the best parameter combination through the loss function;

[0014] Step 3: construct a data set according to the optimal parameter combination, wherein the data set includes a training set, a validation set, and a test set;

[0015] Step 4: Model training: construct a CNN-BiLSTM short-term water supply prediction model, use the training set to train the model, and obtain a trained CNN-BiLSTM neural network;

[0016] Step 5: Execute prediction: Use the trained CNN-BiLSTM neural network to predict the validation set, test set, and future respectively, and obtain the validation set prediction value, test set prediction value, and future prediction value;

[0017] Step 6: Visualize the prediction results: Draw a line graph of the original data, validation set and validation set prediction value, test set and test set prediction value, and future prediction value on the same graph to intuitively show the prediction effect.

[0018] Preferably, the data preprocessing in step 1 specifically includes:

[0019] Step 11, data input: input a single column time series of water supply, data type, detection interval, device name, detection start and end time, and future prediction steps;

[0020] Step 12: Data selection: Use the data parameter storage and update mechanism to select the original data for prediction.

[0021] Preferably, the data parameter storage and update mechanism is specifically as follows:

[0022] Search for structures with the same characteristics in historical data based on user input data and parameters;

[0023] If there is no identical feature, save the structure and output the judgment result 1;

[0024] If the same features exist and the input data are all the same, save the structure and output the judgment result 2;

[0025] If there are the same features but the input data are not all the same, determine whether the input data overlaps; if there is input data overlap, determine whether there is predicted supplementary data in the overlapping part; if there is predicted supplementary data, replace the overlapping part with the newly input data; if there is no predicted supplementary data, replace the predicted data with the data of the corresponding time, and splice the rest, save the structure and output the judgment result 3; if the input data does not overlap, calculate the difference between the monitoring start time and the end time, determine whether the difference is within the threshold, if the difference is within the threshold, directly splice, save the structure and output the judgment result 3; if the difference is not within the threshold, predict the supplementary data value and splice, save the structure and output the judgment result 3. Adopting the update type and structure data storage method, the historical stored input data is continuously updated through user input data, thereby improving the trained model and improving the prediction accuracy.

[0026] As an improvement, if there are some outliers or missing values ​​in the input data in step 11, the input data is cleaned using the isolation forest method of multi-dimensional sub-sampling to exclude outliers and fill them with linear interpolation.

[0027] Preferably, the calculation method of the isolation forest method of the multi-dimensional sub-sample is as follows:

[0028] a1) Path length

[0029] For each sample x, its path length h(x) in the isolation tree is defined as the distance from the root node to the leaf node of the sample, where at each node, the sample x is randomly divided into the left subtree or the right subtree; each division increases the path length, and when the sample reaches a leaf node, the current path length is returned;

[0030] Average path length formula:

[0031]

[0032] Where H(n) is the nth harmonic number, defined as:

[0033] H(n)=ln(n)+γ

[0034] Where γ is Euler's constant;

[0035] The average path length c(n) is used to normalize the path length so that the differences in path length can be compared between data of different scales;

[0036] a2) Anomaly score calculation: The anomaly score reflects the probability that a sample point is considered anomaly. The anomaly score of the isolation forest is based on the average path length of the sample point in all trees; the shorter the path, the easier it is for the sample to be isolated and the greater the possibility of being considered anomaly; the calculation formula is as follows:

[0037]

[0038] Among them, E(h(x)) is the average path length of all isolated trees of sample x in the isolation forest, and c(n) is the average path length based on the number of samples n;

[0039] The value range of anomaly score is [0,1]:

[0040] S(x,n)≈1 means that the sample point x is very easy to be isolated, so it is more likely to be an outlier; S(x,n)≈0 means that the sample point x is difficult to be isolated, so it is more likely to be a normal point;

[0041] a3) Split point selection: In the process of building an isolation tree, each node will select a random split point; for each sample set X, a value is randomly selected as the split point, the formula is as follows:

[0042] Y s =min(X)+rand()×(max(X)-min(X))

[0043] Among them, rand() is a uniformly distributed random number, ensuring that the split point is randomly selected between the minimum and maximum values ​​of the sample. The isolation forest method with multi-dimensional sub-sampling is used to optimize the sampling points of the Bayesian optimization algorithm, making the sampling points closer to the optimal combination.

[0044] Preferably, the improvement of the improved Bayesian optimization algorithm lies in the optimization of the initial sampling points:

[0045] For sampling n points in the d-dimensional parameter space, the value range of each dimension is:

[0046] [a i ,b i ]

[0047] Latin square sampling:

[0048] b1) Divide each dimension into n equally spaced intervals: For each dimension i, divide the interval into n subintervals:

[0049]

[0050] The boundaries of each interval are:

[0051]

[0052] These intervals are Latin square series;

[0053] b2) Randomly select a point in each interval: For each dimension i, randomly select a point in each interval:

[0054]

[0055] where u i It is a random number uniformly distributed from 0 to 1, which is used to ensure the randomness of sampling;

[0056] b3) Randomly disrupt the selection order of intervals: For each dimension i, randomly disrupt the selection order of n intervals to ensure that each interval sample is only used once in a certain dimension;

[0057] b4) Combining sample points of each dimension: Finally, the sample points are generated by selecting p in each dimension. i , forming n sample points;

[0058] Specifically, for the i-th dimension, n points are sampled within its interval range, and the formula used by the Latin square is as follows:

[0059]

[0060] Where i is the dimension index and j is the sample index. Latin square sampling is used to reduce sampling point errors and increase efficiency.

[0061] Compared with the related art, the present invention has the following advantages: in terms of parameter optimization, the present invention is placed before building a CNN-BiLSTM short-term water supply prediction model; and in terms of prediction accuracy, the present invention adopts an improved Bayesian optimization algorithm to optimize the hyperparameters of the model, and uses the isolation forest method of multi-dimensional sub-samples to optimize the sampling points of the Bayesian optimization algorithm, so that the sampling points are closer to the optimal combination, and according to the minimum value of the loss function output during the optimization process, the best parameter combination suitable for the current input data is accurately captured, which greatly improves the model prediction performance and accuracy; in contrast, optimizing the parameters after the model is built results in that the initial hyperparameter configuration of the model is not optimal, which affects the early training effect and thus affects the final accuracy.

[0062] In terms of prediction speed, hyperparameters are optimized before building the model, so that the model uses the best parameter combination during training, reducing the time for later parameter adjustment and trial, thus improving the overall prediction speed. On the contrary, if the model is optimized after construction, the overall prediction time will be extended, especially in the case of (multi-parameter) high dimensions, parameter adjustment becomes particularly complicated, and it is difficult to determine which parameter is more sensitive.

[0063] Theoretically, the improved Bayesian optimization can find the global optimal hyperparameter combination more quickly through an iterative method, avoiding the limitations of grid search and random search. Therefore, performing Bayesian optimization before model training can avoid unsatisfactory training results caused by poor initial parameter settings. In addition, the adaptive nature of Bayesian optimization also makes it more efficient than traditional hyperparameter tuning methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] Figure 1 It is a flow chart of this application.

[0065] Figure 2 This is the logic diagram of the data parameter storage and update mechanism of this application.

[0066] Figure 3 This is a diagram showing the prediction results based on the verification example of this application. DETAILED DESCRIPTION

[0067] First, those skilled in the art should understand that these implementations are only used to explain the technical principles of the embodiments of the present application, and are not intended to limit the protection scope of the embodiments of the present application. Those skilled in the art can make adjustments to them as needed to adapt to specific application scenarios.

[0068] The present invention is further described in detail below with reference to specific embodiments.

[0069] The present invention Figure 1 The figure shows a short-term water supply prediction method based on an improved Bayesian optimization algorithm, which specifically includes the following steps:

[0070] Step 1: Data preprocessing: Select the raw data for prediction based on the water supply data and features input by the user;

[0071] Step 2: Parameter tuning: Use the improved Bayesian optimization algorithm to tune multiple parameters of the model and select the best parameter combination through the loss function;

[0072] Step 3: construct a data set according to the optimal parameter combination, wherein the data set includes a training set, a validation set, and a test set;

[0073] Step 4: Model training: construct a CNN-BiLSTM short-term water supply prediction model, use the training set to train the model, and obtain a trained CNN-BiLSTM neural network;

[0074] Step 5: Execute prediction: Use the trained CNN-BiLSTM neural network to predict the validation set, test set, and future respectively, and obtain the validation set prediction value, test set prediction value, and future prediction value;

[0075] Step 6: Visualize the prediction results: Draw a line graph of the original data, validation set and validation set prediction value, test set and test set prediction value, and future prediction value on the same graph to intuitively show the prediction effect.

[0076] Preferably, the data preprocessing in step 1 specifically includes:

[0077] Step 11, data input: input a single column time series of water supply, data type, detection interval, device name, detection start and end time, and future prediction steps;

[0078] Step 12: Data selection: Use the data parameter storage and update mechanism to select the original data for prediction.

[0079] Preferably, the data parameter storage and update mechanism is as follows: Figure 2 Specifically shown are:

[0080] Search for structures with the same characteristics in historical data based on user input data and parameters;

[0081] If there is no identical feature, save the structure and output the judgment result 1;

[0082] If the same features exist and the input data are all the same, save the structure and output the judgment result 2;

[0083] If there are the same features but the input data are not all the same, then determine whether the input data overlaps; if there is input data overlap, determine whether there is predicted supplementary data in the overlapping part; if there is predicted supplementary data, replace the overlapping part with the new input data in time, if there is no predicted supplementary data, replace the predicted data with the data of the corresponding time, and splice the rest, save the structure and output the judgment result 3; if the input data does not overlap, calculate the difference between the monitoring start time and the end time, determine whether the difference is within the threshold, if the difference is within the threshold, directly splice, save the structure and output the judgment result 3; if the difference is not within the threshold, predict the supplementary data value and splice, save the structure and output the judgment result 3. Among them, the structure is a file format for storing multiple data types (arrays, neural networks, etc.). In the prediction model, the optimized neural network parameters, original data, neural networks, etc. can be saved in the structure for easy calling.

[0084] As an improvement, if there are some outliers or missing values ​​in the input data in step 11, the input data is cleaned using the isolation forest method of multi-dimensional sub-sampling to exclude outliers and fill them with linear interpolation.

[0085] Preferably, the calculation method of the isolation forest method of the multi-dimensional sub-sample is as follows:

[0086] a1) Path length

[0087] For each sample x, its path length h(x) in the isolation tree is defined as the distance from the root node to the leaf node of the sample, where at each node, the sample x is randomly divided into the left subtree or the right subtree; each division increases the path length, and when the sample reaches a leaf node, the current path length is returned;

[0088] Average path length formula:

[0089]

[0090] Where H(n) is the nth harmonic number, defined as:

[0091] H(n)=ln(n)+γ

[0092] Where γ is Euler's constant;

[0093] The average path length c(n) is used to normalize the path length so that the differences in path length can be compared between data of different scales;

[0094] a2) Anomaly score calculation: The anomaly score reflects the probability that a sample point is considered anomaly. The anomaly score of the isolation forest is based on the average path length of the sample point in all trees; the shorter the path, the easier it is for the sample to be isolated and the greater the possibility of being considered anomaly; the calculation formula is as follows:

[0095]

[0096] Among them, E(h(x)) is the average path length of all isolated trees of sample x in the isolation forest, and c(n) is the average path length based on the number of samples n;

[0097] The value range of anomaly score is [0,1]:

[0098] S(x,n)≈1 means that the sample point x is very easy to be isolated, so it is more likely to be an outlier; S(x,n)≈0 means that the sample point x is difficult to be isolated, so it is more likely to be a normal point;

[0099] a3) Split point selection: In the process of building an isolation tree, each node will select a random split point; for each sample set X, a value is randomly selected as the split point, the formula is as follows:

[0100] Y s =min(X)+rand()×(max(X)-min(X))

[0101] Among them, rand() is a uniformly distributed random number, which ensures that the split point is randomly selected between the minimum and maximum values ​​of the sample.

[0102] Preferably, the improvement of the improved Bayesian optimization algorithm lies in the optimization of the initial sampling points, which improves the optimization efficiency:

[0103] For sampling n points in the d-dimensional parameter space, the value range of each dimension is:

[0104] [a i ,b i ]

[0105] Latin square sampling:

[0106] b1) Divide each dimension into n equally spaced intervals: For each dimension i, divide the interval into n subintervals:

[0107]

[0108] The boundaries of each interval are:

[0109]

[0110] These intervals are Latin square series;

[0111] b2) Randomly select a point in each interval: For each dimension i, randomly select a point in each interval:

[0112]

[0113] where u i It is a random number uniformly distributed from 0 to 1, which is used to ensure the randomness of sampling;

[0114] b3) Randomly disrupt the selection order of intervals: For each dimension i, randomly disrupt the selection order of n intervals to ensure that each interval sample is only used once in a certain dimension;

[0115] b4) Combining sample points of each dimension: Finally, the sample points are generated by selecting p in each dimension. i , forming n sample points;

[0116] Specifically, for the i-th dimension, n points are sampled within its interval range, and the formula used by the Latin square is as follows:

[0117]

[0118] Where i is the dimension index and j is the sample index.

[0119] Step 4 constructs a CNN-BiLSTM short-term water supply prediction model, which mainly considers the seasonal, long-term and short-term fluctuation characteristics of industrial water supply. The LSTM model that can capture long-term dependencies is selected. Because the current water supply data is not only related to historical data, but also to future values, the extended BiLSTM model of LSTM is selected to capture the long-term dependency characteristics of the sequence in both directions. In addition, for seasonality and short-term volatility, a CNN model that can capture local features is selected to learn the seasonality and short-term volatility of water supply data. Therefore, the two are connected in series, first capturing local information, and then inputting it into BiLSTM for global learning to form a CNN-BiLSTM short-term water supply prediction model.

[0120] The physical steps to implement the BiLSTM model are as follows:

[0121] c1) Forward LSTM

[0122] First is the calculation of the forget gate:

[0123]

[0124] Input Gate:

[0125]

[0126] Unit status update:

[0127]

[0128] Output Gate:

[0129]

[0130] c2) Reverse LSTM

[0131] The reverse LSTM calculation method is almost the same as the forward calculation method, except that the direction is different and the calculation formula has different superscripts and subscripts of the variables.

[0132] Output Gate:

[0133]

[0134] c3) Final output

[0135]

[0136] The meaning of the above variables is:

[0137] Hidden state of the forward LSTM at time t-1.

[0138] x t : Input at the current moment.

[0139] The cell state of the forward LSTM at time t-1.

[0140] Forward LSTM weight matrix.

[0141] Bias term for the forward LSTM.

[0142] Gated output of the forward LSTM.

[0143] σ, tanh: Sigmoid and hyperbolic tangent activation functions.

[0144] The steps to implement CNN are as follows:

[0145] d1) Convolutional layer

[0146]

[0147] Variable meaning:

[0148] z i,j,k : The value of the kth feature map at the i, jth position of the convolution output.

[0149] x i+m,j+n: The pixel value or activation value at the i+m, j+n position of the input image or feature map.

[0150] w m,n,k : The weight of the kth convolution kernel (filter) at the mth, nth position.

[0151] b k : Bias term for the kth convolution kernel.

[0152] M, N: convolution kernel size.

[0153] i, j: The position index of the output feature map (different from the position index of the input image). K: The convolution kernel index, which determines which feature map is generated.

[0154] d2) Pooling layer

[0155] The pooling layer is used to reduce the dimension of the feature map and reduce overfitting during model learning.

[0156] Max pooling formula:

[0157] p i,j,k =max(x i+m,j+n,k )

[0158] Variable meaning:

[0159] p i,j,k : The value of the kth pooling feature map at the i, jth position after pooling.

[0160] x i+m,j+n,k : The value of the i+m, j+n position of the input before pooling.

[0161] d3) Fully connected layer

[0162] The fully connected layer maps the previous features to the output.

[0163]

[0164] Variable meaning:

[0165] y i : The output value of the ith neuron.

[0166] a j : The j-th activation value of the previous layer input.

[0167] w ji : The weight from the jth node in the previous layer to the i-th node in the current layer.

[0168] b i : The bias term of the i-th neuron in the current layer.

[0169] Verification example:

[0170] ① User input: input data (single-column time series), data type (water volume, flow), detection time interval (hours), device name, detection start and end time (yyyy / mm / dd hh:mm:ss), and future prediction steps (e.g. 50 steps).

[0171] ② Select data: Use the data parameter storage and update mechanism to select the original data for prediction.

[0172] ③ Data preprocessing: If there are some outliers or missing values ​​in the input data, the isolation forest (IF) method of multi-dimensional sub-sampling will be used to clean the data, exclude outliers and fill them with linear interpolation.

[0173] ④ Parameter tuning: The improved Bayesian optimization algorithm is used to tune the following parameters of the model:

[0174] 1) numHiddenUnits1: the number of neurons in the forward LSTM hidden layer, for example 125;

[0175] 2) numHiddenUnits2: the number of neurons in the reverse LSTM hidden layer, for example 64;

[0176] 3) initialLearnRate: initial learning rate, for example 0.002;

[0177] 4) droprate: random drop rate of neurons, for example 0.3;

[0178] 5) dropperiod: learning rate drop period, for example 30;

[0179] 6) l2Regularization: L2 regularization coefficient, used to prevent overfitting, for example 0.00005;

[0180] 7) gradientThreshold: gradient threshold to prevent gradient explosion, for example 3;

[0181] 8) miniBatchSize: mini-batch size, for example 16;

[0182] 9) dropfactor: learning rate drop factor, for example 0.8;

[0183] 10) inputSequenceLength: input sequence length, which determines the input dimensions of the training set, validation set, and test set, for example, 48;

[0184] 11)convFilterSize: convolution kernel size, for example 5;

[0185] 12)convNumFilters: the number of convolution kernels, for example 16;

[0186] 13) maxpooling: maximum pooling, reducing the dimension of feature maps to avoid overfitting, for example 7;

[0187] ⑤Build a data set: including training set, validation set and test set, with the training set accounting for 80%, the validation set and the test set each accounting for 10%;

[0188] ⑥Build the model and set the training options: Build the Layer of the CNN-BiLSTM short-term water supply prediction model and set the training option. The parameters are derived from the parameter tuning in step ④.

[0189] ⑦Train and save the network model: call the "trainNetwork" function, input the training set input and output as well as the model Layer and Option, and start training. After the training is completed, bind and save the trained CNN-BiLSTM neural network in a file;

[0190] ⑧ Execute prediction: Predict the validation set, test set and future respectively. The prediction of the validation set has real input and output values, which can be said to be a kind of fitting, used to show the effect of training fitting. The test set has no real input and output, and its prediction is predicted by the last set of inputs of the validation set, so it has lag and needs one more prediction step to evaluate the generalization of the model. The prediction of future values ​​is evaluated based on the performance of the test set to evaluate its accuracy.

[0191] ⑨ Visualization of prediction results: One is to calculate the error index (MAE, RMSE, MAPE or SMAPE) to quantify the prediction effect; the other is to draw images to intuitively show the prediction effect. Figure 3 The prediction results shown are based on the original data of water supply with a detection time interval of 1 hour. The number of data is 624. The data for the next 3 days are predicted in sequence. The corresponding validation set MAE, RMSE and MAPE are 79.9785, 114.1242 and 0.0368 respectively; and the corresponding error indicators of the test set are 95.7053, 124.5507 and 0.0460 respectively; the test set MAPE value is less than 0.1, which shows that the prediction accuracy is very high.

[0192] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A short-term water supply prediction method based on an improved Bayesian optimization algorithm, characterized in that: The specific steps include: Step 1: Data preprocessing: Select the raw data for prediction based on the water supply data and features input by the user; Step 2: Parameter tuning: Use the improved Bayesian optimization algorithm to tune multiple parameters of the model and select the best parameter combination through the loss function; Step 3: construct a data set according to the optimal parameter combination, wherein the data set includes a training set, a validation set, and a test set; Step 4: Model training: Build a CNN-BiLSTM short-term water supply prediction model and define training options; use the training set to train the model to obtain a trained CNN-BiLSTM neural network; Step 5: Execute prediction: Use the trained CNN-BiLSTM neural network to predict the validation set, test set, and future respectively, and obtain the validation set prediction value, test set prediction value, and future prediction value; Step 6: Visualize the prediction results: Draw a line graph of the original data, validation set and validation set prediction value, test set and test set prediction value, and future prediction value on the same graph to intuitively show the prediction effect.

2. The short-term water supply prediction method based on the improved Bayesian optimization algorithm according to claim 1 is characterized in that: The data preprocessing in step 1 specifically includes: Step 11, data input: input data, data type, data detection time interval, device name, detection start and end time, and future prediction steps; the data is a single column time series of water supply; Step 12: Data selection: Use the data parameter storage and update mechanism to select the original data for prediction.

3. The short-term water supply prediction method based on the improved Bayesian optimization algorithm according to claim 2 is characterized in that: The data parameter storage and update mechanism is specifically as follows: Search for structures with the same characteristics in historical data based on user input data and parameters; If there is no identical feature, save the structure and output the judgment result 1; If the same features exist and the input data are all the same, save the structure and output the judgment result 2; If there are identical features but the input data are not all identical, determine whether the input data overlaps; if there is input data overlap, determine whether there is predicted supplementary data in the overlapping part; if there is predicted supplementary data, replace the overlapping part corresponding to the time with the newly input data; if there is no predicted supplementary data, replace the predicted data with the data corresponding to the time, and concatenate the rest, save the structure and output the judgment result 3; if the input data does not overlap, calculate the difference between the monitoring start time and the end time, determine whether the difference is within the threshold, if the difference is within the threshold, directly concatenate, save the structure and output the judgment result 3; if the difference is not within the threshold, predict the supplementary data value and concatenate, save the structure and output the judgment result 3.

4. The short-term water supply prediction method based on the improved Bayesian optimization algorithm according to claim 1 is characterized in that: If there are some outliers or missing values ​​in the input data in step 11, the input data is cleaned using the isolation forest method of multi-dimensional sub-sampling to exclude outliers and fill them with linear interpolation.

5. The short-term water supply prediction method based on the improved Bayesian optimization algorithm according to claim 4 is characterized in that: The calculation method of the isolation forest method of the multi-dimensional sub-sample is as follows: a1) Path length For each sample x, its path length h(x) in the isolation tree is defined as the distance from the root node to the leaf node of the sample, where at each node, the sample x is randomly divided into the left subtree or the right subtree; each division increases the path length, and when the sample reaches a leaf node, the current path length is returned; Average path length formula: Where H(n) is the nth harmonic number, H(n)=ln(n)+γ, γ is the Euler constant; a2) Anomaly score calculation The anomaly score reflects the probability that a sample point is considered an anomaly. The anomaly score of the isolation forest is based on the average path length of the sample point in all trees. The shorter the path, the easier it is for the sample to be isolated and the greater the possibility of being considered an anomaly. The calculation formula is as follows: Among them, E(h(x)) is the average path length of all isolated trees of sample x in the isolation forest, and c(n) is the average path length based on the number of samples n; The value range of anomaly score is [0,1]: S(x,n)≈1 means that the sample point x is very easy to be isolated, so it is more likely to be an outlier; S(x,n)≈0 means that the sample point x is difficult to be isolated, so it is more likely to be a normal point; a3) Split point selection In the process of building an isolation tree, each node will select a random split point; for each sample set X, a value is randomly selected as the split point, the formula is as follows: Y s =min(X)+rand()×(max(X)-min(X)) Among them, rand() is a uniformly distributed random number, which ensures that the split point is randomly selected between the minimum and maximum values ​​of the sample.

6. The short-term water supply prediction method based on the improved Bayesian optimization algorithm according to claim 1 is characterized in that: The improvement of the improved Bayesian optimization algorithm lies in the optimization of the initial sampling points: For sampling n points in the d-dimensional parameter space, the value range of each dimension is: [a i ,b i ] Latin square sampling: b1) Divide each dimension into n equally spaced intervals: For each dimension i, divide the interval into n subintervals: The boundaries of each interval are: These intervals are Latin square series; b2) Randomly select a point in each interval: For each dimension i, randomly select a point in each interval: where u i It is a random number uniformly distributed from 0 to 1, which is used to ensure the randomness of sampling; b3) Randomly disrupt the selection order of intervals: For each dimension i, randomly disrupt the selection order of n intervals to ensure that each interval sample is only used once in a certain dimension; b4) Combining sample points of each dimension: Finally, the sample points are generated by selecting p in each dimension. i , forming n sample points; Specifically, for the i-th dimension, n points are sampled within its interval range, and the formula used by the Latin square is as follows: Where i is the dimension index and j is the sample index.

Citation Information

Patent Citations

  • Water supply prediction method and water supply prediction system

    CN105956690A

  • Urban sky-level water demand online prediction method based on deep learning neural network

    CN111626518A

  • Integrated learning-based fan short-term output prediction method

    CN115618734A

  • CNN-BiLSTM-BO-based aerosol chemical component reconstruction method and system

    CN118447945A

Cited By

  • Industrial water quota Bayesian network uncertainty modeling and correcting method

    CN120995854A