Resident daily electricity consumption prediction method and device based on dynamic clustering and time sequence fusion network, storage medium and system
Through the method of dynamic clustering and timing fusion network, the dynamic nature and insufficient characteristic processing of residential electricity consumption prediction are solved, and the accurate prediction of residential electricity consumption is achieved, and the accuracy and adaptability of prediction is improved. It is suitable for complex residential electricity consumption scenarios.
Patent Information
- Application Number
- CN202510518997.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2025-08-01
AI Technical Summary
The existing household electricity consumption prediction methods have insufficient dynamics, feature processing, model interpretation and universality, resulting in insufficient prediction accuracy and reliability, and are unable to effectively adapt to the changes in electricity consumption characteristics in different regions and seasons.
The dynamic clustering and time-series fusion network method is adopted to screen key influence features through dynamic time regular K-value clustering analysis and Shap algorithm Xgboost model, combined with the time-series fusion transformer model, grouping and feature extraction of residential electricity data, realizing automatic identification of residential electricity behavior and transparent contribution value evaluation, and improving prediction accuracy and adaptability.
It improves the accuracy and reliability of household electricity consumption prediction, enhances the model's ability to capture time-dependent and nonlinear relationships, and is suitable for complex residential electricity consumption scenarios, providing transparent decision-making support.
Smart Images

Figure CN120414503A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method, device, storage medium and system for predicting daily electricity consumption of residents based on dynamic clustering and temporal fusion network, and belongs to the technical field of predicting daily electricity consumption of residents. Background Technique
[0002] With the rapid development of the mobile Internet, the means of obtaining and analyzing residential electricity consumption data have been continuously enriched. By analyzing historical electricity consumption data and related influencing factors, it has become more accurate to predict residential electricity demand using statistical and machine learning methods. With the acceleration of the urbanization process and the improvement of residents' living standards, the demand for electricity has risen sharply. Accurate electricity consumption prediction not only helps power companies allocate resources reasonably, optimize grid operation, but also effectively reduces electricity waste and improves energy utilization efficiency. At the same time, in the context of the gradually increasing proportion of renewable energy, accurate electricity demand prediction is crucial for the dispatching of the power market, the utilization of renewable energy, and the construction of smart grids. Therefore, improving the accuracy of residential electricity consumption prediction is of profound significance for achieving sustainable development and intelligent energy management.
[0003] Currently, the methods for predicting residential electricity consumption mainly include statistical methods, machine learning methods, and deep learning methods. Statistical methods such as linear regression and time series analysis usually make simple predictions based on historical data and have limited ability to capture non-linear and complex temporal patterns. Machine learning methods, such as support vector machine (SVM), decision tree, etc., can mine potential laws in data by constructing complex models and improve prediction accuracy. In recent years, deep learning methods such as long short-term memory network (LSTM) and convolutional neural network (CNN) have also been gradually applied to electricity consumption prediction. With their powerful feature learning ability, they can process larger-scale and more complex temporal data and have achieved certain success.
[0004] Although certain progress has been made in existing prediction methods, there are still deficiencies. First, many methods fail to fully consider the dynamics and temporal characteristics of residential electricity consumption behavior. In practical applications, residential electricity consumption is affected by various factors such as seasonal changes, holidays, and weather conditions. Traditional models often assume that the data is static and cannot accurately capture these time-varying characteristics. Second, existing methods have deficiencies in feature selection and processing. Many prediction models rely on manual feature selection, ignoring other important factors that may affect electricity consumption. In addition, the process of traditional feature engineering is often time-consuming and prone to bias, affecting the prediction performance of the model. Third, the interpretability of the model is also a key issue. Although deep learning models perform well in prediction accuracy, their "black box" nature makes it difficult to explain the decision-making process of the model. This lacks sufficient transparency for power companies and users. Finally, the generality and adaptability of the model are also a major challenge for current methods. Many studies build models for specific regions or specific time periods, while the electricity consumption characteristics in different regions and different seasons may be very different, resulting in limited applicability of the model in practical applications. Therefore, it is particularly important to establish a prediction model that can flexibly adapt to different situations. In summary, the current methods for predicting residential electricity consumption have deficiencies in multiple dimensions such as dynamics, feature processing, model interpretability, and generality, and new methods are urgently needed to improve the accuracy and reliability of prediction. Summary of the Invention
[0005] An object of the present invention is to provide a method, device, storage medium, and system for predicting daily residential electricity consumption based on dynamic clustering and temporal fusion network, so as to solve the problem of insufficient accuracy and reliability in predicting daily residential electricity consumption in the prior art.
[0006] To achieve the above object, the present invention is implemented by adopting the following technical solutions:
[0007] In the first aspect, the present invention provides a method for predicting daily residential electricity consumption based on dynamic clustering and temporal fusion network, including:
[0008] Obtain the historical daily residential electricity consumption time series, key influencing features, and holiday data of multiple residents within the same time period. The key influencing features are screened from the historical meteorological data through an Xgboost model based on the Shap algorithm, and the historical meteorological data is the historical meteorological data of the region corresponding to the historical daily residential electricity consumption time series;
[0009] Perform clustering analysis on the historical daily residential electricity consumption time series of multiple residents through a K-value clustering analysis algorithm based on dynamic time warping to obtain the residential electricity consumption behavior patterns of each resident. The residential electricity consumption behavior pattern is a time series containing the daily residential electricity consumption;
[0010] Input the key influencing features, holiday data, historical daily electricity consumption time series of each resident, and residential electricity consumption behavior patterns into the trained time series fusion transformer model to obtain the predicted values of the daily electricity consumption of each resident within a future set time period. The time series fusion transformer model is constructed based on the key influencing features.
[0011] Further, the historical daily electricity consumption time series and the historical meteorological data are obtained through web crawling technology. The historical meteorological data includes historical daily temperature, historical daily humidity, historical sunshine duration, historical precipitation, historical apparent temperature, historical wind speed, and historical weekly data.
[0012] Further, the historical daily electricity consumption time series, key influencing features, and holiday data of multiple residents within the same time period have been preprocessed and standardized;
[0013] The preprocessing includes dirty data cleaning, missing value handling, and outlier handling. The dirty data cleaning includes removing or repairing unreasonable data. The missing value handling includes filling missing values using the mean method, median method, or interpolation method. The outlier handling includes smoothing the outliers;
[0014] The standardization processing includes: normalizing each item of data to the same dimension.
[0015] Further, perform clustering analysis on the historical daily electricity consumption time series of multiple residents through the K - value clustering analysis algorithm based on dynamic time warping to obtain the residential electricity consumption behavior patterns of each resident, including:
[0016] Initialize K centroids, where one centroid corresponds to one residential electricity consumption behavior pattern;
[0017] Calculate the minimum cumulative distance between the historical daily electricity consumption time series of each resident and each centroid;
[0018] Assign the historical daily electricity consumption time series of each resident to the centroid with the closest minimum cumulative distance to form clusters composed of centroids and historical daily electricity consumption time series;
[0019] Within each cluster, take the average of the minimum cumulative distances between all historical daily electricity consumption time series within the cluster and the centroid as the minimum cumulative distance between all historical daily electricity consumption time series within the cluster and the new centroid to obtain the new centroid of each cluster;
[0020] Repeat the above iterative process until all centroids no longer change or the significance level is less than the preset threshold, stop the iteration, and take the centroids of the last iteration as the residential electricity consumption behavior patterns of each resident.
[0021] Further, the minimum cumulative distance is calculated by the following formula:
[0022] ;
[0023] where represents the minimum cumulative distance from the first i elements of the historical daily electricity consumption time series of residents to the first j elements of the centroid, represents the Euclidean distance from the i-th element of the historical daily electricity consumption time series of residents to the j-th element of the centroid, min{*} represents taking the minimum value of *, represents from the first elements of the historical daily electricity consumption time series of residents to the first j elements of the centroid of the minimum cumulative distance, represents from the first elements of the historical daily electricity consumption time series of residents to the first j - 1 elements of the centroid of the minimum cumulative distance, represents from the first elements of the historical daily electricity consumption time series A of residents to the first j - 1 elements of the centroid of the minimum cumulative distance.
[0024] Further, the key influencing features are obtained by the following method:
[0025] Obtain the historical daily electricity consumption time series, historical meteorological data, and holiday data of multiple residents in the same time period. Use the historical daily electricity consumption time series of residents as the target variable, and each feature in the historical meteorological data as the independent variable to construct and train an Xgboost model. Input each feature in the historical meteorological data into the trained Xgboost model, and use the Shap algorithm to analyze the processing process of the Xgboost model, so as to calculate the contribution of each feature in the historical meteorological data to the predicted value of the historical daily electricity consumption time series of residents;
[0026] The contribution of the feature to the predicted value of the historical daily electricity consumption time series of residents is calculated by the following formula:
[0027] ;
[0028] where is the contribution of the l-th feature in the historical meteorological data to the predicted value of the i-th historical daily electricity consumption time series of residents, N is the historical meteorological data, S is a subset of N, f() is the Xgboost model, U represents the union of sets, l represents the l-th feature in the historical meteorological data, || represents taking the absolute value, and! represents factorial;
[0029] Calculate the average value of the contributions of the features to all historical daily electricity consumption time series of residents as the importance of the feature;
[0030] Sort the features in descending order of importance, and take the top n features as the key influencing features, where n is the number of historical daily electricity consumption time series of residents.
[0031] Furthermore, perform the following operations in the time series fusion transformer model:
[0032] Use the variable selection network to adaptively select the input data to obtain a dynamic feature sequence;
[0033] Input the above dynamic feature sequence into the LSTM encoder to generate a hidden state, perform a linear transformation on the hidden state to obtain the input of the multi-head attention mechanism, and input it into the multi-head attention mechanism;
[0034] Obtain the output of the multi-head attention mechanism through the multi-head attention mechanism;
[0035] Input the output of the multi-head attention mechanism and the hidden state into the time series fusion module to obtain a fusion result;
[0036] Predict the fusion result through the output layer to obtain the predicted values of the daily electricity consumption of each resident within a future set time period.
[0037] In a second aspect, the present invention provides a device for predicting the daily electricity consumption of residents based on a dynamic clustering and time series fusion network, including:
[0038] A data acquisition module, configured to: acquire the historical daily electricity consumption time series, key influencing features, and holiday data of multiple residents within the same time period, where the key influencing features are screened from the historical meteorological data through an Xgboost model based on the Shap algorithm, and the historical meteorological data is the historical meteorological data of the region corresponding to the historical daily electricity consumption time series of residents;
[0039] A residential electricity consumption behavior pattern analysis module, configured to: perform clustering analysis on the historical daily electricity consumption time series of multiple residents through a K-value clustering analysis algorithm based on dynamic time warping to obtain the residential electricity consumption behavior patterns of each resident, where the residential electricity consumption behavior pattern is a time series including the daily electricity consumption of residents;
[0040] A residential daily electricity consumption prediction module, configured to: input the key influencing features, holiday data, the historical daily electricity consumption time series of each resident, and the residential electricity consumption behavior pattern into the trained time series fusion transformer model to obtain the predicted values of the daily electricity consumption of each resident within a future set time period, where the time series fusion transformer model is constructed based on the key influencing features.
[0041] In a third aspect, the present invention provides a computer-readable storage medium, on which a computer program / instructions are stored, characterized in that when the computer program / instructions are executed by a processor, the steps of the method for predicting daily electricity consumption of residents based on dynamic clustering and temporal fusion network described in any one of the first aspects are realized.
[0042] In a fourth aspect, the present invention provides a computer system, characterized by including:
[0043] A memory for storing computer programs / instructions;
[0044] A processor for executing the computer programs / instructions to realize the steps of the method for predicting daily electricity consumption of residents based on dynamic clustering and temporal fusion network described in any one of the first aspects.
[0045] Compared with the prior art, the beneficial effects achieved by the present invention are:
[0046] A method, device, storage medium and system for predicting daily electricity consumption of residents based on dynamic clustering and temporal fusion network provided by the present invention group the electricity consumption data of residents through a dynamic clustering technique (K-value clustering analysis algorithm based on dynamic time warping), automatically identify different electricity consumption patterns, ensure that the characteristics of different groups are fully mined, introduce the Shap algorithm to provide a transparent and interpretable contribution value for each feature, so as to extract the key influencing features in the historical meteorological data that have a significant impact on the daily electricity consumption of residents, improve the accuracy and reliability of prediction, and improve the adaptability to irregular data and the flexible expandability in different application scenarios by adopting a temporal fusion transformer model. Combine the clustered data with the key influencing features, and on the basis of comprehensively considering the time series, enhance the model's ability to capture time dependence and non-linear relationships, and realize the accurate prediction of the daily electricity consumption of residents. The overall algorithm framework enhances the robustness and adaptability of the prediction and is applicable to complex residential electricity consumption scenarios. Description of the Drawings
[0047] Figure 1 is a flowchart of a method for predicting daily electricity consumption of residents based on dynamic clustering and temporal fusion network corresponding to Embodiment 1 of the present invention;
[0048] Figure 2 is a flowchart of a method for predicting daily electricity consumption of residents based on dynamic clustering and temporal fusion network corresponding to Embodiment 2 of the present invention. Detailed Embodiments
[0049] The present invention will be further described below with reference to the drawings. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and cannot be used to limit the protection scope of the present invention.
[0050] Embodiment 1
[0051] As Figure 1 shown, this embodiment provides a method for predicting daily electricity consumption of residents based on dynamic clustering and time series fusion network, including:
[0052] Obtain the historical daily electricity consumption time series, key influencing features and holiday data of multiple residents within the same time period. The key influencing features are selected from the historical meteorological data through an Xgboost model based on the Shap algorithm, and the historical meteorological data is the historical meteorological data of the area corresponding to the historical daily electricity consumption time series;
[0053] Perform clustering analysis on the historical daily electricity consumption time series of multiple residents through the K - value clustering analysis algorithm based on dynamic time warping to obtain the electricity consumption behavior patterns of each resident. The electricity consumption behavior pattern of a resident is a time series containing the daily electricity consumption of the resident;
[0054] Input the key influencing features, holiday data, the historical daily electricity consumption time series of each resident, and the electricity consumption behavior pattern into the trained time series fusion transformer model to obtain the predicted values of the daily electricity consumption of each resident at a future set time. The time series fusion transformer model is constructed based on the key influencing features.
[0055] Group the residential electricity consumption data through dynamic clustering technology, automatically identify different electricity consumption patterns, ensure that the characteristics of different groups are fully explored. Introducing the Shap algorithm can provide a transparent and interpretable contribution value for each feature, thereby extracting the key influencing features in the historical meteorological data that have a significant impact on the daily electricity consumption of residents, improving the accuracy and reliability of prediction. By adopting the time series fusion transformer model, the adaptability to irregular data and the flexible expandability in different application scenarios are improved. Combining the clustered data with the key influencing features, on the basis of comprehensively considering the time series, the ability of the model to capture time dependence and non - linear relationships is enhanced, realizing the accurate prediction of the daily electricity consumption of residents. The overall algorithm framework enhances the robustness and adaptability of the prediction and is applicable to complex residential electricity consumption scenarios.
[0056] Embodiment 2
[0057] As Figure 2 shown, this embodiment provides a method for predicting daily electricity consumption of residents based on dynamic clustering and time series fusion network, including the following steps:
[0058] Step 1: Obtain the historical daily electricity consumption data, historical meteorological data and holiday data, and pre - process the obtained data to ensure the integrity and availability of the data.
[0059] Step 1 includes step S11 and step S12, specifically:
[0060] Step S11 obtains historical daily electricity consumption data, historical meteorological data, and holiday data within the same time period required for modeling in the form of a time series. Specifically, the following steps are performed: daily electricity consumption data is obtained from public platforms using crawler technology; historical meteorological data corresponding to the historical daily electricity consumption data is obtained through relevant meteorological websites and other open data platforms. The historical meteorological data includes historical daily temperature, historical daily humidity, historical sunshine length, historical precipitation, historical perceived temperature, historical wind speed, and historical weekly data for the region corresponding to the obtained daily electricity consumption data; holiday data is quickly generated using the Python software's holiday library. Holiday data refers to holiday data for the region corresponding to the obtained historical daily electricity consumption data. The "holiday library" is a library primarily used to obtain public holiday information for countries and regions around the world. By dynamically generating and storing holiday data, the library supports on-demand loading of countries, regions, and specific holiday categories, and has efficient data access and query speeds.
[0061] Step S12, data preprocessing, specifically: first, clean the data, eliminate or repair unreasonable data to improve data quality, identify and process missing values, and use the mean method, median method, or interpolation method to fill in the missing data; check the data at each time point, remove duplicate entries, and ensure the uniqueness of the data; encode holiday data, mark holidays as 1, and mark non-holidays as 0, to obtain a holiday data time series to analyze its impact on electricity consumption; perform outlier detection on each data, use the IQR (interquartile range) method to identify outliers, and smooth out the outliers to prevent them from affecting the prediction results; finally, the data used as model input needs to be standardized to make the dimensions of different features consistent to improve the training effect of the model.
[0062] The final input to the model is the historical residents' daily electricity consumption time series, historical meteorological data and holiday data that have been preprocessed and standardized. There are multiple historical residents' daily electricity consumption time series as input, and one resident corresponds to one historical residents' daily electricity consumption time series.
[0063] Step 2: Use the DTW-Kmeans (Dynamic Time Warping-Kmeans) algorithm to cluster the historical residential daily electricity consumption time series to identify patterns of electricity consumption behavior among different resident groups. Cluster analysis of the historical residential daily electricity consumption time series involves calculating the minimum cumulative distance between all historical residential daily electricity consumption time series to generate a distance matrix.
[0064] Let the daily electricity consumption time series of two historical residents be respectively , to which respectively represent the first to the Nth historical daily electricity consumption of the historical resident daily electricity consumption time series A, to which respectively represent the first to the Mth historical daily electricity consumption of the historical resident daily electricity consumption time series B.
[0065] The K - value clustering analysis algorithm based on dynamic time warping is divided into two parts: First, determine the number of clusters K, select the optimal value of the number of clusters K through the silhouette coefficient method, and then initialize the cluster centers; then is the iterative process of clustering, which has two stages. One is the assignment stage, which assigns the daily electricity consumption data time series of each resident to the nearest cluster center according to the minimum cumulative distance. The other is the update stage, which calculates the mean of all samples in each cluster and updates the position of the cluster center; repeat the above two stages until the cluster centers no longer change significantly (significance level less than 0.01) or reach the preset number of iterations.
[0066] Let there be n historical resident daily electricity consumption time series, which are respectively , the number of clusters is K, and the K - value clustering analysis algorithm based on dynamic time warping specifically includes:
[0067] (a) Randomly select K initial centroids , which represent the initial electricity consumption behavior patterns of different resident groups.
[0068] (b) For the historical daily electricity consumption time series of each resident, calculate its minimum cumulative distance from each centroid: . Among them, represents the ith historical daily electricity consumption time series, represents the kth centroid.
[0069] (c) Assign the ith historical daily electricity consumption time series to the centroid with the closest distance to form the corresponding cluster. After all the historical daily electricity consumption time series are assigned, all clusters are obtained. This step ensures that the electricity consumption behavior pattern of the resident is closest to the assigned cluster center, thus realizing the clustering of similar electricity consumption behaviors.
[0070] (d) Update the centroid of each cluster. Generate a new centroid by taking the average of the minimum cumulative distances of all historical daily electricity consumption time series of residents within the cluster, that is, take the average of the minimum cumulative distances between all historical daily electricity consumption time series of residents within the cluster and the centroid as the minimum cumulative distance between all historical daily electricity consumption time series of residents within the cluster and the new centroid, and obtain the new centroids of each cluster to ensure that it can represent the typical electricity consumption behavior patterns of users in that cluster.
[0071] (e) Check whether the centroid has changed. If it no longer changes or the significance level is less than the preset threshold, the algorithm converges and the iteration stops.
[0072] The minimum cumulative distance is calculated by the following formula:
[0073] ;
[0074] where represents the minimum cumulative distance from the first i elements of the historical daily electricity consumption time series of residents to the first j elements of the centroid, represents the Euclidean distance from the i-th element of the historical daily electricity consumption time series of residents to the j-th element of the centroid, min{*} represents taking the minimum value of *, represents from the first elements of the historical daily electricity consumption time series of residents to the first j elements of the centroid, represents from the first elements of the historical daily electricity consumption time series of residents to the first j - 1 elements of the centroid, represents from the first elements of the historical daily electricity consumption time series A of residents to the first j - 1 elements of the centroid.
[0075] After the K - value clustering analysis, the electricity consumption behavior patterns of the residents corresponding to the time series of daily electricity consumption data within the same clustering center are the same. In this way, the electricity consumption behavior patterns of different residents can be clearly identified, providing a basis for subsequent electricity demand forecasting.
[0076] Step 3, use statistical analysis and the Stl (Standard Template Library) method to further analyze the electricity consumption behavior patterns of different resident groups to explore the trend changes among them.
[0077] Analyze the electricity consumption behavior patterns of different resident groups, specifically: on the one hand, calculate the basic statistics of each resident group, including indicators such as mean, standard deviation, maximum value, minimum value, skewness, and kurtosis, to outline the overall characteristics of residents' electricity consumption behavior; then use the t-test to compare the electricity consumption differences between different resident groups and test whether there are significant differences in electricity consumption behavior; on the other hand, use the Stl method to decompose the time series of daily electricity consumption data of each resident group. The Stl method can divide the time series of daily electricity consumption data into seasonal components, trend components, and random components, and its formula is as follows:
[0078] ;
[0079] Among them, is the time series of historical daily electricity consumption data of residents to be decomposed, is the decomposed trend component, representing the long-term change trend of the time series of historical daily electricity consumption data of residents, reflecting the overall change direction of the data; is the decomposed seasonal component, representing the seasonal fluctuations in the time series of historical daily electricity consumption data of residents, capturing the part of periodic changes; is the decomposed random component, representing the random fluctuations or noises in the time series of historical daily electricity consumption data of residents.
[0080] Step 4: Use the Xgboost model based on the Shap algorithm to identify the key influencing features of the electricity consumption behavior patterns of different resident groups.
[0081] Feature importance assessment, specifically: First, organize all the data after clustering to ensure that each feature in the historical meteorological data (such as historical temperature, historical humidity, historical wind speed, and holiday data) and the target variable (daily electricity consumption of residents) have been cleaned. Divide the data into a training set and a test set in a ratio of 8:2, construct an Xgboost model, set the hyperparameters of the Xgboost model, such as learning rate, tree depth, and regularization parameters, and at the same time use cross-validation to optimize the performance of the model; and use the mean square error (MSE, Mean-Square Error) and the root mean square error (RMSE, Root Mean-Square Error) to measure the accuracy of the Xgboost model; after obtaining the trained Xgboost model, use the Shap algorithm to analyze the Xgboost model, calculate the contribution of each feature to each prediction result, draw a Shap summary plot, display the influence degree and its positive and negative contributions of each feature, and identify the key influencing features in different resident groups. In this embodiment, the Xgboost model and the Shap algorithm are combined to obtain the Xgboost model based on the Shap algorithm.
[0082] The key influencing features are obtained through the following methods:
[0083] (a)Obtain the historical daily electricity consumption time series, historical meteorological data, and holiday data of multiple residents within the same time period. Use the historical daily electricity consumption time series as the target variable and each feature in the historical meteorological data as the independent variable to construct and train an Xgboost model. Input each feature in the historical meteorological data into the trained Xgboost model, and use the Shap algorithm to analyze the processing process of the Xgboost model, so as to calculate the contribution of each feature in the historical meteorological data to the predicted value of the historical daily electricity consumption time series.
[0084] The prediction function of the Xgboost model based on the Shap algorithm is: , where, represents the contribution of the k-th base learner corresponding to the residential electricity consumption behavior pattern to the prediction of the daily electricity consumption of residents, which is used to capture the residential electricity consumption behavior patterns of different resident groups, and x represents the input of the Xgboost model based on the Shap algorithm.
[0085] The contribution of the feature to the predicted value of the historical daily electricity consumption time series is calculated by the following formula:
[0086] ;
[0087] where, is the contribution of the l-th feature in the historical meteorological data to the predicted value of the i-th historical daily electricity consumption time series, N is the historical meteorological data, S is a subset of N, f() is the Xgboost model, U represents the union of sets, l represents the l-th feature in the historical meteorological data, || represents taking the absolute value, and! represents factorial.
[0088] (b)Calculate the average value of the contributions of the features to all historical daily electricity consumption time series as the importance of the feature.
[0089] ;
[0090] where, represents the average value of the contributions of the l-th feature to all historical daily electricity consumption time series.
[0091] (c)Sort the features in descending order of importance, and take the top n features as the key influencing features, where n is the number of historical daily electricity consumption time series.
[0092] Step 5, train models and make predictions for the residential electricity consumption behavior patterns of different resident groups.
[0093] Model prediction, specifically: Ensure to obtain the historical daily electricity consumption data time series from different resident groups, and obtain the key influencing features through the Xgboost-Shap model. Use PyTorch (an open-source deep learning framework for machine learning and deep learning) to build a TFT (Temporal Fusion Transformer) model. The TFT model is a deep learning model specifically designed for multi-step time series prediction. Adjust the hyperparameters of the TFT model through cross-validation, including the learning rate, batch size, time step, and Dropout parameter. Use the training set to train the TFT model and detect the performance of the TFT model on the validation set. The input of the TFT model consists of two parts: the historical daily electricity consumption data time series and the historical meteorological data time series, including the target variable (daily electricity consumption of residents), historical meteorological data, and masked features. The output is the predicted value of the daily electricity consumption of residents. The evaluation of the TFT model uses the mean squared error (MSE) and the root mean squared error (RMSE).
[0094] The following operations are performed in the temporal fusion transformer model:
[0095] (a)Use the Variable Selection Network (VSN) to adaptively select the input data to obtain a dynamic feature sequence.
[0096] Suppose there are n historical daily electricity consumption data time series of residents, and each historical daily electricity consumption data time series has T time steps. All the input data can be represented as dynamic features , is the data dimension, and the dynamic feature at the t-th time step of the input is represented as .
[0097] The expression for step (a) is: ; where represents the activation function, represents the dynamic feature sequence at the t-th time step after adaptive selection, represents the learnable weight matrix, is the bias term in the adaptive selection process.
[0098] (b)Input the above dynamic feature sequence into the LSTM encoder to generate a hidden state. The hidden state reflects the local trend in the residential electricity consumption behavior pattern. Perform a linear transformation on the hidden state to obtain the input of the multi-head attention mechanism (the result of the linear transformation of the hidden state), and input it into the multi-head attention mechanism.
[0099] The expression for step (b) is: ; represents the hidden state at the (t - 1)-th time step, represents the hidden state at the t-th time step, and LSTM represents the LSTM encoder.
[0100] For the hidden state perform a linear transformation to obtain the linear transformation results Q, K, and V of the hidden state.
[0101] (c) Process the linear transformation results of the hidden state through a multi-head attention mechanism to obtain the output of the multi-head attention mechanism, so as to capture the global temporal dependencies.
[0102] The expression for step (c) is:
[0103] ;
[0104] ;
[0105] where represents the output of the multi-head attention mechanism of *, represents the concatenation operation, represents the output of the m-th head, and the maximum value of m is h, represents the weight matrix of the linear transformation, represents the weight matrix of Q in the m-th head, represents the weight matrix of K in the m-th head, represents the weight matrix of V in the m-th head.
[0106] (d) Input the output of the multi-head attention mechanism and the hidden state into the temporal fusion module to obtain the fusion result. In the temporal fusion module, the fusion of the output of the multi-head attention mechanism and the hidden state is achieved through a fusion function, and specifically, operations such as concatenation and weighted average can be adopted to integrate local and global dependency information and more accurately represent the residential electricity consumption behavior pattern.
[0107] The expression for step (d) is:
[0108] ;
[0109] where represents the fusion result at the t-th time step, represents the fusion function.
[0110] (e) Predict the fusion result obtained in step (d) through the output layer to obtain the predicted values of the daily electricity consumption of each resident within a set future time period.
[0111] The expression for step (e) is:
[0112] ;
[0113] Among them, represents the predicted value of the daily electricity consumption of residents at the t-th time step, represents the bias term of the output layer.
[0114] The above method can perform excellently in dealing with seasonal fluctuations, helping power companies optimize resource allocation and load management. At the same time, the errors of the prediction results are all lower than those of the benchmark model, ensuring high prediction accuracy and providing more reliable data support for decision-making.
[0115] Embodiment 3
[0116] The present invention provides a device for predicting the daily electricity consumption of residents based on dynamic clustering and time series fusion network, including:
[0117] A data acquisition module, configured to: acquire the historical daily electricity consumption time series, key influencing features, and holiday data of multiple residents within the same time period, where the key influencing features are screened from historical meteorological data through an Xgboost model based on the Shap algorithm, and the historical meteorological data is the historical meteorological data of the area corresponding to the historical daily electricity consumption time series of residents;
[0118] A residential electricity consumption behavior pattern analysis module, configured to: perform clustering analysis on the historical daily electricity consumption time series of multiple residents through a K-value clustering analysis algorithm based on dynamic time warping to obtain the residential electricity consumption behavior patterns of each resident, where the residential electricity consumption behavior pattern is a time series including the daily electricity consumption of residents;
[0119] A daily electricity consumption prediction module for residents, configured to: input the key influencing features, holiday data, the historical daily electricity consumption time series of each resident, and the residential electricity consumption behavior pattern into a trained time series fusion transformer model to obtain the predicted values of the daily electricity consumption of each resident within a set future time period, where the time series fusion transformer model is constructed based on the key influencing features.
[0120] Embodiment 4
[0121] In a third aspect, the present invention provides a computer-readable storage medium, on which a computer program / instructions are stored, and when the computer program / instructions are executed by a processor, the steps of the method for predicting the daily electricity consumption of residents based on dynamic clustering and time series fusion network provided in Embodiment 1 are implemented:
[0122] Obtain the historical daily electricity consumption time series, key influencing features, and holiday data of multiple residents within the same time period. The key influencing features are screened from the historical meteorological data through an Xgboost model based on the Shap algorithm, and the historical meteorological data is the historical meteorological data of the area corresponding to the historical daily electricity consumption time series of residents;
[0123] Perform clustering analysis on the historical daily electricity consumption time series of multiple residents through a K - value clustering analysis algorithm based on dynamic time warping to obtain the electricity consumption behavior patterns of each resident. The electricity consumption behavior pattern of residents is a time series containing the daily electricity consumption of residents;
[0124] Input the key influencing features, holiday data, the historical daily electricity consumption time series of each resident, and the electricity consumption behavior pattern of residents into the trained time - series fusion transformer model to obtain the predicted values of the daily electricity consumption of each resident within a future set time period. The time - series fusion transformer model is constructed based on the key influencing features.
[0125] Embodiment 5
[0126] In a fourth aspect, the present invention provides a computer system, including:
[0127] A memory for storing computer programs / instructions;
[0128] A processor for executing the computer programs / instructions to implement the steps of the method for predicting daily electricity consumption of residents based on dynamic clustering and time - series fusion network provided in Embodiment 1:
[0129] Obtain the historical daily electricity consumption time series, key influencing features, and holiday data of multiple residents within the same time period. The key influencing features are screened from the historical meteorological data through an Xgboost model based on the Shap algorithm, and the historical meteorological data is the historical meteorological data of the area corresponding to the historical daily electricity consumption time series of residents;
[0130] Perform clustering analysis on the historical daily electricity consumption time series of multiple residents through a K - value clustering analysis algorithm based on dynamic time warping to obtain the electricity consumption behavior patterns of each resident. The electricity consumption behavior pattern of residents is a time series containing the daily electricity consumption of residents;
[0131] Input the key influencing features, holiday data, the historical daily electricity consumption time series of each resident, and the electricity consumption behavior pattern of residents into the trained time - series fusion transformer model to obtain the predicted values of the daily electricity consumption of each resident within a future set time period. The time - series fusion transformer model is constructed based on the key influencing features.
[0132] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0133] The present application is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram can be implemented by computer program instructions, and the combination of flows and / or blocks in the flowchart and / or block diagram can also be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or multiple blocks.
[0134] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device implements the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or multiple blocks.
[0135] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or multiple blocks.
[0136] The above is only the preferred embodiment of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the technical principle of the present invention, several improvements and modifications can be made, and these improvements and modifications should also be regarded as the protection scope of the present invention.
Claims
1. A method for predicting daily electricity consumption of residents based on dynamic clustering and time series fusion network, characterized in that Including: Obtain the historical daily electricity consumption time series, key influencing features, and holiday data of multiple residents within the same time period. The key influencing features are selected from historical meteorological data through an Xgboost model based on the Shap algorithm, and the historical meteorological data is the historical meteorological data of the region corresponding to the historical daily electricity consumption time series of residents; Perform clustering analysis on the historical daily electricity consumption time series of multiple residents through a K - value clustering analysis algorithm based on dynamic time warping to obtain the electricity consumption behavior patterns of each resident. The electricity consumption behavior pattern of a resident is a time series containing the daily electricity consumption of the resident; Input the key influencing features, holiday data, the historical daily electricity consumption time series of each resident, and the electricity consumption behavior pattern into the trained time - series fusion transformer model to obtain the predicted values of the daily electricity consumption of each resident within a future set time period. The time - series fusion transformer model is constructed based on the key influencing features.
2. The method for predicting daily electricity consumption of residents based on dynamic clustering and temporal fusion network according to claim 1, characterized in that The historical daily electricity consumption time series of residents and the historical meteorological data are obtained through web crawler technology. The historical meteorological data includes historical daily temperature, historical daily humidity, historical sunshine duration, historical precipitation, historical perceived temperature, historical wind speed, and historical weekly data.
3. The method for predicting daily electricity consumption of residents based on dynamic clustering and temporal fusion network according to claim 1, wherein The historical daily electricity consumption time series, key influencing features, and holiday data of multiple residents within the same time period have been pre - processed and standardized; The pre - processing includes dirty data cleaning, missing value handling, and outlier handling. The dirty data cleaning includes eliminating or repairing unreasonable data. The missing value handling includes filling missing values using the mean method, median method, or interpolation method. The outlier handling includes smoothing the outliers; The standardization processing includes: normalizing each item of data to the same dimension.
4. The method for predicting the daily electricity consumption of residents based on dynamic clustering and temporal fusion network according to claim 1, characterized in that, The performing clustering analysis on the historical daily electricity consumption time series of multiple residents through a K - value clustering analysis algorithm based on dynamic time warping to obtain the electricity consumption behavior patterns of each resident includes: Initialize K centroids, where one centroid corresponds to one electricity consumption behavior pattern; Calculate the minimum cumulative distance between the historical daily electricity consumption time series of each resident and each centroid; Assign the historical daily electricity consumption time series of each resident to the centroid with the closest minimum cumulative distance to form clusters composed of centroids and historical daily electricity consumption time series; Within each cluster, take the average of the minimum cumulative distances between all historical daily electricity consumption time series within the cluster and the centroid as the minimum cumulative distance between all historical daily electricity consumption time series within the cluster and the new centroid to obtain the new centroids of each cluster; Repeat the above iterative process until all centroids no longer change or the significance level is less than a preset threshold, stop the iteration, and take the centroids of the last iteration as the electricity consumption behavior patterns of each resident.
5. The method for predicting the daily electricity consumption of residents based on the dynamic clustering and time series fusion network according to claim 4, wherein, The minimum cumulative distance is calculated through the following formula: ; Among them, represents the minimum cumulative distance from the first i elements of the historical daily electricity consumption time series of residents to the first j elements of the centroid, represents the Euclidean distance from the i-th element of the historical daily electricity consumption time series of residents to the j-th element of the centroid, and min{*} represents taking the minimum value of *, represents from the first elements of the historical daily electricity consumption time series of residents to the first j elements of the centroid, represents from the first elements of the historical daily electricity consumption time series of residents to the first j - 1 elements of the centroid, represents from the first elements of the historical daily electricity consumption time series A of residents to the first j - 1 elements of the centroid.
6. The method for predicting daily electricity consumption of residents based on dynamic clustering and temporal fusion network according to claim 1, wherein The key influencing features are obtained through the following method: Obtain the historical daily electricity consumption time series, historical meteorological data, and holiday data of multiple residents within the same time period. Use the historical daily electricity consumption time series of residents as the target variable, and each feature in the historical meteorological data as the independent variable. Construct and train an Xgboost model. Input each feature in the historical meteorological data into the trained Xgboost model, and use the Shap algorithm to analyze the processing process of the Xgboost model, so as to calculate the contribution of each feature in the historical meteorological data to the predicted value of the historical daily electricity consumption time series of residents; The contribution of the feature to the predicted value of the historical daily electricity consumption time series of residents is calculated by the following formula: ; wherein, is the contribution of the l-th feature in the historical meteorological data to the predicted value of the i-th historical daily electricity consumption time series of residents. N is the historical meteorological data, S is a subset of N, f() is the Xgboost model, U represents the union of sets, l represents the l-th feature in the historical meteorological data, || represents taking the absolute value, and! represents factorial; Calculate the average value of the contributions of the feature to all historical daily electricity consumption time series of residents as the importance of the feature; Sort the features according to the importance from large to small, and take the top n features as the key influencing features, where n is the number of historical daily electricity consumption time series of residents.
7. The method for predicting daily electricity consumption of residents based on dynamic clustering and temporal fusion network according to claim 1, wherein Perform the following operations in the time series fusion transformer model: Use the variable selection network to adaptively select the input data to obtain a dynamic feature sequence; Input the above dynamic feature sequence into the LSTM encoder to generate a hidden state, perform a linear transformation on the hidden state to obtain the input of the multi-head attention mechanism, and input it into the multi-head attention mechanism; Obtain the output of the multi-head attention mechanism through the multi-head attention mechanism; Input the output of the multi-head attention mechanism and the hidden state into the time series fusion module to obtain a fusion result; Predict the fusion result through the output layer to obtain the predicted value of the daily electricity consumption of each resident within a future set time period.
8. A device for predicting daily electricity consumption of residents based on dynamic clustering and time series fusion network, characterized in that, Including: A data acquisition module configured to: obtain the historical daily electricity consumption time series, key influencing features, and holiday data of multiple residents within the same time period. The key influencing features are screened from the historical meteorological data through an Xgboost model based on the Shap algorithm, and the historical meteorological data is the historical meteorological data of the area corresponding to the historical daily electricity consumption time series of residents; A residential electricity consumption behavior pattern analysis module configured to: perform clustering analysis on the historical daily electricity consumption time series of multiple residents through a K-value clustering analysis algorithm based on dynamic time warping to obtain the residential electricity consumption behavior pattern of each resident. The residential electricity consumption behavior pattern is a time series including the daily electricity consumption of residents; A residential daily electricity consumption prediction module configured to: input the key influencing features, holiday data, the historical daily electricity consumption time series of each resident, and the residential electricity consumption behavior pattern into the trained time series fusion transformer model to obtain the predicted value of the daily electricity consumption of each resident within a future set time period. The time series fusion transformer model is constructed based on the key influencing features.
9. A computer-readable storage medium having computer programs / instructions stored thereon, characterized in that, When the computer program / instructions are executed by a processor, the steps of the residential daily electricity consumption prediction method based on dynamic clustering and time series fusion network according to any one of claims 1 to 7 are implemented.
10. A computer system, characterized in that, Including: A memory for storing computer programs / instructions; A processor for executing the computer program / instructions to implement the steps of the method for predicting daily electricity consumption of residents based on dynamic clustering and temporal fusion network according to any one of claims 1 to 7.
Citation Information
Cited By
New energy automobile production demand prediction method based on multi-modal fusion
CN120822993A
Electricity price prediction method and system based on clustering and hybrid modeling
CN122288772A