Urban electricity consumption prediction method, system and device fusing time-frequency characteristics and storage medium
Through the combination of short-time Fourier transform and feature pyramid network and Transformer model, the problem of insufficient prediction accuracy of multi-time scales in the existing technology is solved, the effective fusion of time-frequency features is achieved, and the accuracy of urban power consumption prediction is improved. and reliability, suitable for smart grid and energy management.
Patent Information
- Application Number
- CN202411423148.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2024-12-31
AI Technical Summary
The existing power system prediction methods are difficult to meet the needs of complex power grids, especially in the prediction of power consumption changes on multiple time scales. The traditional methods cannot effectively integrate time-frequency characteristics, which limits the prediction accuracy.
The urban electricity consumption prediction method with fusion time-frequency characteristics is adopted, and the multi-time-scale time-frequency characteristics are extracted through short-time Fourier transform, combined with the feature pyramid network and the Transformer model, multi-dimensional feature fusion and embedding are carried out to achieve urban electricity consumption. Accurate prediction.
Improve the accuracy and reliability of urban electricity consumption prediction, can better capture the law of electricity consumption changes under multiple time scales, enhance the robustness and scientificity of the prediction model, and is suitable for smart grid scheduling and energy management. .
Smart Images

Figure CN119227899A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method for predicting urban electricity consumption, in particular to a method for predicting urban electricity consumption integrating time-frequency characteristics. The present invention also relates to a system, device and storage medium for predicting urban electricity consumption. Background Art
[0002] At present, the development of low-carbon electricity market has become the focus of common concern of all countries. As an important link in energy consumption and carbon emissions, the power system plays a vital role in achieving low-carbon transformation. However, traditional power system prediction and analysis methods are unable to cope with the increasingly complex power system needs.
[0003] Existing power system prediction methods mainly rely on numerical simulation and optimization methods. These methods have limitations in dealing with the nonlinear and multidimensional characteristics of power systems and are difficult to meet the operation requirements of power grid systems. In addition, existing methods are also insufficient in interdisciplinary comprehensive analysis and comprehensive system evaluation, making it difficult to fully reflect and solve complex problems at the system level. Studies in recent years have shown that urban economic factors (such as GDP, urbanization rate, electricity efficiency, electricity prices, etc.) and urban meteorological factors (such as daily temperature, relative humidity, wind speed, precipitation, solar radiation, etc.) are closely related to urban electricity consumption, but few studies have conducted comprehensive analysis on these cross-domain data.
[0004] In recent years, with the rapid development of artificial intelligence technology, especially the application based on Transformer structure, it has brought new opportunities for the prediction and analysis of power systems. By learning from massive data, large models can automatically understand and process complex languages and data, and have powerful data processing and analysis capabilities. Applying the Transformer model to the prediction and analysis of power systems can significantly improve the accuracy of predictions and the comprehensiveness of analysis, providing strong support for the optimization and management of power systems.
[0005] Specifically, with the acceleration of urbanization, urban electricity demand presents complex time-varying characteristics, and traditional electricity demand forecasting methods are difficult to meet accuracy requirements. Existing electricity forecasting methods are usually based on a single time scale or a specific statistical model, which makes it difficult to effectively capture the trend of electricity consumption under multiple time scales, especially for long time spans. In addition, with the development of artificial intelligence technology, deep learning models have shown great potential in processing time series data, but existing models are usually limited to processing single time scale data and cannot achieve effective fusion of multi-scale features, which limits the prediction accuracy. Some methods also use frequency domain features purely for prediction and cannot integrate time domain features well. Therefore, developing an efficient prediction method that can integrate multi-time scale data and integrate time-frequency features at the same time has become a technical problem that needs to be solved urgently in the current technical field.
[0006] Related patent literature: CN114881333A discloses a method and device for predicting urban electricity consumption based on new infrastructure, wherein the method includes: obtaining a basic module, an industrial structure module, an electricity intensity module, an industrial value-added module and an electricity demand prediction module in a pre-set urban electricity consumption prediction model framework of new infrastructure; obtaining a first data set required in the basic module, the industrial structure module, the electricity intensity module and the industrial value-added module, analyzing the first data set to obtain a second data set; inputting the second data set into the electricity demand prediction module to obtain urban electricity consumption based on new infrastructure, and by predicting the market size of typical new infrastructure and combining the energy consumption characteristics of new infrastructure, realizing a macro-level prediction of urban electricity consumption under new infrastructure.
[0007] This technology does not provide specific technical guidance on how to improve the accuracy and reliability of urban electricity consumption forecasts. Summary of the invention
[0008] The purpose of the present invention is to provide a method for predicting urban electricity consumption by integrating time-frequency characteristics, which can improve the accuracy and reliability of urban electricity consumption prediction, thereby providing strong support for the optimization and management of the power system.
[0009] To this end, another object of the present invention is to provide a city electricity consumption prediction system, device and storage medium that integrate time-frequency characteristics.
[0010] In order to solve the above technical problems, the technical solution adopted by the present invention is as follows:
[0011] A method for predicting urban electricity consumption by integrating time-frequency characteristics, the technical solution of which is that it includes the following steps:
[0012] S1: Prepare and input historical multivariate time data (closely) related to a city's electricity consumption; the multivariate time data mainly includes three categories: one is historical electricity consumption data, the second is historical economic data, and the third is historical meteorological data.
[0013] S2: Preprocessing and alignment of multivariate time data. Preprocess the multivariate time data prepared in step S1, including processing missing data and aligning data with different time granularities to the daily time granularity. The processed data will be a complete daily multivariate data sequence, ensuring that all feature data are on the same time scale, and obtaining preprocessed multivariate data.
[0014] S3: The multivariate data obtained in step S2 is processed by short-time Fourier transform to extract multi-time-scale time-frequency features. Year, quarter, month, week and day are used as multi-scale time windows. Through different time window parameters, the filter group of short-time Fourier transform is used to extract multivariate data time-frequency feature maps of different scales, so as to retain the time-frequency feature information of different time scales as much as possible. This step obtains the multi-time-scale time-frequency feature map F.
[0015] S4: Use the Feature Pyramid Network (FPN) to perform feature fusion on the multi-time-scale time-frequency feature map F obtained in step S3; through the multi-level structure of FPN, extract features of different time scales, and effectively fuse these features to obtain a multi-dimensional feature fusion matrix, providing rich time-frequency feature information for the subsequent Transformer encoder.
[0016] S5: Input the multi-dimensional feature fusion matrix obtained in step S4 into the Transformer encoder to embed the time-frequency information and obtain the time-frequency feature matrix. The core goal of this step is to utilize the self-attention mechanism and parallel computing capability of the Transformer encoder to effectively embed multi-scale time-frequency features to capture the long-term and short-term dependencies in the time series and provide rich and informative embedding features for the subsequent Transformer decoder.
[0017] S6: Input the time-frequency feature matrix obtained in step S5 into the Transformer decoder, and predict the future daily electricity consumption time series of a city through the decoding process. The main task of the Transformer decoder is to convert the encoded time-frequency feature information into the predicted value of the future time point. Through the self-attention and cross-attention mechanism, the decoder can effectively capture the complex dependencies in the time series, thereby making accurate future electricity consumption predictions.
[0018] In the above technical solution, the preferred technical solution may be that in step S1, the historical electricity consumption data is the daily electricity consumption data Y of a certain city (city X) in the past N years. i ; The historical economic data is the GDP of the city (City X) in the past N years i , urbanization rate CI i , Electricity efficiency EF i 、Electricity price P i The historical meteorological data is the daily temperature T of the city (city X) over the past N years. i , relative humidity RH i , wind speed WS i , precipitation R i 、Solar radiation Sr i ,Since the technical solution tends to observe a longer time window, N is generally required to satisfy N ≥ 10.
[0019] In the above technical solution, a preferred technical solution may also be that step S1 specifically includes:
[0020] S1.1: Collect historical multivariate time data related to electricity consumption in a city over the past N years. The time span of each type of data is N years. Considering the diversity and multidimensionality of these data, structure them into the following form:
[0021] Historical electricity consumption data Y i :Y={y1,y2,…,y N×365}, where Y i represents the electricity consumption on the i-th day;
[0022] Historical Economic Data i :E={(GDP i ,CI i ,EF i ,P i )},i∈{1,2,…,N×365}, economic data may have different time granularities, for example, GDP data may only have quarterly or monthly data;
[0023] Historical weather data MP i :MP={(T i ,RH i ,WS i ,R i ,Sr i )},i∈{1,2,…,N×365}, meteorological data usually have daily time granularity;
[0024] The urbanization rate is calculated as:
[0025] The power efficiency is calculated as:
[0026] The total solar radiation is calculated as:
[0027] Where I(t) represents the instantaneous solar radiation intensity.
[0028] S1.2: All the above data are stored in a structured form. You can choose to use CSV files, SQL databases, or other data storage methods. For data with fewer missing features, it can be stored as a sparse matrix.
[0029] S1.3: Clean the data to remove noise and outliers, perform data consistency checks to ensure that the timestamps of the data are consistent, and complete the data. In subsequent steps, missing values and problems with different time granularities will be handled to ensure data quality and integrity.
[0030] In the above technical solution, a preferred technical solution may also be that step S2 specifically includes:
[0031] S2.1: Preprocessing of multivariate time data: First, process missing data. In multivariate time data, GDP data and urbanization rate CI data may only have monthly or annual statistical data, while electricity consumption data and meteorological data are daily data. In order to align all features to the daily time granularity, interpolation methods are used to fill in the data; further, for multivariate data with different types of time granularity, the following interpolation methods are used: 1. Linear interpolation: Linear interpolation of monthly or annual data to convert it into daily data; 2. Spline interpolation: Applicable to the case where data changes smoothly, providing smoother interpolation results; 3. Zero-order hold: For some data that does not change frequently, such as policy electricity price P i For example, suppose there is a time series x in multivariate data. t , there are missing values between t1 and t2, and the linear interpolation formula is:
[0032]
[0033] By using the above formula, the interpolated value can be calculated for each time point in the time period [t1, t2].
[0034] S2.2: After the above preprocessing steps, taking N years of data as an example, the final daily multivariate data matrix is:
[0035]
[0036] Among them, the city's daily electricity consumption data Y, the city's gross domestic product GDP, urbanization rate CI, electricity efficiency EF, electricity price P, city's daily temperature T, relative humidity RH, wind speed WS, precipitation R, and solar radiation SR are all processed into continuous and non-missing daily data.
[0037] Furthermore, in the above technical solution, a preferred technical solution may also be that in step S2.1, the linear interpolation method is: for a city's economic data, that is, gross domestic product GDP, which only has monthly data, the data can be expressed as follows based on N years: It is necessary to convert monthly data into daily data using linear interpolation. The specific steps are as follows:
[0038] S2.1.1: Time index conversion: convert the time index of monthly data into daily time index. Assume that there are D m days, then the monthly data is expressed as:
[0039]
[0040] S2.1.2: Linear interpolation, calculate the GDP of each day through the linear interpolation formula t value:
[0041] S2.1.3: Further, for annual data (such as urbanization rate), this interpolation method (or similar interpolation methods) is used to linearly interpolate the annual data to the daily time scale. The specific formula is similar to the monthly data interpolation, except that the time interval is 365 or 366 days in a year.
[0042] In the above technical solution, a preferred technical solution may also be that step S3 specifically includes:
[0043] S3.1: Construct a preliminary data set, with M×365 days as the time window, M is the year, M is required to satisfy N>>M, extract daily multivariate time series data as input, and use the first day of electricity consumption after M years as the prediction target, define X My is the daily multivariate time series data for the previous M years, and the output data y 1+My is the electricity consumption on the first day of M years later; multiple samples can be constructed by sliding windows. The input is the daily data of the previous M years, and the output is the electricity consumption on the first day of the M+1 year. The subsequent time window size remains unchanged, slides for 1 day, and outputs the electricity consumption on the second day of the M+1 year, which can be expressed as:
[0044] Where D is the training set or the test set, so that the entire N years of data can be divided into training set and test set according to a certain ratio; for example, the samples generated by the first 80% of the data can be used as the training set, and the last 20% of the data can be used as the test set.
[0045] S3.2: Multi-scale downsampling interpolation, in order to obtain multi-scale time series data, the input data X 10y Perform downsampling interpolation processing, and define the time scale as follows:
[0046] scale Sampling interval Year scale <![CDATA[W y =365 days]]> Quarterly scale <![CDATA[W q =91 days]]> Monthly scale <![CDATA[W m =30 days]]> Weekly scale <![CDATA[W w =7 days]]> Day scale <![CDATA[W d =1 day]]>
[0047] Furthermore, for the downsampled data of different time scales, linear interpolation or spline interpolation method is used for processing. For any time scale s, the interpolated data is defined as:
[0048] X s (t) = Interpolate(X My ,W s ), where W s is the sampling interval corresponding to the time scale;
[0049] S3.3: Short-time Fourier transform (STFT) processing. Apply STFT to the downsampled time series data to obtain time-frequency diagrams of different scales. For each time scale s, the formula is used to calculate:
[0050] Among them, Xs(t,f) is the time-frequency feature at time t and frequency f. Finally, the time-frequency features of different time scales can be combined into a high-dimensional feature matrix F for the subsequent feature pyramid fusion step:
[0051] F=[X y (t,f),X q (t,f),X m (t,f),X w (t,f),X d (t,f)].
[0052] In the above technical solution, a preferred technical solution may also be that step S4 specifically includes:
[0053] S4.1: Input time-frequency feature map. The main advantage of FPN is that it can utilize multi-level features and combine high-resolution detail features with low-resolution semantic features through top-down paths and lateral connections to generate multi-scale fusion features. This enables the model to fully capture dynamic features from local to global. Multiple time-frequency feature maps of different time scales are obtained from step S3. y (t,f),X q (t,f),X m (t,f),X w (t,f),X d(t,f)], these feature maps correspond to the time scales of year, quarter, month, week, and day, respectively, and each feature map has different spatial and frequency resolutions.
[0054] S4.2: FPN feature extraction. The structure of FPN usually includes multiple pyramid layers. The input of each layer comes from the feature map extracted in step S3 and is processed layer by layer through convolutional layers and top-down paths. The main processing process includes:
[0055] 1. Extraction of underlying features: The input time-frequency feature map is passed through a convolutional layer to extract underlying features. The convolutional layer usually uses a 3x3 convolution kernel to maintain spatial resolution and extract local features.
[0056] 2. Use a top-down path and upsampling: Upsample the high-level features layer by layer to align with the spatial resolution of the low-level features, and fuse the upsampled features with the corresponding low-level features layer by layer through lateral connections;
[0057] 3. Horizontal connection: add the upsampled features from the higher layer to the convolutional features of the corresponding layer point by point to form more representative multi-scale features;
[0058] 4. Output pyramid feature map: The fused feature map is used as the multi-scale feature output, that is, the output of the fused feature is realized for the subsequent Transformer encoder; the above feature extraction process is defined by the formula, assuming that the feature map X s The feature obtained by the convolution layer is C s , the feature obtained after upsampling is U s , the fusion feature after horizontal connection is F s , then the definition is as follows:
[0059]
[0060] Finally, the fusion feature output by FPN is F FPN =[F y ,F q ,F m ,F w ,F d ], each level of feature map integrates high-level semantic information and underlying detail information. Through the feature fusion of FPN, the network can capture the dynamic changes of time and frequency in time series at multiple scales, which is particularly critical for dealing with complex urban electricity consumption prediction problems.
[0061] Furthermore, in step S4.2: when extracting the underlying features, the time-frequency feature map of each time scale is (t,f) is input into an independent convolutional layer to extract the underlying features C s , as follows:
[0062] scale Bottom-layer features Cs Year scale <![CDATA[C y =Conv(X y (t,f))]]> Quarterly scale <![CDATA[C q =Conv(X q (t,f))]]> Monthly scale <![CDATA[C m =Conv(X m (t,f))]]> Weekly scale <![CDATA[C w =Conv(X w (t,f))]]> Day scale <![CDATA[C d =Conv(X d (t,f))]]>
[0063] When using the top-down path and upsampling, the annual scale feature C of the highest level y The upsampling process is performed layer by layer and laterally connected with the convolutional features of the lower layers as follows:
[0064] scale Upsampling and lateral connections Quarterly scale <![CDATA[U q =Upsample(C y )+C q ]]> Monthly scale <![CDATA[U m =Upsample(U q )+C m <!-- 5 --> ]]> Weekly scale <![CDATA[U w =Upsample(U m )+C w ]]> Day scale <![CDATA[U d =Upsample(U w )+C d ]]>
[0065] The output of the fused feature is the fused feature F FPN =[F y ,F q ,F m ,F w ,F d ] is combined into a multi-scale feature matrix, where F FPN Can be expanded to:
[0066]
[0067] Each Fs(t,f) represents the time-frequency features after FPN fusion at the time scale s, which is further expanded as:
[0068]
[0069] Each of the components is the feature corresponding to the time scale s, the time-frequency information at time t and frequency f, where X i represents specific economic, meteorological and electricity characteristics, including gross domestic product (GDP), urbanization rate (CI), electricity efficiency (EF), etc. FPN The matrix combines the multi-dimensional features of all time scales (including years, quarters, months, weeks, and days) as input for subsequent Transformer encoders. In this way, the model can utilize multi-scale dynamic time-frequency information to more accurately capture and predict the changing trend of urban electricity consumption.
[0070] In the above technical solution, a preferred technical solution may also be that step S5 specifically includes:
[0071] S5.1: Position encoding and feature embedding. Transformer encoder is used to process sequence data. Position encoding is introduced to retain the order information in the time series. Each time-frequency feature matrix is positionally encoded to ensure that the time order of the time series is not lost during the encoding process. The formula for position encoding is defined as follows:
[0072]
[0073] Where pos is the position in the sequence, i is the dimension index, and d model is the dimension of the feature vector;
[0074] The position code is added to the feature matrix Fs(t,f) of each time scale to ensure that the sequence information is not lost. The calculation formula is:
[0075] S5.2: Encoder layer processing, the Transformer encoder is composed of multiple encoder layers (Encoder Layers) stacked together, each encoder layer consists of two main parts:
[0076] 1. Multi-Head Self-Attention Mechanism: Capture the dependencies between time series features in the input feature matrix;
[0077] 2. Feed-Forward Neural Network (FFN): Further nonlinear transformation is performed on the features processed by the self-attention mechanism. The calculation formula for each encoder layer is:
[0078]
[0079] Furthermore, the specific steps included in step S5.2 are as follows:
[0080] S5.2.1: Multi-head self-attention mechanism processing, input feature matrix F FPN is linearly transformed into a matrix of query Q, key K and value V: Q = F FPN W Q ,K=F FPN W K ,V=F FPN W V , where W Q , W K , W V is a learnable weight matrix, and the self-attention calculation is defined as follows:
[0081]
[0082] Multi-head self-attention performs these calculations in parallel on multiple heads and concatenates the results and transforms them linearly:
[0083] MultiHead(Q,K,V)=Concat(head1,…,head h )W O
[0084] where h is the number of heads, W O is the output weight matrix; this step converts the feature matrix with position encoding Input into the multi-head self-attention mechanism of the Transformer encoder, calculate the attention weights between each feature, and perform weighted summation of the features using these weights, which are defined as follows:
[0085]
[0086] S5.2.2: Feedforward neural network processing, each encoder layer also contains a fully connected feedforward neural network, which is used to perform nonlinear transformation on the features output by the attention layer. FFN usually contains two linear transformations and a ReLU activation function, which is defined as follows:
[0087] FFN(F′)=max(0,F′W1+b1)W2+b2,
[0088] Where W1, W2, and b1, b2 are learnable parameters, and the output Z of the multi-head self-attention mechanism is s Input into the feedforward neural network for further nonlinear feature transformation to obtain the embedded feature matrix F′ FPN :F′ s =FFN(Z s );
[0089] S5.2.3: Stacking processing of encoder layers. Repeat the above steps S5.2.1 and S5.2.2 on multiple encoder layers, deeply embed and extract features layer by layer. Finally, after processing by N layers of encoders, the multi-level embedded time-frequency feature matrix F″ is output. FPN , as the input of the next decoder; assuming a 6-layer encoder structure, the input feature matrix dimension is N×365×10, that is, 10 types of feature data per day for N years, each layer of encoder is processed through position encoding, attention mechanism and feedforward network, and the final output embedding feature matrix F″ FPN It will have richer time-frequency information and be able to preserve the complex dependencies of features at different time scales.
[0090] In the above technical solution, a preferred technical solution may also be that step S6 specifically includes:
[0091] S6.1: Input feature matrix and position encoding. The input of the decoder is the time-frequency feature matrix F″ output from the encoder FPN , and the previously predicted historical electricity consumption sequence as the initial input of the decoder; let the future prediction window length be T f , the decoder will predict the next T fIn order to maintain the sequential order of the decoder in processing sequence data, position encoding is added to the input data in the same way as the encoder. The calculation formula is: where Y t is the input feature of the decoder at time step t; the feature matrix F″ output by the encoder FPN and historical electricity consumption series Y t-1 Input to the decoder, after position encoding the input data, the initial input Y of the decoder is finally generated PE ;
[0092] S6.2: Self-attention calculation processing. In the self-attention layer of the decoder, the input sequence Y generated in step S6.1 is PE Perform self-attention calculation to generate processed sequence features Z d , calculated as follows:
[0093] Z d =Self-Attention(Y PE )+Y PE ,
[0094] The self-attention mechanism is used to process the dependencies in the decoder input sequence. First, the input feature sequence Y PE Linear transformation to query Q d , key K d , value V d matrix:
[0095] Q d =Y PE W Q ,K d =Y PE W K ,V d =Y PE W V
[0096] Calculate the self-attention weight and weighted sum, calculated as follows:
[0097]
[0098] Among them, Q d , K d , V d is the matrix after the decoder input has been linearly transformed.
[0099] S6.3: Encoding-decoding attention mechanism processing, the time-frequency feature matrix F″ output by the encoder FPN As a query, the coded information is weighted extracted and combined with the historical information input by the decoder to generate a prediction of future electricity consumption;
[0100] The specific steps are as follows: d and encoder output F″ FPN Input into the encoding-decoding attention layer, combined with the time-frequency feature information of the encoder, to generate a prediction sequence feature Z rich in time-frequency dependencies ed , the calculation formula is as follows:
[0101] Z ed =Encoder-Decoder Attention(Z d ,F″ FPN )+Z d ,
[0102] The encoder-decoder attention mechanism is used to combine the decoder input with the encoder output to generate a prediction of future electricity consumption, calculated as follows:
[0103]
[0104] Among them, Q ed is the transformed result of the decoder input, K FPN ,V FPN is the transformation result output by the encoder;
[0105] S6.4: Feedforward neural network processing, which is the same (or similar) to the FFN in the encoder step S5.2.2. The feedforward neural network of the decoder layer is used to perform nonlinear transformation on the features processed by the attention mechanism; the predicted sequence feature Z generated in step S6.3 is converted into ed Input into the feedforward neural network and further processed to generate the final decoder output Y′ t , that is, the predicted value of future daily electricity consumption, the calculation formula is Y′ t =FFN(Z ed )+Z ed ,
[0106] The FFN calculation formula is FFN(Z ed )=max(0,Z ed W1+b1)W2+b2;
[0107] S6.5: Decoder layer stacking and final output, repeat the above steps S6.1 to S6.4 in the multi-layer decoder structure, decode layer by layer, and finally output the future T f Daily electricity consumption forecast series Assuming that the future prediction time window is 1 year (365 days), the decoder will decode the input time-frequency features through a 6-layer stacking structure and finally output the future T fThe decoder will make full use of the multi-time-scale time-frequency feature information extracted from the encoder and combine it with the powerful modeling ability of Transformer to generate accurate prediction results; these predictions It will serve as the final electricity consumption forecast output and provide a scientific basis for urban power planning and management.
[0108] A city electricity consumption prediction system integrating time-frequency characteristics, the prediction system uses the above-mentioned city electricity consumption prediction method integrating time-frequency characteristics, and its technical solution is that the prediction system includes:
[0109] The data preparation and preprocessing submodule is used in step S1 and step S2, and includes a data collection module, a data cleaning module, a data completion module, and a time alignment module; wherein the data collection module is responsible for collecting multivariate historical data related to urban electricity consumption, including but not limited to historical electricity consumption data, historical economic data, and historical meteorological data; the time alignment module is responsible for aligning data of different time granularities to the daily time granularity, and completing the data by interpolation method;
[0110] The time-frequency feature extraction submodule, used in step S3, includes a downsampling interpolation module and a short-time Fourier transform module; wherein the downsampling interpolation module is responsible for performing multi-scale downsampling interpolation processing on the input data to obtain data of different time scales; the short-time Fourier transform submodule is responsible for performing short-time Fourier transform (STFT) on the downsampled data to extract time-frequency features of different time scales;
[0111] A feature pyramid network (FPN) submodule, used in step S4, is responsible for using FPN to perform feature fusion on time-frequency feature maps of different time scales, extract features of different time scales and effectively fuse these features;
[0112] The Transformer encoder submodule is used in step S5, and includes a position encoding module, a multi-head self-attention module, and a feedforward neural network module; wherein the position encoding module is responsible for adding position encoding to each time-frequency feature matrix to retain the order information in the time series; the multi-head self-attention module is responsible for calculating the attention weights between the time series features in the input feature matrix, and weighted summing the features through these weights; the feedforward neural network module is responsible for performing nonlinear transformation on the features processed by the attention mechanism;
[0113] The Transformer decoder submodule is used in step S6: it includes a self-attention calculation module, an encoding-decoding attention module, a feedforward neural network module, and a decoder layer stacking module; wherein the self-attention calculation module is responsible for processing the dependencies in the decoder input sequence, calculating the self-attention weights and weighted summing them; the encoding-decoding attention module is responsible for combining the time-frequency feature matrix output by the encoder with the historical information input by the decoder to generate a prediction of future power consumption; the feedforward neural network module is responsible for performing nonlinear transformation on the features processed by the attention mechanism; the decoder layer stacking module is responsible for repeatedly executing the decoding steps and finally outputting a sequence of power consumption predictions for a period of time in the future.
[0114] A device for predicting urban electricity consumption by integrating time-frequency characteristics. The prediction device uses the above-mentioned method for predicting urban electricity consumption by integrating time-frequency characteristics. The technical solution is that the prediction device includes: a processor, a user interface, a network interface, an operating system, a network communication module, a user interface module, and a memory. The memory stores a computer program, that is, the memory stores program instructions. When the program instructions stored in the memory are executed by the processor, the method for predicting urban electricity consumption by integrating time-frequency characteristics is implemented.
[0115] A computer-readable storage medium (a storage medium that receives user input programs), wherein the technical solution is that a city electricity consumption prediction program integrating time-frequency characteristics is stored on the above-mentioned storage medium, and when the program is run on a computer, the above-mentioned city electricity consumption prediction method integrating time-frequency characteristics is executed to achieve accurate prediction of city electricity consumption.
[0116] Compared with the prior art, the present invention has the following beneficial effects:
[0117] Multi-scale feature extraction and fusion: This invention uses short-time Fourier transform (STFT) to extract time-frequency features from multi-time scale (year, quarter, month, week, day) data, so that the model can capture the changing patterns of electricity consumption at different time scales. This multi-scale feature extraction method is relatively rare in existing methods and greatly enhances the robustness and accuracy of the prediction model.
[0118] Feature Pyramid Network (FPN) Enhanced Feature Fusion: By introducing the Feature Pyramid Network (FPN) for multi-scale feature fusion, the present invention can effectively integrate the time-frequency feature information from different time scales, so that the model can make full use of this rich information when predicting future electricity consumption and achieve more accurate predictions.
[0119] Transformer encoding and decoding architecture: This paper uses the Transformer encoder and decoder to embed and decode time-frequency features. The self-attention mechanism of the Transformer model gives it a clear advantage in processing long time series and complex feature information. Compared with traditional RNN or CNN structures, Transformer can better capture long-range dependencies in time series, thereby improving the accuracy of prediction.
[0120] Data preprocessing and time alignment: In view of the inconsistency of time granularity of multivariate time series data, this paper proposes a data preprocessing and time alignment solution, which unifies data of different time granularities to the time scale of daily data through interpolation algorithms. This sophisticated preprocessing method improves the integrity of the data and avoids prediction bias caused by inconsistent data.
[0121] Efficient data prediction capability: Combining cross-domain economic and meteorological data, multi-time scale feature extraction, feature fusion, and the powerful prediction capability of Transformer, the present invention can make high-precision predictions of future urban electricity consumption, and has high practical application value, especially in smart grid dispatching and energy management, which can significantly improve the scientificity and efficiency of decision-making.
[0122] Through these advantages, the present invention shows superior performance over traditional methods and wide application potential in the field of urban electricity consumption forecasting.
[0123] In summary, the present invention provides a method, system, device and storage medium for predicting urban electricity consumption by integrating time-frequency features. The method comprises: firstly, data preparation and preprocessing are performed to extract features of multiple time scales such as year, quarter, month, week and day from historical data containing multidimensional time series data such as electricity consumption, economy and meteorology. Then, the short-time Fourier transform (STFT) is used to perform time-frequency analysis on these data of different time scales to generate a time-frequency feature map. Then, multi-scale feature fusion is performed based on the feature pyramid network (FPN), and the fused feature matrix is input into the Transformer encoder to realize synchronous time-frequency information embedding. Finally, the Transformer decoder decodes and predicts the daily electricity consumption of the city at a specific time point in the future according to the time-frequency feature matrix. The method realizes accurate prediction of electricity consumption at multiple time scales by combining time and frequency information, and can be widely used in smart grid dispatching, energy management and related fields. The present invention improves the accuracy and reliability of urban electricity consumption prediction, thereby providing strong support for the optimization and management of power systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0124] Figure 1It is a structural schematic diagram of a device for predicting urban electricity consumption integrating time-frequency characteristics of a hardware operating environment involved in an embodiment of the present invention.
[0125] Figure 2 It is a flow chart of an embodiment of a method for predicting urban electricity consumption (integrating time-frequency features) of the present invention.
[0126] Figure 3 It is a schematic diagram of the process of generating time-frequency characteristics of multivariate data in an embodiment of the urban electricity consumption prediction method of the present invention.
[0127] Figure 4 This is the time-frequency feature graph of multi-scale data extracted by the present invention, with year, quarter, month, week and day as the multi-scale time window ( Figure 4 Can be seen as Figure 3 (a partial enlarged view of the right end of the ).
[0128] Figure 5 It is a structural diagram of a feature pyramid network and a Transformer codec of an embodiment of a method for predicting urban electricity consumption of the present invention. DETAILED DESCRIPTION
[0129] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described in conjunction with the embodiments below. Obviously, the described embodiments are part of the embodiments of the present invention, not all of them. Based on this embodiment, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of the present invention.
[0130] Example 1: Figure 1 As shown, the urban electricity consumption prediction device integrating time-frequency characteristics uses the above-mentioned urban electricity consumption prediction method integrating time-frequency characteristics, and its technical solution is that the prediction device includes: a processor, a user interface, a network interface, an operating system, a network communication module, a user interface module, and a memory, wherein the memory stores a computer program, that is, the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the urban electricity consumption prediction method integrating time-frequency characteristics is implemented.
[0131] Further, the urban electricity consumption prediction device integrating time-frequency characteristics may include: a processor 1001, such as a CPU, a C-GPU integrating a CPU, a GPU and an NPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize data connection communication between these components. The user interface 1003 may include a display to facilitate users to view data and system status; the optional user interface 1003 may also include standard wired interfaces such as a keyboard and a mouse, or wireless interfaces such as Bluetooth and infrared. The network interface 1004 may optionally include wired interfaces such as standard Ethernet interfaces and optical fiber interfaces, as well as wireless interfaces such as Wi-Fi, Bluetooth, and mobile networks. The memory 1005 may be a high-speed RAM memory for temporarily storing data and instructions being processed; it may also be a non-volatile memory, such as a solid-state drive (SSD) or a mechanical hard disk (HDD). The memory 1005 may also be an optional storage server independent of the aforementioned processor 1001 to provide greater storage capacity or better data security. In addition, the device may also include a power module for powering the device and managing the power status; an optional encryption module for ensuring the security of data transmission; and a heat dissipation module for ensuring that the device operates at a suitable operating temperature. These components work together to ensure that the urban electricity consumption forecasting device can operate stably and efficiently, and achieve accurate electricity consumption forecasting.
[0132] Those skilled in the art will understand that Figure 1 The structure shown in does not constitute a limitation on the urban electricity consumption prediction device, and may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component layout. For example, the user interface can add a touch screen function according to the actual application scenario, the network interface can integrate multiple types of communication protocols, and the memory can use a combination of multiple storage technologies to adapt to different data storage requirements. These changes and adjustments are all within the scope of protection of the present invention.
[0133] Example 2: Figure 2 , Figure 3 , Figure 4 As shown in the figure, the urban electricity consumption prediction method integrating time-frequency characteristics includes the following steps:
[0134] S1: Prepare and input historical multivariate time data (closely related to) a city's electricity consumption; the multivariate time data mainly includes three categories: historical electricity consumption data, historical economic data, and historical meteorological data. In step S1, the historical electricity consumption data is the daily electricity consumption data Y of a city (city X) over the past N years. i; The historical economic data is the GDP of the city (City X) in the past N years i , urbanization rate CI i , Electricity efficiency EF i 、Electricity price P i The historical meteorological data is the daily temperature T of the city (city X) over the past N years. i , relative humidity RH i , wind speed WS i , precipitation R i 、Solar radiation Sr i , since the technical solution tends to observe a longer time window, N is generally required to satisfy N≥10. In this embodiment, N=30 years of urban multivariate time series data were collected, including: historical electricity consumption data X(t), where t represents daily urban electricity consumption from the 1st day to the 30×365th day; economic data: including urban gross domestic product GDP(t), urbanization rate CI(t), electricity efficiency EF(t), electricity price P(t); meteorological data: including daily temperature T(t), relative humidity RH(t), wind speed WS(t), precipitation R(t), solar radiation SR(t); the time span of each data set is 30 years, recorded on a daily basis, that is, the length of each data series is 30×365=10950 days.
[0135] Step S1 specifically includes:
[0136] S1.1: Collect historical multivariate time data related to electricity consumption in a city over the past N years. The time span of each type of data is N years. Considering the diversity and multidimensionality of these data, structure them into the following form:
[0137] Historical electricity consumption data Y i :Y={y1,y2,…,y N×365}, where Y i represents the electricity consumption on the i-th day;
[0138] Historical Economic Data i :E={(GDP i ,CI i ,EF i ,P i )},i∈{1,2,…,N×365}, economic data may have different time granularities;
[0139] Historical weather data MP i :MP={(T i ,RH i ,WS i ,R i ,Sr i)},i∈{1,2,…,N×365}, meteorological data usually have daily time granularity;
[0140] The urbanization rate is calculated as:
[0141] The power efficiency is calculated as:
[0142] The total solar radiation is calculated as:
[0143] Where I(t) represents the instantaneous solar radiation intensity.
[0144] S1.2: All the above data are stored in a structured form. You can choose to use CSV files, SQL databases or other data storage methods. For data with fewer missing features, it can be stored as a sparse matrix. In this embodiment, the time series data of each category are sorted according to a unified time tag and archived in the following matrix form:
[0145]
[0146] Among them, data with fewer missing features can be stored as a sparse matrix.
[0147] S1.3: Clean the data to remove noise and outliers, perform data consistency checks to ensure that the timestamps of the data are consistent, and complete the data. In subsequent steps, missing values and problems with different time granularities will be handled to ensure data quality and integrity.
[0148] In order to ensure data quality and integrity, data cleaning is required to remove noise and outliers, check whether there are missing values or outliers in each data column, and use the following formula to identify outliers:
[0149]
[0150] Where D(t) is the data value, μ is the mean, σ is the standard deviation, and if |Z(t)|>3, it is marked as an outlier; for missing values, the interpolation algorithm is used to fill them in the subsequent steps; at the same time, according to the general processing flow, the multivariate time series data is normalized to eliminate the differences caused by different data dimensions. The following normalization formula is used:
[0151]
[0152] Among them, min(D) and max(D) are the minimum and maximum values of the data sequence respectively; finally, for each subsequence D′ iThe data (length of M = 10 years, about 3650 days) are extracted and prepared for subsequent time-frequency analysis and feature extraction. The generated data set includes multiple subsets with a length of M = 10 years for training and testing in subsequent steps.
[0153] S2: Preprocessing and alignment of multivariate time data: preprocess the multivariate time data prepared in step S1, including processing missing data and aligning data with different time granularities to the daily time granularity; the processed data will be a complete daily multivariate data sequence, ensuring that all feature data are on the same time scale, and obtaining preprocessed multivariate data. Step S2 specifically includes:
[0154] S2.1: Preprocessing of multivariate time data: First, process missing data. In multivariate time data, GDP data and urbanization rate CI data may only have monthly or annual statistical data, while electricity consumption data and meteorological data are daily data. In order to align all features to the daily time granularity, interpolation methods are used to fill in the data; further, for multivariate data with different types of time granularity, the following interpolation methods are used: 1. Linear interpolation: Linear interpolation of monthly or annual data to convert it into daily data; 2. Spline interpolation: Applicable to the case where data changes smoothly, providing smoother interpolation results; 3. Zero-order hold: For some data that does not change frequently, such as policy electricity price P i For example, suppose there is a time series x in multivariate data. t , there are missing values between t1 and t2, and the linear interpolation formula is:
[0155]
[0156] By using the above formula, the interpolated value can be calculated for each time point in the time period [t1, t2].
[0157] In step S2.1, the specific method of linear interpolation is: for a city's economic data, that is, gross domestic product (GDP), which only has monthly data, the data can be expressed as follows based on N years: It is necessary to convert monthly data into daily data using linear interpolation. The steps are as follows:
[0158] S2.1.1: Time index conversion: convert the time index of monthly data into daily time index. Assume that there are D m days, then the monthly data is expressed as:
[0159]
[0160] S2.1.2: Linear interpolation, calculate the GDP of each day through the linear interpolation formulat value:
[0161] S2.1.3: For annual data (such as urbanization rate), use this interpolation method (or a similar interpolation method) to linearly interpolate the annual data to the daily time scale. The specific formula is similar to the monthly data interpolation, except that the time interval is 365 or 366 days in a year.
[0162] The goal of the data integrity check preprocessing step is to ensure the consistency and integrity of the data and to ensure that there are corresponding multivariate data at each time point. For the 30 years of data collected and sorted in step S1, check whether each data feature is missing. If missing data is found, it is supplemented by an appropriate interpolation algorithm. Let D i (t) represents the value of the i-th type of data at time t. If D i If (t) is missing, the neighboring value interpolation method is used to fill it in:
[0163]
[0164] Alternatively, polynomial interpolation can be used to fit missing values based on contextual information.
[0165] In addition to data interpolation and filling, the goal of the time granularity alignment step is to align data of different time granularities to the daily data level to ensure the consistency of time-frequency feature extraction. For example, economic data GDP(t) is usually counted on a monthly basis, while other data (such as electricity consumption, temperature, etc.) are counted on a daily basis. Suppose the GDP(t) data for a certain month only has GDP january , and there are 31 days in between, so 31 days of daily GDP data need to be generated. The interpolation formula is as follows:
[0166]
[0167] Among them, t represents the tth day in January; similar to the above process, linear interpolation, spline interpolation and other methods can be used to interpolate lower frequency data such as quarterly and annual data to daily data, and the calculation is as follows:
[0168]
[0169] Here, n is the number of data points that need to be interpolated.
[0170] S2.2: After the above preprocessing steps, taking N years of data as an example, the final daily multivariate data matrix is:
[0171]
[0172] Among them, the city's daily electricity consumption data Y, the city's gross domestic product GDP, urbanization rate CI, electricity efficiency EF, electricity price P, city's daily temperature T, relative humidity RH, wind speed WS, precipitation R, and solar radiation SR are all processed into continuous and non-missing daily data.
[0173] The goal of the synchronization and alignment step of the multivariate time series is to ensure that all feature data at each time point are synchronized and aligned. Based on the daily multivariate data generated in the previous step, a complete daily data matrix is formed. Assuming that the data has been interpolated, the final aligned daily data matrix is:
[0174]
[0175] Taking GDP(t) as an example, assuming that the original data has only one data point per month, GDP′(t) is generated for each day through interpolation, thereby aligning all features to each day; a completeness check is performed on the interpolated data to ensure that all data points are physically and statistically reasonable. If abnormal data points are found, they need to be corrected according to the specific situation. The data generated after interpolation are checked using an outlier detection method similar to that in step S1, and are corrected based on the test results. Finally, a complete and consistent daily multivariate data matrix is generated to prepare for the subsequent time-frequency feature extraction. Through the above steps, the final and complete daily data matrix D′ is generated, with a dimension of 10950×10, where 10950 is the number of days in 30 years and 10 is the number of multivariate data.
[0176] S3: The multivariate data obtained in step S2 is processed by short-time Fourier transform to extract multi-time-scale time-frequency features. Year, quarter, month, week, and day are used as multi-scale time windows. The multivariate data time-frequency feature graphs of different scales are extracted by using the filter group of short-time Fourier transform through different time window parameters, so as to retain the time-frequency feature information of different time scales as much as possible. This step obtains the multi-time-scale time-frequency feature graph F. Step S3 specifically includes:
[0177] S3.1: Construct a preliminary data set, with M×365 days as the time window, M is the year, M is required to satisfy N>>M, extract daily multivariate time series data as input, and use the first day of electricity consumption after M years as the prediction target, define X My is the daily multivariate time series data for the previous M years, and the output data y 1+My is the electricity consumption on the first day of M years later; multiple samples can be constructed by sliding windows. The input is the daily data of the previous M years, and the output is the electricity consumption on the first day of the M+1 year. The subsequent time window size remains unchanged, slides for 1 day, and outputs the electricity consumption on the second day of the M+1 year, which can be expressed as:
[0178] Where D is the training set or the test set, so that the entire N years of data can be divided into training set and test set according to a certain ratio; for example, the samples generated by the first 80% of the data can be used as the training set, and the last 20% of the data can be used as the test set.
[0179] Specifically, this step can be to define time windows and segments, and segment the daily multivariate time series data of 30 years (N=30) into windows of M=10 years. Each segment of data contains 10 years of daily data. The number of days contained in each time window is: Wi=365×M (number of days). For the case of M=10 years, each time window contains 3650 days of data, so there are a total of T=10950 days of data. The data set can be defined as:
[0180] Input data: X 10y ={X(t),X(t+1),…,X(t+3650)},
[0181] Output data: y t+10y =y(t+3650),
[0182] The input is the daily data of the previous 10 years, and the output is the electricity consumption on the first day of the 11th year. The subsequent time window size remains unchanged, slides for 1 day, and outputs the electricity consumption on the second day of the 11th year, thereby constructing the training set and test set.
[0183] S3.2: Multi-scale downsampling interpolation, in order to obtain multi-scale time series data, the input data X 10y Perform downsampling interpolation processing, and define the time scale as follows:
[0184] scale Sampling interval Year scale <![CDATA[W y =365 days]]> Quarterly scale <![CDATA[W q =91 days]]> Monthly scale <![CDATA[W m =30 days]]> Weekly scale <![CDATA[W w =7 days]]> Day scale <![CDATA[W d =1 day]]>
[0185] Furthermore, for the downsampled data of different time scales, linear interpolation or spline interpolation method is used for processing. For any time scale s, the interpolated data is defined as:
[0186] X s (t) = Interpolate(X My ,W s ), where W s is the sampling interval corresponding to the time scale;
[0187] This step can be specifically as follows: the data downsampling and interpolation steps are performed for each time window W i , for each data feature D i (t) Downsampling and interpolation are performed to obtain data series at five time scales: year, quarter, month, week, and day. After sampling, the same as step S3.1 is performed, and resampling is performed after sliding the 1-day time window, and finally a data series of different time scales related to each sample in the entire data set is generated.
[0188] S3.3: Short-time Fourier transform (STFT) processing. Apply STFT to the downsampled time series data to obtain time-frequency diagrams of different scales. For each time scale s, the formula is used to calculate:
[0189] Among them, Xs(t,f) is the time-frequency feature at time t and frequency f. Finally, the time-frequency features of different time scales can be combined into a high-dimensional feature matrix F for the subsequent feature pyramid fusion step:
[0190] F=[X y (t,f),X q (t,f),X m (t,f),X w (t,f),X d (t,f)].
[0191] Specifically, this step may be to perform a short-time Fourier transform (STFT) on the data sequence of each time scale after downsampling, extract the time-frequency feature graph of each time scale, and .... The STFT is calculated at different time scales (year, quarter, month, week, day) as follows:
[0192]
[0193] Among them, w(nm) is the window function, ω is the frequency variable, and n is the time variable. The appropriate window function w(nm) is selected according to the data characteristics of each scale; for each data feature Di(t) at each time scale, the corresponding time-frequency feature map is obtained through STFT The feature maps of all time scales are spliced to obtain the final multi-scale time-frequency feature map matrix F i :
[0194]
[0195] Each of these The dimension of is determined by the time step and frequency resolution of the STFT calculation. The final spliced F i It is a collection of time-frequency feature maps at five different time scales. Taking 30 years of daily electricity consumption data as an example, it is divided into 10-year windows for STFT analysis to generate time-frequency feature maps at different time scales. The STFT results of each time scale are spliced to finally generate a time-frequency feature map matrix containing 5 scales, in preparation for subsequent feature fusion.
[0196] S4: Use the Feature Pyramid Network (FPN) to perform feature fusion on the multi-time-scale time-frequency feature map F obtained in step S3; through the multi-level structure of FPN, extract features of different time scales, and effectively fuse these features to obtain a multi-dimensional feature fusion matrix, providing rich time-frequency feature information for the subsequent Transformer encoder. Step S4 specifically includes:
[0197] S4.1: Input time-frequency feature map. The main advantage of FPN is that it can utilize multi-level features and combine high-resolution detail features with low-resolution semantic features through top-down paths and lateral connections to generate multi-scale fusion features. This enables the model to fully capture dynamic features from local to global. Multiple time-frequency feature maps of different time scales are obtained from step S3. y (t,f),X q (t,f),X m (t,f),X w (t,f),X d (t,f)], these feature maps correspond to the time scales of year, quarter, month, week, and day, respectively. Each feature map has different spatial and frequency resolutions, capturing the dynamic characteristics at their respective time scales.
[0198] S4.2: FPN feature extraction. The structure of FPN usually includes multiple pyramid layers. The input of each layer comes from the feature map extracted in step S3 and is processed layer by layer through convolutional layers and top-down paths. The main processing process includes:
[0199] 1. Extraction of underlying features: The input time-frequency feature map is passed through a convolutional layer to extract underlying features. The convolutional layer usually uses a 3x3 convolution kernel to maintain spatial resolution and extract local features.
[0200] 2. Use a top-down path and upsampling: Upsample the high-level features layer by layer to align with the spatial resolution of the low-level features, and fuse the upsampled features with the corresponding low-level features layer by layer through lateral connections;
[0201] 3. Horizontal connection: add the upsampled features from the higher layer to the convolutional features of the corresponding layer point by point to form more representative multi-scale features;
[0202] 4. Output pyramid feature map: The fused feature map is used as the multi-scale feature output, that is, the output of the fused feature is realized for the subsequent Transformer encoder; the above feature extraction process is defined by the formula, assuming that the feature map Xs The feature obtained by the convolution layer is C s , the feature obtained after upsampling is U s , the fusion feature after horizontal connection is F s , then the definition is as follows:
[0203]
[0204] Finally, the fusion feature output by FPN is F FPN =[F y ,F q ,F m ,F w ,F d ], each level of feature map integrates high-level semantic information and underlying detail information. Through the feature fusion of FPN, the network can capture the dynamic changes of time and frequency in time series at multiple scales, which is particularly critical for dealing with complex urban electricity consumption prediction problems.
[0205] In this step, the structure of FPN is mainly composed of multiple pyramid layers. Each pyramid layer obtains input from the feature map extracted in step S3 and processes it layer by layer through convolutional layers and top-down paths. This process involves the extraction of underlying features, upsampling of top-down paths, fusion of lateral connections, and the final output of multi-scale features.
[0206] Furthermore, in step S4.2: when extracting the underlying features, the time-frequency feature map of each time scale is (t,f) is input into an independent convolutional layer to extract the underlying features C s , as follows:
[0207] scale Bottom-layer features Cs Year scale <![CDATA[C y =Conv(X y (t,f))]]> Quarterly scale <![CDATA[C q =Conv(X q (t,f))]]> Monthly scale <![CDATA[C m =Conv(X m (t,f))]]> Weekly scale <![CDATA[C w =Conv(X w (t,f))]]> Day scale <![CDATA[C d =Conv(X d (t,f))]]>
[0208] This step can be specifically, the underlying feature extraction for each time scale time-frequency feature map X s (t,f), the underlying features are extracted through the convolution layer. The convolution layer usually uses a 3x3 convolution kernel to maintain the spatial resolution and extract local features, defined as C s =Conv(X s (t,f)), where s represents the time scale (year, quarter, month, week, day), and C s Represents the underlying features extracted by the convolutional layer, which is calculated as follows:
[0209]
[0210] When using the top-down path and upsampling, the annual scale feature C of the highest level yThe upsampling process is performed layer by layer and laterally connected with the convolutional features of the lower layers as follows:
[0211] scale Upsampling and lateral connections Quarterly scale <![CDATA[U q =Upsample(C y )+C q ]]> Monthly scale <![CDATA[U m =Upsample(U q )+C m ]]> Weekly scale <![CDATA[U w =Upsample(U m )+C w ]]> Day scale <![CDATA[U d =Upsample(U w )+C d ]]>
[0212] This step can be specifically, the top-down path and upsampling from the highest level annual scale feature C y At the beginning, upsampling is performed layer by layer to align the spatial resolution of high-level features with lower-level features, and they are fused with the convolutional features of the lower layers through lateral connections, as follows:
[0213]
[0214] Among them, U s Represents the upsampled feature map and the horizontally connected feature map F s It will contain rich multi-scale feature information. The horizontal connection adds the upsampled high-level features to the corresponding low-level convolutional features point by point to generate a more representative multi-scale fusion feature map.
[0215] The output of the fused feature is the fused feature F FPN =[F y ,F q ,F m ,F w ,F d ] is combined into a multi-scale feature matrix, where F FPN Can be expanded to:
[0216]
[0217] Each Fs(t,f) represents the time-frequency features after FPN fusion at the time scale s. These features contain the fusion of multi-dimensional feature information (such as GDP, CI, EF, etc.). Further expansion is:
[0218]
[0219] Each of the components is the feature corresponding to the time scale s, the time-frequency information at time t and frequency f, where X i represents specific economic, meteorological and electricity characteristics, including gross domestic product (GDP), urbanization rate (CI), electricity efficiency (EF), etc. FPN The matrix combines the multi-dimensional features of all time scales (including years, quarters, months, weeks, and days) as input for subsequent Transformer encoders. In this way, the model can utilize multi-scale dynamic time-frequency information to more accurately capture and predict the changing trend of urban electricity consumption.
[0220] S5: Input the multi-dimensional feature fusion matrix obtained in step S4 into the Transformer encoder to embed the time-frequency information and obtain the time-frequency feature matrix. The core goal of this step is to use the self-attention mechanism and parallel computing capability of the Transformer encoder to effectively embed multi-scale time-frequency features to capture the long-term and short-term dependencies in the time series and provide rich and informative embedding features for the subsequent Transformer decoder. Step S5 specifically includes:
[0221] S5.1: Position encoding and feature embedding. Transformer encoder is used to process sequence data. In order to retain the order information of the time series, position encoding is introduced to retain the order information in the time series. Position encoding is performed on each time-frequency feature matrix to ensure that the time order of the time series will not be lost during the encoding process (position encoding ensures that the time order of the time series will not be lost during the feature embedding process). The formula for position encoding is defined as follows:
[0222]
[0223] Where pos is the position in the sequence, i is the dimension index, and d model is the dimension of the feature vector; for each time scale feature matrix F s (t,f), the position code is added to the feature matrix Fs(t,f) of each time scale to ensure that the sequence information is not lost. The calculation formula is:
[0224] Among them, F s (t,f) is the time-frequency feature map at the time scale s. By adding the position encoding PE(t) to each feature matrix, it ensures that the Transformer encoder can correctly capture the sequential information of the time series.
[0225] S5.2: Encoder layer processing, the Transformer encoder is composed of multiple encoder layers (Encoder Layers) stacked together, each encoder layer consists of two main parts:
[0226] 1. Multi-Head Self-Attention Mechanism: Capture the dependencies between time series features in the input feature matrix;
[0227] 2. Feed-Forward Neural Network (FFN): Further nonlinear transformation is performed on the features processed by the self-attention mechanism. The calculation formula for each encoder layer is:
[0228]
[0229] Among them, Z is the intermediate feature matrix after being processed by the multi-head self-attention mechanism, and F′ FPN It is the output feature matrix after being processed by the feedforward neural network.
[0230] Furthermore, the specific steps included in step S5.2 are as follows:
[0231] S5.2.1: Multi-head self-attention mechanism processing, input feature matrix F FPN is linearly transformed into a matrix of query Q, key K and value V: Q = F FPN W Q ,K=F FPN W K ,V=F FPN W V , where W Q , W K , W V is a learnable weight matrix, and the self-attention calculation is defined as follows:
[0232]
[0233] in, is a scaling factor used to prevent the gradient from disappearing or exploding due to excessive inner product values; multi-head self-attention performs these calculations in parallel on multiple heads and concatenates the results and transforms them linearly:
[0234] MultiHead(Q,K,V)=Concat(head1,…,head h )W O
[0235] where h is the number of heads, W O is the output weight matrix; this step converts the feature matrix with position encoding Input into the multi-head self-attention mechanism of the Transformer encoder, calculate the attention weights between each feature, and perform weighted summation of the features by these weights, defined as follows (obtained as follows):
[0236]
[0237] S5.2.2: Feedforward neural network processing, each encoder layer also contains a fully connected feedforward neural network, which is used to perform nonlinear transformation on the features output by the attention layer. FFN usually contains two linear transformations and a ReLU activation function, which is defined as follows:
[0238] FFN(F′)=max(0,F′W1+b1)W2+b2,
[0239] Where W1, W2, and b1, b2 are learnable parameters, and the output Z of the multi-head self-attention mechanism is s Input into the feedforward neural network for further nonlinear feature transformation to obtain the embedded feature matrix F′ FPN :F′ s =FFN(Z s );
[0240] S5.2.3: Stacking processing of encoder layers. Repeat the above steps S5.2.1 and S5.2.2 on multiple encoder layers to deeply embed and extract features layer by layer. Assuming a 6-layer encoder structure, the input feature matrix dimension is N×365×10, that is, 10 types of feature data per day for N years (30 years). Each layer of encoder is processed through position encoding, multi-head self-attention mechanism and feedforward network to gradually extract and embed deeper features. Finally, after processing by N layers of encoders, the multi-level embedded time-frequency feature matrix F″ is output. FPN , as the input of the next decoder, so that after being processed by the 6-layer encoder, the output embedding feature matrix F″ FPN It will contain richer time-frequency information and be able to preserve the complex dependencies of features at different time scales. These embedded features will be used as decoder input for further prediction processing.
[0241] S6: Input the time-frequency feature matrix obtained in step S5 into the Transformer decoder, and predict the future daily electricity consumption time series of a city through the decoding process. The main task of the Transformer decoder is to convert the encoded time-frequency feature information into the predicted value of the future time point. Through the self-attention and cross-attention mechanism, the decoder can effectively capture the complex dependencies in the time series, so as to accurately predict the future electricity consumption. Step S6 specifically includes:
[0242] S6.1: Input feature matrix and position encoding. The input of the decoder is the time-frequency feature matrix F″ output from the encoder FPN , and the previously predicted historical electricity consumption sequence as the initial input of the decoder; let the future prediction window length be T f , the decoder will predict the next T f In order to maintain the sequential order of the decoder in processing sequence data, position encoding is added to the input data in the same way as the encoder. The calculation formula is: where Y t is the input feature of the decoder at time step t; the feature matrix F″ output by the encoder FPN and historical electricity consumption series Y t-1Input to the decoder, after position encoding the input data, the initial input Y of the decoder is finally generated PE .
[0243] S6.2: Self-attention calculation processing. In the self-attention layer of the decoder, the input sequence Y generated in step S6.1 is PE Perform self-attention calculation to generate processed sequence features Z d , calculated as follows:
[0244] Z d =Self-Attention(Y PE )+Y PE ,
[0245] The self-attention mechanism is used to process the dependencies in the decoder input sequence. First, the input feature sequence Y PE Linear transformation to query Q d , key K d , value V d matrix:
[0246] Q d =Y PE W Q ,K d =Y PE W K ,V d =Y PE W V
[0247] Calculate the self-attention weight and weighted sum, calculated as follows:
[0248]
[0249] Among them, Q d , K d , V d is the matrix after the decoder input has been linearly transformed.
[0250] S6.3: Encoding-decoding attention mechanism processing, the time-frequency feature matrix F″ output by the encoder FPN As a query, the coded information is weighted extracted and combined with the historical information input by the decoder to generate a prediction of future electricity consumption;
[0251] The specific steps are as follows: d and encoder output F″ FPN Input into the encoding-decoding attention layer, combined with the time-frequency feature information of the encoder, to generate a prediction sequence feature Z rich in time-frequency dependencies ed , the calculation formula is as follows:
[0252] Z ed =Encoder-Decoder Attention(Z d ,F″ FPN )+Z d ,
[0253] The encoder-decoder attention mechanism is used to combine the decoder input with the encoder output to generate a prediction of future electricity consumption, calculated as follows:
[0254]
[0255] Among them, Q ed is the transformed result of the decoder input, K FPN ,V FPN It is the transformation result output by the encoder.
[0256] S6.4: Feedforward neural network processing, which is the same (or similar) to the FFN in the encoder step S5.2.2. The feedforward neural network of the decoder layer is used to perform nonlinear transformation on the features processed by the attention mechanism; the predicted sequence feature Z generated in step S6.3 is converted into ed Input into the feedforward neural network and further processed to generate the final decoder output Y′ t , which is the predicted value of future daily electricity consumption, and the calculation formula is Y′ t =FFN(Z ed )+Z ed ,
[0257] The FFN calculation formula is FFN(Z ed )=max(0,Z ed W1+b1)W2+b2;
[0258] S6.5: Decoder layer stacking and final output, repeat the above steps S6.1 to S6.4 in the multi-layer decoder structure, decode layer by layer, and finally output the future T f Daily electricity consumption forecast series Assuming that the future prediction time window is 1 year (365 days), the decoder will decode the input time-frequency features through a 6-layer stacking structure and finally output the future T f The decoder will make full use of the multi-time-scale time-frequency feature information extracted from the encoder and combine it with the powerful modeling ability of Transformer to generate accurate prediction results; these predictions It will serve as the final electricity consumption forecast output and provide a scientific basis for urban power planning and management.
[0259] Embodiment 3: A city electricity consumption prediction system integrating time-frequency characteristics, wherein the prediction system uses the above-mentioned city electricity consumption prediction method integrating time-frequency characteristics, and the technical solution thereof is that the prediction system comprises:
[0260] The data preparation and preprocessing submodule is used in step S1 and step S2, and includes a data collection module, a data cleaning module, a data completion module, and a time alignment module; wherein the data collection module is responsible for collecting multivariate historical data related to urban electricity consumption, including but not limited to historical electricity consumption data, historical economic data, and historical meteorological data; the time alignment module is responsible for aligning data of different time granularities to the daily time granularity, and completing the data by interpolation method;
[0261] The time-frequency feature extraction submodule, used in step S3, includes a downsampling interpolation module and a short-time Fourier transform module; wherein the downsampling interpolation module is responsible for performing multi-scale downsampling interpolation processing on the input data to obtain data of different time scales; the short-time Fourier transform submodule is responsible for performing short-time Fourier transform (STFT) on the downsampled data to extract time-frequency features of different time scales;
[0262] A feature pyramid network (FPN) submodule, used in step S4, is responsible for using FPN to perform feature fusion on time-frequency feature maps of different time scales, extract features of different time scales and effectively fuse these features;
[0263] The Transformer encoder submodule is used in step S5, and includes a position encoding module, a multi-head self-attention module, and a feedforward neural network module; wherein the position encoding module is responsible for adding position encoding to each time-frequency feature matrix to retain the order information in the time series; the multi-head self-attention module is responsible for calculating the attention weights between the time series features in the input feature matrix, and weighted summing the features through these weights; the feedforward neural network module is responsible for performing nonlinear transformation on the features processed by the attention mechanism;
[0264] The Transformer decoder submodule is used in step S6: it includes a self-attention calculation module, an encoding-decoding attention module, a feedforward neural network module, and a decoder layer stacking module; wherein the self-attention calculation module is responsible for processing the dependencies in the decoder input sequence, calculating the self-attention weights and weighted summing them; the encoding-decoding attention module is responsible for combining the time-frequency feature matrix output by the encoder with the historical information input by the decoder to generate a prediction of future power consumption; the feedforward neural network module is responsible for performing nonlinear transformation on the features processed by the attention mechanism; the decoder layer stacking module is responsible for repeatedly executing the decoding steps and finally outputting a sequence of power consumption predictions for a period of time in the future.
[0265] Embodiment 4: A computer-readable storage medium (a storage medium that receives user input programs), wherein a city electricity consumption prediction program integrating time-frequency features is stored on the storage medium, and when the program is run on a computer, the city electricity consumption prediction method integrating time-frequency features is executed to achieve accurate prediction of city electricity consumption.
[0266] In summary, the present invention aims to utilize multi-scale time series data to extract and fuse features through feature pyramid network (FPN) and transformer network (Transformer), thereby realizing high-precision prediction of future urban daily electricity consumption. It is an efficient prediction method that can integrate multi-time scale data and fuse time-frequency features at the same time. This method can be widely used in urban power demand management, smart grid optimization, and the formulation of energy scheduling strategies.
Claims
1. A method for predicting urban electricity consumption by integrating time-frequency characteristics, characterized in that It includes the following steps: S1: Prepare and input historical multivariate time data related to electricity consumption of a certain city; the multivariate time data includes three categories: one is historical electricity consumption data, the second is historical economic data, and the third is historical meteorological data; S2: Preprocessing and alignment of multivariate time data: preprocess the multivariate time data prepared in step S1, including processing missing data and aligning data with different time granularities to the daily time granularity; the processed data will be a complete daily multivariate data sequence, ensuring that all feature data are on the same time scale, and obtaining preprocessed multivariate data; S3: The multivariate data obtained in step S2 is processed by short-time Fourier transform to extract time-frequency features at multiple time scales. Year, quarter, month, week and day are used as multi-scale time windows. The multivariate data time-frequency feature graphs at different scales are extracted by using the filter group of short-time Fourier transform through different time window parameters. The time-frequency feature information at different time scales is retained. This step obtains the time-frequency feature graph F at multiple time scales. S4: Use the feature pyramid network FPN to perform feature fusion on the multi-time scale time-frequency feature map F obtained in step S3; Through the multi-level structure of FPN, features of different time scales are extracted and effectively fused to obtain a multi-dimensional feature fusion matrix; S5: Input the multi-dimensional feature fusion matrix obtained in step S4 into the Transformer encoder, perform embedding processing on the time-frequency information, and obtain the time-frequency feature matrix. The self-attention mechanism and parallel computing capability of the Transformer encoder are used to effectively embed multi-scale time-frequency features to capture the long-term and short-term dependencies in the time series, and provide embedding features for the subsequent Transformer decoder. S6: Input the time-frequency feature matrix obtained in step S5 into the Transformer decoder, and predict the future daily electricity consumption time series of a city through the decoding process. The Transformer decoder converts the encoded time-frequency feature information into a predicted value for a future time point. Through the self-attention and cross-attention mechanisms, the decoder can effectively capture the complex dependencies in the time series and predict future electricity consumption.
2. The urban electricity consumption prediction method integrating time-frequency characteristics according to claim 1 is characterized in that In step S1, the historical electricity consumption data is the daily electricity consumption data Y of a city in the past N years. i ; The historical economic data is the GDP of the city in the past N years i , urbanization rate CI i , Electricity efficiency EF i 、Electricity price P i The historical meteorological data is the daily temperature T of the city in the past N years. i , relative humidity RH i , wind speed WS i , precipitation R i 、Solar radiation Sr i , N is required to satisfy N≥10.
3. The urban electricity consumption prediction method integrating time-frequency characteristics according to claim 1 is characterized in that Step S2 includes: S2.1: Preprocessing of multivariate time data: First, process missing data. In multivariate time data, GDP data and urbanization rate CI data only have monthly or annual statistical data, while electricity consumption data and meteorological data are daily data. In order to align all features to the daily time granularity, interpolation methods are used to fill in the data; further, for multivariate data of different types of time granularity, the following interpolation methods are used:
1. Linear interpolation: Linear interpolation is performed on monthly or annual data to convert it into daily data; 2. Spline interpolation: It is suitable for the case where data changes smoothly and provides smoother interpolation results; 3. Zero-order hold: For data that does not change frequently, the last known value is kept unchanged; S2.2: After the above preprocessing steps, based on N years of data, the final daily multivariate data matrix is: Among them, the city's daily electricity consumption data Y, the city's gross domestic product GDP, urbanization rate CI, electricity efficiency EF, electricity price P, city's daily temperature T, relative humidity RH, wind speed WS, precipitation R, and solar radiation SR are all processed into continuous and non-missing daily data.
4. The urban electricity consumption prediction method integrating time-frequency characteristics according to claim 1 is characterized in that Step S3 includes: S3.1: Construct a preliminary data set, with M×365 days as the time window, M is the year, M is required to satisfy N>>M, extract daily multivariate time series data as input, and use the first day of electricity consumption after M years as the prediction target, define X My is the daily multivariate time series data for the previous M years, and the output data y 1+My is the electricity consumption on the first day of M years later; multiple samples can be constructed by sliding windows. The input is the daily data of the previous M years, and the output is the electricity consumption on the first day of the M+1 year. The subsequent time window size remains unchanged, slides for 1 day, and outputs the electricity consumption on the second day of the M+1 year, which can be expressed as: Where D is the training set or the test set, so that the entire N years of data are divided into training sets and test sets according to a certain ratio; S3.2: Multi-scale downsampling interpolation, in order to obtain multi-scale time series data, the input data X 10y Perform downsampling interpolation processing, and define the time scale as follows: Furthermore, for the downsampled data of different time scales, linear interpolation or spline interpolation method is used for processing. For any time scale s, the interpolated data is defined as: X s (t) = Interpolate(X My ,W s ), where W s is the sampling interval corresponding to the time scale; S3.3: Short-time Fourier transform (STFT) processing. Apply STFT to the downsampled time series data to obtain time-frequency diagrams of different scales. For each time scale s, the formula is used to calculate: Among them, Xs(t,f) is the time-frequency feature at time t and frequency f. Finally, the time-frequency features of different time scales can be combined into a high-dimensional feature matrix F for the subsequent feature pyramid fusion step: F=[X y (t,f),X q (t,f),X m (t,f),X w (t,f),X d (t,f)]。 5. The urban electricity consumption prediction method integrating time-frequency characteristics according to claim 1 is characterized in that Step S4 includes: S4.1: Input the time-frequency feature map, and obtain multiple time-frequency feature maps of different time scales from step S3 F = [X y (t,f),X q (t,f),X m (t,f),X w (t,f),X d (t,f)], these feature maps correspond to the time scales of year, quarter, month, week, and day, respectively, and each feature map has different spatial and frequency resolutions; S4.2: FPN feature extraction. The structure of FPN includes multiple pyramid layers. The input at each level comes from the feature map extracted in step S3 and is processed layer by layer through convolutional layers and top-down paths. The processing process includes:
1. Extraction of underlying features: The input time-frequency feature map is passed through a convolutional layer to extract underlying features. The convolutional layer usually uses a 3x3 convolution kernel to maintain spatial resolution and extract local features.
2. Use a top-down path and upsampling: Upsample high-level features layer by layer to align with the spatial resolution of low-level features, and fuse the upsampled features with the corresponding low-level features layer by layer through lateral connections; 3. Horizontal connection: add the upsampled features from the higher layer to the convolutional features of the corresponding layer point by point to form more representative multi-scale features; 4. Output pyramid feature map: The fused feature map is used as the multi-scale feature output, that is, the output of the fused feature is realized for the subsequent Transformer encoder; the above feature extraction process is defined by the formula, assuming that the feature map X s The feature obtained by the convolution layer is C s , the feature obtained after upsampling is U s , the fusion feature after horizontal connection is F s , then the definition is as follows: Finally, the fusion feature output by FPN is F FPN =[F y ,F q ,F m ,F w ,F d ], each level of feature map integrates high-level semantic information and low-level detail information. Through the feature fusion of FPN, the network can capture the dynamic changes of time and frequency in time series at multiple scales.
6. The urban electricity consumption prediction method integrating time-frequency characteristics according to claim 1 is characterized in that Step S5 includes: S5.1: Position encoding and feature embedding. Transformer encoder is used to process sequence data. Position encoding is introduced to retain the order information in the time series. Each time-frequency feature matrix is positionally encoded to ensure that the time order of the time series is not lost during the encoding process. The position encoding is added to the feature matrix Fs(t,f) of each time scale to ensure that the sequence information is not lost. The calculation formula is: S5.2: Encoder layer processing, the Transformer encoder is composed of multiple encoder layers (Encoder Layers) stacked together, each encoder layer consists of two parts:
1. Multi-Head Self-Attention Mechanism: Capture the dependencies between time series features in the input feature matrix; 2. Feedforward Neural Network FFN: Further nonlinear transformation is performed on the features processed by the self-attention mechanism. The calculation formula of each encoder layer is:
7. The urban electricity consumption prediction method integrating time-frequency characteristics according to claim 1 is characterized in that Step S6 includes: S6.1: Input feature matrix and position encoding. The input of the decoder is the time-frequency feature matrix F output from the encoder. F ″ PN , and the previously predicted historical electricity consumption sequence as the initial input of the decoder; let the future prediction window length be T f , the decoder will predict the next T f The daily electricity consumption; keep the decoder processing sequence data sequentially, add position encoding to the input data in the same way as the encoder, and the calculation formula is: where Y t is the input feature of the decoder at time step t; the feature matrix F output by the encoder F ″ PN and historical electricity consumption series Y t-1 Input to the decoder, after position encoding the input data, the initial input Y of the decoder is finally generated PE ; S6.2: Self-attention calculation processing. In the self-attention layer of the decoder, the input sequence Y generated in step S6.1 is PE Perform self-attention calculation to generate processed sequence features Z d , calculated as follows: Z d =Self-Attention(T PE )+Y PE , The self-attention mechanism is used to process the dependencies in the decoder input sequence. It takes the input feature sequence Y PE Transform into query Q, key K, value V matrix, calculate self-attention weight and weighted sum; S6.3: Encoding-decoding attention mechanism processing, the time-frequency feature matrix F″ output by the encoder FPN As a query, the coded information is weighted extracted and combined with the historical information input by the decoder to generate a prediction of future electricity consumption; The specific steps are as follows: d and encoder output F″ FPN Input into the encoding-decoding attention layer, combined with the time-frequency feature information of the encoder, to generate a prediction sequence feature Z rich in time-frequency dependencies ed , the calculation formula is as follows: Z ed =Encoder-Decoder Attention(Z d ,F″ FPN )+Z d , The encoder-decoder attention mechanism is used to combine the decoder input with the encoder output to generate a prediction of future electricity consumption, calculated as follows: Among them, Q ed is the transformed result of the decoder input, K FPN ,V FPN is the transformation result output by the encoder; S6.4: Feedforward neural network processing, which is the same or similar to the FFN in the encoder step S5.2.
2. The feedforward neural network of the decoder layer is used to perform nonlinear transformation on the features processed by the attention mechanism; the predicted sequence feature Z generated in step S6.3 is converted into ed Input into the feedforward neural network and further processed to generate the final decoder output Y′ t , that is, the predicted value of future daily electricity consumption, the calculation formula is Y′ t =FFN(Z ed )+Z ed , The FFN calculation formula is FFN(Z ed )=max(0,Z ed W1+b1)W2+b2; S6.5: Decoder layer stacking and final output, repeat the above steps S6.1 to S6.4 in the multi-layer decoder structure, decode layer by layer, and finally output the future T f Daily electricity consumption forecast series The decoder will decode the input time-frequency features through a 6-layer stacking structure and finally output the future T f The daily electricity consumption forecast for the day.
8. A city electricity consumption prediction system integrating time-frequency characteristics, wherein the prediction system uses the city electricity consumption prediction method integrating time-frequency characteristics according to any one of claims 1 to 7, characterized in that The prediction system comprises: The data preparation and preprocessing submodule includes a data collection module, a data cleaning module, a data completion module, and a time alignment module. The data collection module is responsible for collecting multivariate historical data related to urban electricity consumption, including but not limited to historical electricity consumption data, historical economic data, and historical meteorological data. The time alignment module is responsible for aligning data of different time granularities to the daily time granularity and completing the data through interpolation methods. The time-frequency feature extraction submodule includes a downsampling interpolation module and a short-time Fourier transform module; the downsampling interpolation module is responsible for performing multi-scale downsampling interpolation processing on the input data to obtain data of different time scales; the short-time Fourier transform module is responsible for performing short-time Fourier transform (STFT) on the downsampled data to extract time-frequency features of different time scales; The feature pyramid network (FPN) submodule is responsible for using FPN to fuse the time-frequency feature maps of different time scales, extracting features of different time scales and effectively fusing these features; The Transformer encoder submodule includes a position encoding module, a multi-head self-attention module, and a feedforward neural network module. The position encoding module is responsible for adding position encoding to each time-frequency feature matrix to retain the order information in the time series. The multi-head self-attention module is responsible for calculating the attention weights between the time series features in the input feature matrix and performing weighted summation of the features using these weights. The feedforward neural network module is responsible for performing nonlinear transformation on the features processed by the attention mechanism. Transformer decoder submodule: including self-attention calculation module, encoding-decoding attention module, feedforward neural network module, and decoder layer stacking module; the self-attention calculation module is responsible for processing the dependencies in the decoder input sequence, calculating the self-attention weights and weighted summing them; the encoding-decoding attention module is responsible for combining the time-frequency feature matrix output by the encoder with the historical information input by the decoder to generate a prediction of future power consumption; the feedforward neural network module is responsible for performing nonlinear transformations on the features processed by the attention mechanism; the decoder layer stacking module is responsible for repeatedly executing the decoding steps and finally outputting a sequence of power consumption predictions for a period of time in the future.
9. A device for predicting urban electricity consumption by integrating time-frequency characteristics, wherein the device uses the method for predicting urban electricity consumption by integrating time-frequency characteristics as claimed in any one of claims 1 to 7, characterized in that The prediction device comprises: A processor, a user interface, a network interface, an operating system, a network communication module, a user interface module, and a memory, wherein the memory stores a computer program, that is, the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the method for predicting urban electricity consumption by integrating time-frequency characteristics as described in any one of claims 1 to 11 is implemented.
10. A computer-readable storage medium, characterized in that The storage medium stores a city electricity consumption prediction program integrating time-frequency features. When the program runs on a computer, the city electricity consumption prediction method integrating time-frequency features as described in any one of claims 1 to 7 is executed to achieve accurate prediction of city electricity consumption.
Citation Information
Cited By
Power grid optimization scheduling method and system based on intelligent optimization algorithm
CN119476649A
Cross-dimension multi-scale fusion load prediction method based on multi-user load space-time correlation
CN120832644A
A cross-dimension multi-scale fusion load prediction method based on multi-user load space-time correlation
CN120832644B
