Method, system and device for constructing electricity consumption prediction model based on federated learning and medium

By constructing a bilateral graph and extracting features using a graph attention network and a graph autoencoder, and by optimizing the global prediction model using network weight similarity, the problem of not taking into account the temporal patterns and user associations in electricity consumption prediction is solved, thus improving prediction accuracy and adaptability.

CN121886335APending Publication Date: 2026-04-17HAINAN POWER GRID CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-28
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing electricity consumption prediction methods fail to take into account both the temporal patterns of electricity consumption data and the characteristic correlations between users. The aggregation of local prediction models under federated learning lacks specificity, resulting in poor prediction performance under privacy protection.

Method used

By constructing a two-sided graph containing temporal and numerical edges, multidimensional features are extracted using graph attention networks and graph autoencoders. These features are then weighted and aggregated based on network weight similarity to optimize the global prediction model.

Benefits of technology

It enables the full exploitation of complex dynamic correlations in electricity consumption data while protecting privacy, thereby improving the accuracy and adaptability of prediction models and making them suitable for the data-dispersed and privacy-critical environment of smart grids.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121886335A_ABST
    Figure CN121886335A_ABST
Patent Text Reader

Abstract

The invention discloses an electricity consumption prediction model construction method and system based on federated learning, equipment and a medium, and the method comprises the steps: carrying out the time sequence decomposition processing of a historical electricity consumption sequence, and constructing a bilateral graph containing a time sequence edge and a numerical value edge based on a multi-dimensional feature vector; multi-time-scale feature extraction is carried out on the time sequence edge through a graph attention network, and Gaussian distribution modeling is carried out on node features corresponding to the numerical value edge through a graph auto-encoder; fusing the time sequence attention features and the numerical value coding features; initializing a global prediction model at a server side, and calculating the network weight similarity between each local prediction model and the current global prediction model; and performing weighted aggregation on each local prediction model based on the network weight similarity to update the global prediction model. According to the method, the problems that in an existing prediction method, feature extraction does not consider association of a time sequence and user features, and local prediction model aggregation under federal learning lacks pertinence, so that prediction performance under privacy protection is poor are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of model building technology, and in particular to a method, system, device and medium for building an electricity consumption prediction model based on federated learning. Background Technology

[0002] With the large-scale development of smart grids, electricity consumption data is becoming increasingly distributed and multi-dimensional. Customers' electricity consumption information is stored in a decentralized manner, and data privacy is being regulated more and more strictly. Federated learning, which can achieve distributed collaborative modeling and avoid sharing of raw data, has become an important direction for electricity consumption forecasting.

[0003] However, most existing electricity consumption prediction methods fail to take into account the temporal patterns of electricity consumption data and the feature relationships between users, resulting in relatively singular feature extraction dimensions that are difficult to fully capture the inherent complex dynamic relationships. At the same time, the aggregation of local prediction models under the federated learning framework often lacks specificity and fails to combine weight similarity for weighting. This not only affects the update efficiency of the global model but also makes it difficult to adapt to the differences in data distribution among different clients. These limitations at the feature extraction and model aggregation levels make it difficult for existing electricity consumption prediction methods to achieve ideal prediction model performance while protecting data privacy. Summary of the Invention

[0004] In view of the aforementioned existing problems, the present invention is proposed.

[0005] Therefore, this invention provides a method, system, device, and medium for constructing an electricity consumption prediction model based on federated learning. This addresses the problems in existing electricity consumption prediction methods, such as feature extraction failing to consider the correlation between temporal sequence and user features, difficulty in capturing complex relationships, and the lack of specificity in local model aggregation under federated learning, which affects global efficiency and is difficult to adapt to data differences, resulting in poor prediction performance under privacy protection.

[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution: In a first aspect, the present invention provides a method for constructing an electricity consumption prediction model based on federated learning, comprising: acquiring historical electricity consumption sequences of each client in a distributed system; performing time-series decomposition processing on the historical electricity consumption sequences to obtain multi-dimensional feature vectors of each client; and constructing a bilateral graph containing time-series edges and numerical edges based on the multi-dimensional feature vectors; extracting features from the time-series edges at multiple time scales using a graph attention network to obtain time-series attention features; performing Gaussian distribution modeling on the node features corresponding to the numerical edges using a graph autoencoder to obtain numerical encoding features; fusing the time-series attention features and the numerical encoding features to obtain fused features; initializing a global prediction model on the server side; training local prediction models of each client iteratively based on the fused features; and calculating the network weight similarity between each local prediction model and the current global prediction model; and performing weighted aggregation on each local prediction model based on the network weight similarity to update the global prediction model until a preset condition is met to obtain a global prediction model for electricity consumption prediction.

[0007] As a preferred embodiment of the method for constructing the electricity consumption prediction model based on federated learning as described in this invention, the step of constructing temporal edges based on the multidimensional feature vector includes: using each time point corresponding to the multidimensional feature vector as a graph node of a bilateral graph; setting a time window, for the graph node corresponding to the current time point, using the graph nodes corresponding to each historical time point within the time window as neighbor nodes, establishing temporal edges between the current graph node and each neighbor node, and determining the connection weight of each temporal edge according to the time distance between graph nodes; and constructing an adjacency matrix corresponding to each temporal edge according to each temporal edge and its corresponding connection weight.

[0008] The beneficial effects of this preferred technical solution are as follows: using each time point corresponding to the multidimensional feature vector as a graph node of the bilateral graph, the time dimension information is transformed into a graph structure element that can be intuitively associated. By setting a time window, the graph node at the current time point and the graph nodes at historical time points within the window are established as neighbor nodes, realizing the directional association between current and historical data. A temporal edge is established between the two and the connection weight is determined according to the time distance, so that the influence of different historical time points on the current time point can be quantified and distinguished through the weight. By combining the temporal edge and the corresponding connection weight, an adjacency matrix is ​​constructed, which transforms the temporal association implicit in the multidimensional feature vector into a matrix form that the model can recognize, so that the temporal pattern in the multidimensional feature vector is fully explored.

[0009] As a preferred embodiment of the method for constructing the electricity consumption prediction model based on federated learning as described in this invention, the step of constructing numerical edges based on the multidimensional feature vectors includes: obtaining the multidimensional feature vectors corresponding to each graph node in the bilateral graph, calculating the cosine similarity between each pair of multidimensional feature vectors of each graph node to obtain a similarity set, and calculating the average value of all cosine similarities in the similarity set, using the average value as a similarity threshold; traversing the similarity set, for graph node pairs with a cosine similarity greater than the similarity threshold, establishing numerical edges between the graph node pairs, and constructing the adjacency matrix corresponding to each numerical edge.

[0010] The beneficial effects of this preferred technical solution are as follows: It obtains the multidimensional feature vectors corresponding to each graph node in the bilateral graph, calculates the cosine similarity between each pair of multidimensional feature vectors of each graph node, presents the degree of numerical association between nodes in a quantitative manner, uses the average value of the similarity set as the similarity threshold, ensuring that the similarity threshold setting fits the actual distribution characteristics of the current data, traverses the similarity set and establishes numerical edges for graph node pairs with cosine similarity greater than the similarity threshold, thereby filtering effective numerical associations, and constructs a corresponding adjacency matrix by combining each numerical edge, transforming the effective numerical associations between graph nodes into identifiable structured information, allowing the numerical associations implicit in the multidimensional feature vectors to be fully mined and presented, ensuring that the numerical feature associations between nodes can be directly utilized.

[0011] As a preferred embodiment of the method for constructing the electricity consumption prediction model based on federated learning described in this invention, the step of extracting features from the temporal edges using a graph attention network at multiple time scales to obtain temporal attention features includes: obtaining the adjacency matrix corresponding to the temporal edge; obtaining multiple neighborhood adjacency matrices representing different order neighborhood relationships based on the adjacency matrix; calculating the similarity features between each pair of graph nodes for each neighborhood adjacency matrix, and normalizing the similarity features to obtain the attention coefficients under that order neighborhood; weighting and aggregating the feature vectors of adjacent graph nodes according to the attention coefficients under each order neighborhood to obtain the attention features under each order neighborhood, and fusing the attention features under each order neighborhood to obtain the temporal attention features.

[0012] The beneficial effects of this preferred technical solution are as follows: multiple neighborhood adjacency matrices representing different levels of neighborhood relationships are obtained, allowing the multi-level neighborhood associations of graph nodes to be fully presented. For each neighborhood adjacency matrix, the similarity features between each pair of graph nodes are calculated and normalized. The resulting neighborhood attention coefficients at each level can accurately quantify the association strength between nodes. Based on these attention coefficients, the feature vectors of adjacent graph nodes are weighted and aggregated, so that the key features under each level of neighborhood are effectively extracted. The attention features of each level of neighborhood are fused to form temporal attention features, so that temporal association information at different levels is fully integrated, and the multi-timescale features contained in the temporal edges are fully mined and utilized.

[0013] As a preferred embodiment of the method for constructing the electricity consumption prediction model based on federated learning described in this invention, the step of obtaining numerical encoded features by modeling the node features corresponding to the numerical edges using a Gaussian distribution through a graph autoencoder includes: calculating the first attention weight between each pair of graph nodes based on the adjacency matrix corresponding to the numerical edges and the multidimensional feature vectors corresponding to each graph node, wherein the formula for calculating the first attention weight is expressed as: ; In the formula, Let i be the first attention weight for graph node i to graph node j. Let P be the adjacency matrix corresponding to the numerical edges, and let P be the learnable projection matrix. and Let be the multidimensional feature vectors of graph node i and graph node j, respectively, and T be the matrix transpose operation. Let be the dimension of the multidimensional feature vector, and softmax be the normalized exponential function. Based on the first attention weight and combined with the learnable mask matrix, the second attention weight between each pair of graph nodes is calculated. The formula for calculating the second attention weight is as follows: ; In the formula, Let R be the second attention weight of graph node i for graph node j, and R be the learnable mask matrix. The first attention weight and the second attention weight are weighted and fused to obtain the fused attention weight. The multidimensional feature vectors of each graph node are weighted and aggregated according to the fused attention weight to obtain the aggregated feature vector. The aggregated feature vector is transformed through the mean parameter matrix and the covariance parameter matrix to obtain the mean vector and covariance vector of Gaussian distribution, respectively. The mean vector and the covariance vector are used as the numerical encoding features.

[0014] The beneficial effects of this preferred technical solution are as follows: First attention weights are calculated based on the adjacency matrix corresponding to numerical edges and the multidimensional feature vectors of each graph node. Combined with a learnable projection matrix and normalization operations, the association between graph nodes i and j is quantified. Second attention weights are calculated based on this first attention weight and combined with a learnable mask matrix to supplement additional association information between graph nodes. The first and second attention weights are weighted and fused to obtain a fused attention weight, integrating the association strengths of graph nodes in different dimensions. Then, based on this fused attention weight, the multidimensional feature vectors of each graph node are weighted and aggregated to obtain an aggregated feature vector, integrating the effective information in the graph node features. Finally, the aggregated feature vector is transformed using a mean parameter matrix and a covariance parameter matrix to obtain a Gaussian-distributed mean vector and covariance vector as numerical encoding features, presenting the graph node features in a Gaussian distribution form, thus completing the distribution modeling of the graph node features corresponding to numerical edges.

[0015] As a preferred embodiment of the method for constructing a federated learning-based electricity consumption prediction model according to the present invention, the step of iteratively training the local prediction model of each client based on the fusion features includes: inputting the fusion features into the fully connected output layer of the local prediction model, outputting the electricity consumption prediction result, and calculating the prediction loss between the electricity consumption prediction result and the actual electricity consumption; obtaining the network weight parameters of the current global prediction model, calculating the parameter difference between the network weight parameters of the local prediction model and the global prediction model, and calculating the regularization loss based on the parameter difference; and updating the network weight parameters of the local prediction model based on the weighted sum of the prediction loss and the regularization loss.

[0016] The beneficial effects of this preferred technical solution are as follows: The fused features are input into the fully connected output layer of the local prediction model to obtain the electricity consumption prediction result. By comparing the prediction loss with the actual electricity consumption, the training of the local prediction model can be anchored to the actual prediction deviation. The network weight parameters of the current global prediction model are obtained, and the parameter difference between the global and local models is calculated. The regularization loss obtained based on this parameter difference can quantify the degree of deviation between the local and global prediction models. The prediction loss and the regularization loss are weighted and summed, and the network weight parameters of the local prediction model are updated accordingly. This allows the update of the local prediction model to simultaneously consider its own prediction performance and global synergy, avoiding bias caused by the local prediction model relying solely on local data for training. This makes the parameter adjustment of the local prediction model more aligned with the collaborative needs of federated learning.

[0017] As a preferred embodiment of the method for constructing the electricity consumption prediction model based on federated learning according to the present invention, the step of weighted aggregation of each local prediction model based on the network weight similarity to update the global prediction model includes: calculating the cosine similarity between the network weight parameters of the prediction layer of each local prediction model and the prediction layer of the current global prediction model, and normalizing the cosine similarity to obtain the aggregated weight of each local prediction model; and weighted aggregation of the network weight parameters of each local prediction model according to the aggregated weight to complete the update of the global prediction model.

[0018] The beneficial effects of this preferred technical solution are as follows: The cosine similarity of the network weight parameters of each local prediction model and the current global prediction model is calculated to present the degree of parameter correlation between the two in a quantitative manner. The cosine similarity is normalized to obtain the aggregated weights, so that the aggregated weights of each local prediction model can match their fit with the global prediction model, avoiding information bias caused by indiscriminate aggregation. The network weight parameters of each local prediction model are weighted and aggregated according to the aggregated weights, allowing the local prediction models with higher fit with the global prediction model to play a more important role in the aggregation. This ensures that the update of the global prediction model can fully absorb effective local parameter information, ensuring that the updated global prediction model integrates the training results of each client while maintaining the consistency and rationality of its own parameters.

[0019] Secondly, this invention provides a system for constructing an electricity consumption prediction model based on federated learning, comprising: Data preprocessing and graph construction module: used to obtain the historical electricity consumption sequence of each client, perform time-series decomposition processing on the electricity consumption sequence to obtain multi-dimensional feature vectors, and construct a two-sided graph containing time-series edges and numerical edges based on the multi-dimensional feature vectors; Multi-scale feature extraction module: used to extract temporal attention features from the temporal edges using a graph attention network, and to obtain numerical coding features by modeling the node features corresponding to the numerical edges using a Gaussian distribution through a graph autoencoder. Feature fusion module: used to fuse the temporal attention features and the numerical coding features to obtain fused features; Local model training module: used to train the local prediction model of each client in an iterative manner based on fused features, and to calculate the network weight similarity between each local prediction model and the current global prediction model; Global model aggregation module: used to perform weighted aggregation of each local prediction model based on the network weight similarity to update the global prediction model until a preset condition is met.

[0020] Thirdly, the present invention provides an electronic device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the method for constructing a power consumption prediction model based on federated learning.

[0021] Fourthly, the present invention provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the method for constructing the electricity consumption prediction model based on federated learning.

[0022] Compared with existing technologies, the beneficial effects of this invention are as follows: by optimizing the model construction logic, a deep integration of feature mining, federated collaboration and privacy protection is achieved, thereby improving the practicality and performance of electricity consumption prediction. In the electricity consumption data feature processing stage, it breaks through the limitations of traditional methods that only focus on a single dimension. It can simultaneously capture the temporal patterns of electricity consumption data and the feature correlations between different users, and more comprehensively explore the complex dynamic relationships inherent in the data, solving the prediction accuracy bottleneck caused by insufficient feature extraction. In the application of the federated learning framework, it improves the problem of the lack of targeting in the aggregation of traditional local prediction models. By combining the aggregation strategy with weight similarity, it not only accelerates the update efficiency of the global prediction model, but also better adapts to the differences in data distribution among different clients, avoiding model performance loss caused by data heterogeneity, and making federated collaborative modeling more in line with the needs of actual distributed scenarios. Most importantly, the optimization process of model construction is always based on the technical characteristics of federated learning, ensuring that the original electricity consumption data does not leave the client and is not shared, fully complying with data privacy regulatory requirements. Ultimately, under the premise of effectively protecting privacy and security, it improves the overall performance of the electricity consumption prediction model, which can better adapt to the actual environment of data dispersion and strict privacy in the large-scale development of smart grids, and provide more accurate decision-making basis for scenarios such as electricity management and grid dispatch. Attached Figure Description

[0023] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 This is a schematic diagram illustrating the overall process of constructing a federated learning-based electricity consumption prediction model according to an embodiment of the present invention. Detailed Implementation

[0025] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of the present invention.

[0026] Example 1, referring to Figure 1 As an embodiment of the present invention, a method for constructing an electricity consumption prediction model based on federated learning is provided, including steps S100 to S500: S100. Obtain the historical power consumption sequence of each client in the distributed system, perform time-series decomposition on the historical power consumption sequence to obtain the multi-dimensional feature vector of each client, and construct a two-sided graph containing time-series edges and numerical edges based on the multi-dimensional feature vector.

[0027] S200. Multi-timescale feature extraction is performed on temporal edges using a graph attention network to obtain temporal attention features. Gaussian distribution modeling is performed on the node features corresponding to numerical edges using a graph autoencoder to obtain numerical coding features.

[0028] S300, by fusing temporal attention features and numerical coding features, a fused feature is obtained.

[0029] S400. Initialize the global prediction model on the server side, train the local prediction models of each client in an iterative manner based on the fusion features, and calculate the network weight similarity between each local prediction model and the current global prediction model.

[0030] S500: Based on the network weight similarity, each local prediction model is weighted and aggregated to update the global prediction model until the preset conditions are met, thus obtaining a global prediction model for electricity consumption prediction.

[0031] It should be noted that in a distributed system, the historical electricity consumption data of each client is scattered across different terminals, and the electricity consumption data simultaneously contains time-series variation patterns and numerical correlation characteristics between users. However, the requirement for data privacy protection makes it impossible to directly and centrally share the original electricity consumption data of each client. Traditional electricity consumption prediction methods either fail to fully explore the multi-dimensional correlations of the data or fail to meet privacy requirements due to centralized training. At the same time, the data distribution of different clients varies, and a single local prediction model is difficult to adapt to the actual electricity consumption characteristics of each terminal, affecting the applicability of the prediction.

[0032] Therefore, to address the aforementioned issues of data dispersion, privacy restrictions, and insufficient feature mining, steps S100-S500 are used to first decompose the historical electricity consumption sequences of each client into multi-dimensional feature vectors and construct a bilateral graph containing both temporal and numerical edges, thus achieving a structured organization of data features. Then, graph attention networks and graph autoencoders are used to extract and fuse features from different dimensions, integrating complex correlation information in the data. Simultaneously, based on a federated learning framework, local prediction models are collaboratively trained on the server side, and the global model is updated by combining weight similarity aggregation. This ensures that data privacy is not leaked and adapts to the differences in data distribution among various clients.

[0033] Example 2, refer to Figure 1 As an embodiment of the present invention, based on the above embodiment, a method for constructing an electricity consumption prediction model based on federated learning is provided.

[0034] In this embodiment of the application, step S100 obtains the historical power consumption sequence of each client in the distributed system, performs time-series decomposition processing on the historical power consumption sequence to obtain the multi-dimensional feature vector of each client, and constructs a two-sided graph containing time-series edges and numerical edges based on the multi-dimensional feature vector. In this embodiment, an electricity consumption dataset for a certain region is used as an example. This dataset contains electricity consumption records for multiple regions, with each region corresponding to a client. Taking one client as an example, the historical electricity consumption sequence X={x1, x2, ..., x...} for that client is obtained. n Assume the historical electricity consumption sequence contains electricity consumption records for 5 consecutive time points, namely X={34500, 35200, 36800, 35100, 34900}, with units of kWh; then, the historical electricity consumption sequence is decomposed using the STL decomposition method and the EEMD decomposition method respectively. The STL decomposition yields the trend component T, the seasonal component S, and the residual component R, while the EEMD decomposition yields the intrinsic mode function component IMF; finally, the original electricity consumption value is concatenated with each component to obtain the multidimensional feature vector of each client. Taking time point t=3 as an example, the original electricity consumption value at this time point is x3=36800, the corresponding trend component T3=35200, the seasonal component S3=1200, the residual component R3=400, and the intrinsic mode function component IMF3=200. After concatenation, the multidimensional feature vector f3=[36800, 35200, 1200, 400, 200] is obtained.

[0035] The steps for constructing temporal edges based on multidimensional feature vectors include A1 to A3: A1. Use the time points corresponding to the multidimensional feature vectors as the graph nodes of the bilateral graph; In this embodiment, taking the five time points in step S100 as an example, five graph nodes v1, v2, v3, v4, and v5 are constructed, corresponding to time points t=1, t=2, t=3, t=4, and t=5, respectively. Each graph node carries a corresponding multi-dimensional feature vector as its node feature. For example, the feature of graph node v3 is f3=[36800, 35200, 1200, 400, 200], and the feature of graph node v1 is f1=[34500, 35000, -200, -300, 100]. In this way, time-series data is transformed into graph structure data.

[0036] A2. Set a time window. For the graph node corresponding to the current time point, take the graph nodes corresponding to each historical time point within the time window as neighbor nodes. Establish time-series edges between the current graph node and each neighbor node, and determine the connection weight of each time-series edge according to the time distance between graph nodes. In this embodiment, a time window K=3 is set. Taking graph node v3 as an example, graph nodes v2 and v1 within the time window are considered as neighbors of graph node v3. Temporal edges are established between graph node v3 and graph node v2, and between graph node v3 and graph node v1, respectively. It should be noted that nodes closer in time to the current time t in the time series will be assigned higher connection weights. These connection weights decay over time. The temporal distance k between graph node v3 and graph node v2 is 1, according to the connection weight calculation formula. The connection weight is 1 - 1 / 3 ≈ 0.67; the time distance between graph node v3 and graph node v1 is 2, and the connection weight is 1 - 2 / 3 ≈ 0.33. Similarly, for graph node v4, the connection weight between graph node v4 and graph node v3 is 0.67, and the connection weight between graph node v4 and graph node v2 is 0.33; for graph node v5, the connection weight between graph node v5 and graph node v4 is 0.67, and the connection weight between graph node v5 and graph node v3 is 0.33.

[0037] A3. Construct the adjacency matrix corresponding to each temporal edge based on each temporal edge and its corresponding connection weight; In this embodiment, based on the 5 graph nodes in step A1 and the temporal edges and corresponding connection weights determined in step A2, a 5×5 adjacency matrix A is constructed. temp ; where, the adjacency matrix A tempThe element in the 3rd row and 2nd column is 0.67, and the element in the 3rd row and 1st column is 0.33, indicating that graph node v3 has temporal edges with graph nodes v2 and v1 respectively; the element in the 4th row and 3rd column is 0.67, and the element in the 4th row and 2nd column is 0.33, indicating that graph node v4 has temporal edges with graph nodes v3 and v2 respectively; the element in the 5th row and 4th column is 0.67, and the element in the 5th row and 3rd column is 0.33, indicating that graph node v5 has temporal edges with graph nodes v4 and v3 respectively; Adjacency matrix A temp All other elements in the graph are 0, indicating that there are no temporal edges between the corresponding graph nodes.

[0038] In an optional implementation, step S100, which constructs temporal edges based on multidimensional feature vectors, can also employ a similarity-based dynamic connection strategy. Specifically, instead of relying solely on temporal distance to determine connections, the feature similarity between graph nodes at the current time point and those at historical time points is calculated. When the similarity exceeds a preset threshold, a temporal edge connection is established. The connection weight is determined by both temporal distance and feature similarity, calculated using the following formula: Where α is the balance coefficient, f t and f s These represent the multidimensional feature vectors corresponding to time points t and s, respectively.

[0039] The steps for constructing numerical edges based on multidimensional feature vectors include B1~B2: B1. Obtain the multidimensional feature vectors corresponding to each graph node in the bilateral graph, calculate the cosine similarity between each pair of multidimensional feature vectors of each graph node, obtain the similarity set, and calculate the average value of all cosine similarities in the similarity set, and use the average value as the similarity threshold. In this embodiment, the cosine similarity is obtained by calculating the ratio of the inner product of two multidimensional feature vectors to the product of their magnitudes. Taking graph nodes v1 and v3 as examples, the multidimensional feature vector of graph node v1 is f1 = [34500, 35000, -200, -300, 100], and the multidimensional feature vector of graph node v3 is f3 = [36800, 35200, 1200, 400, 200]. The inner product of multidimensional feature vectors f1 and f3 is calculated as 34500 × 36800 + 35000 × 352. 00 + (-200) × 1200 + (-300) × 400 + 100 × 200 = 2485740000. Since the magnitude of the multidimensional feature vector f1 is 49167.6 and the magnitude of the multidimensional feature vector f3 is 50941.2, the cosine similarity between graph node v1 and graph node v3 is approximately 2485740000 / (49167.6 × 50941.2) ≈ 0.78. The cosine similarity of other graph node pairs is calculated in the same way. A similarity set is formed from the cosine similarities of all graph node pairs, and the average value of all cosine similarities in the similarity set is calculated to be 0.887. This average value is used as the similarity threshold τ.

[0040] B2. Traverse the similarity set. For graph node pairs with a cosine similarity greater than the similarity threshold, establish numerical edges between the graph node pairs and construct the adjacency matrix corresponding to each numerical edge. In this embodiment, the cosine similarity of each graph node pair is compared with a similarity threshold τ = 0.887. Numerical edges are established for graph node pairs with a cosine similarity greater than the threshold. The comparison reveals that numerical edges are established between graph node v1 and v2, v1 and v4, v1 and v5, v2 and v4, v2 and v5, and v4 and v5, respectively. Then, a 5×5 adjacency matrix A is constructed based on these numerical edges. num A graph node pair with numerical edges exists in the adjacency matrix A. num The element at the corresponding position is 1, and the elements at the other positions are 0.

[0041] In an optional implementation, the construction of numerical edges based on multidimensional feature vectors in step S100 can also employ a hierarchical threshold filtering mechanism. Specifically, graph nodes are divided into two categories—high-fluctuation nodes and low-fluctuation nodes—based on the fluctuation range of electricity consumption, and a higher similarity threshold is applied to high-fluctuation nodes. To identify strongly correlated peak change patterns, a lower similarity threshold is used for nodes with low fluctuations. To retain more information about the stable periods, when constructing numerical edges, the standard deviation of the multidimensional feature vectors corresponding to each graph node is first calculated as a fluctuation index. When the standard deviation is greater than a preset fluctuation threshold, the node is classified as a high-fluctuation node; otherwise, it is classified as a low-fluctuation node. Then, the corresponding similarity threshold is selected based on the node category to determine the numerical edge connection.

[0042] In this embodiment of the application, step S200 extracts features of temporal edges at multiple time scales through a graph attention network to obtain temporal attention features, and models the node features corresponding to numerical edges using a Gaussian distribution through a graph autoencoder to obtain numerical coding features. The steps for extracting temporal attention features from temporal edges using a graph attention network at multiple time scales include C1 to C3: C1. Obtain the adjacency matrix corresponding to the temporal edge, and obtain multiple neighborhood adjacency matrices representing different order neighborhood relationships based on the adjacency matrix; In this embodiment, the adjacency matrix A corresponding to the temporal edge constructed in step A3 is obtained. temp Let the neighborhood order H=3, and the adjacency matrix A temp Obtain multiple neighborhood adjacency matrices representing neighborhood relationships of different orders, including first-order neighborhood adjacency matrices representing direct neighborhood relationships between graph nodes. A 2-order neighborhood adjacency matrix representing the 2-hop neighborhood relationships between nodes in a graph. And a 3rd-order neighborhood adjacency matrix representing the 3-hop neighborhood relationships between nodes in the graph. .

[0043] C2. For each neighborhood adjacency matrix, calculate the similarity features between each pair of graph nodes, and normalize the similarity features to obtain the attention coefficients for that neighborhood. In this embodiment, a first-order neighborhood adjacency matrix is ​​used. For example, let's consider the first-order neighborhood adjacency matrix. Multiplying the learnable weight matrix W1 and the multidimensional feature vectors of each graph node respectively, we obtain the transformation features of each graph node in its first-order neighborhood. Taking graph node v3 as an example, the first-order neighborhood adjacency matrix... The learnable weight matrix W1 and the multidimensional feature vector f3=[36800, 35200, 1200, 400, 200] of graph node v3 are multiplied to obtain the transformation feature of graph node v3 in the first-order neighborhood. Similarly, the transformation feature of graph node v2 in the first-order neighborhood is obtained. The transformation features of graph nodes v3 and v2 are input into the fully connected layer to calculate the similarity feature between graph nodes v3 and v2 in the first-order neighborhood. The similarity feature between each pair of graph nodes in the first-order neighborhood is calculated in the same way, which is 0.85. The similarity feature is normalized by the softmax function to obtain the attention coefficient in the first-order neighborhood, where the attention coefficient of graph node v3 to graph node v2 is... Attention coefficient of graph node v3 to graph node v1 In this way, the attention coefficients in the second-order neighborhood and the third-order neighborhood are calculated respectively.

[0044] C3. Based on the attention coefficients in each neighborhood, the feature vectors of adjacent graph nodes are weighted and aggregated to obtain the attention features in each neighborhood. The attention features in each neighborhood are then fused to obtain the temporal attention features. In this embodiment, taking graph node v3 as an example, the attention coefficients in the first-order neighborhood obtained in step C2 are used... and The multidimensional feature vectors of the neighboring nodes of graph node v3 are weighted and aggregated. Specifically, the multidimensional feature vector of graph node v2 is weighted and aggregated with the attention coefficient. The attention features of graph node v3 in the first-order neighborhood are obtained by multiplying the learnable weight matrix Q1 and summing the two. Similarly, the attention features of graph node v3 in the second-order neighborhood and the third-order neighborhood are obtained. The attention features in each order neighborhood are summed and fused to obtain the temporal attention feature feature3=[0.72, 0.65, 0.48, 0.31, 0.25] of graph node v3. And so on, the temporal attention features of other graph nodes are calculated.

[0045] In an optional implementation, step S200 extracts features from temporal edges at multiple time scales using a graph attention network. The resulting temporal attention features can also be achieved using a multi-head attention mechanism combined with temporal convolution. Specifically, multiple attention heads are set up to focus on features at different time scales. Each attention head is configured with different receptive field parameters. The first attention head focuses on short-term temporal dependencies, the second on medium-term dependencies, and the third on long-term dependencies. For each attention head, attention coefficients are calculated between each pair of graph nodes based on the adjacency matrix corresponding to the temporal edge and the learnable weight matrix at the corresponding scale. The feature vectors of adjacent graph nodes are then weighted and aggregated according to these attention coefficients. Finally, the features output by each attention head are concatenated or weighted summed to obtain temporal attention features that integrate multi-time scale information.

[0046] The steps for obtaining numerical encoded features by modeling the node features corresponding to numerical edges using a Gaussian distribution through a graph autoencoder include D1~D4: D1. Calculate the first attention weight between each pair of graph nodes based on the adjacency matrix corresponding to the numerical edges and the multidimensional feature vectors corresponding to each graph node. The formula for calculating the first attention weight is as follows: ; In the formula, Let i be the first attention weight for graph node i to graph node j. Let P be the adjacency matrix corresponding to the numerical edges, and let P be the learnable projection matrix. and Let be the multidimensional feature vectors of graph node i and graph node j, respectively, and T be the matrix transpose operation. Let be the dimension of the multidimensional feature vector, and softmax be the normalization exponential function. In this embodiment, the adjacency matrix A corresponding to the numerical edges constructed in step B2 is first obtained. num And the multidimensional feature vectors of each graph node. Taking graph node v1 and graph node v3 as examples, the multidimensional feature vector of graph node v1 is f1=[34500, 35000, -200, -300, 100], and the multidimensional feature vector of graph node v3 is f3=[36800, 35200, 1200, 400, 200]. The dimension d of the multidimensional feature vector is... k =5; Next, the adjacency matrix A num The learnable projection matrix P is multiplied by the multidimensional feature vector f1 to obtain the projected features of graph node v1; the projected features of graph node v3 are obtained in the same way. Then, the projected features of graph node v1 and the transpose of the projected features of graph node v3 are multiplied and divided by . The scale is then applied, and finally normalized using the softmax function to obtain the first attention weights of graph node v1 to graph node v3. ; accordingly, calculate the first attention weight between each pair of nodes in the graph.

[0047] D2. Based on the first attention weights and combined with the learnable mask matrix, calculate the second attention weights between each pair of nodes in the graph. The formula for calculating the second attention weights is as follows: ; In the formula, Let be the second attention weight of graph node i to graph node j, and R be the learnable mask matrix; In this embodiment, taking graph node v1 and graph node v3 as examples, the learnable mask matrix R and the adjacency matrix A are used. num After multiplication, it is multiplied again with the multidimensional feature vector f1 of graph node v1 to obtain the mask feature of graph node v1; similarly, the mask feature of graph node v3 is obtained. Then, the mask feature of graph node v1 and the transpose of the mask feature of graph node v3 are multiplied element-wise, and normalized by the softmax function to obtain 0.18. This is then compared with the first attention weight of graph node v1 to graph node v3 obtained in step D1. Adding them together gives the second attention weight of graph node v1 to graph node v3. ; accordingly, calculate the second attention weights between each pair of nodes in the graph.

[0048] D3. The first attention weight and the second attention weight are weighted and fused to obtain the fused attention weight. The multi-dimensional feature vectors of each graph node are weighted and aggregated according to the fused attention weight to obtain the aggregated feature vector. In this embodiment, the first attention weight obtained in step D1 and the second attention weight obtained in step D2 are weighted and fused using a gating mechanism to obtain the fused attention weight. Taking graph node v3 as an example, based on the fused attention weight of graph node v3 for each graph node, the multidimensional feature vectors of each graph node are weighted and summed to obtain the aggregated feature vector Z3=[0.58, 0.62, 0.41, 0.27, 0.19] of graph node v3. The aggregated feature vectors of other graph nodes are calculated in the same way.

[0049] D4. Transform the aggregated feature vector through the mean parameter matrix and covariance parameter matrix to obtain the mean vector and covariance vector of the Gaussian distribution, and use the mean vector and covariance vector as numerical coding features. In this embodiment, taking graph node v3 as an example, the aggregated feature vector Z3=[0.58, 0.62, 0.41, 0.27, 0.19] of graph node v3 obtained in step D3 is multiplied by the mean parameter matrix W1 and the covariance parameter matrix W2 respectively to obtain the mean vector μ3=[0.45, 0.52, 0.38] and covariance vector σ3=[0.12, 0.08, 0.15] of the Gaussian distribution corresponding to graph node v3; where the mean... The vector represents the expected value of the numerical characteristics of electricity consumption, and the covariance vector represents the degree of fluctuation of the numerical characteristics of electricity consumption. By introducing controlled perturbation through the covariance vector, the overfitting of the peak fluctuation data of electricity consumption can be alleviated. Finally, the mean vector μ3 and the covariance vector σ3 are concatenated to obtain the numerical coding features of graph node v3 as [0.45, 0.52, 0.38, 0.12, 0.08, 0.15]. In this way, the numerical coding features of other graph nodes are calculated.

[0050] In this embodiment of the application, step S300 fuses temporal attention features and numerical coding features to obtain fused features; In this embodiment, taking graph node v3 as an example, the temporal attention feature feature3=[0.72, 0.65, 0.48, 0.31, 0.25] of graph node v3 obtained in step C3 and the numerical encoding feature [0.45, 0.52, 0.38, 0.12, 0.08, 0.15] of graph node v3 obtained in step D4 are obtained. The temporal attention feature and the numerical encoding feature are concatenated to obtain the fusion feature Z3=[0.72, 0.65, 0.48, 0.31, 0.25, 0.45, 0.52, 0.38, 0.12, 0.08, 0.15] of graph node v3. In the same way, the temporal attention feature and the numerical encoding feature of each graph node are concatenated to obtain the fusion feature of each graph node.

[0051] In this embodiment of the application, step S400 initializes the global prediction model on the server side, trains the local prediction model of each client in an iterative manner based on the fusion features, and calculates the network weight similarity between each local prediction model and the current global prediction model. In this embodiment, a global prediction model is first initialized on the server side, and the network weight parameters of the global prediction model are distributed to each client. Each client initializes a local prediction model based on the received network weight parameters. Taking one client as an example, the local prediction model of the client is trained iteratively based on the fusion features obtained in step S300. After training, the network weight parameters of the prediction layer of the local prediction model and the network weight parameters of the prediction layer of the current global prediction model are obtained, and the cosine similarity between the two is calculated as the network weight similarity between the local prediction model and the current global prediction model.

[0052] The steps of iteratively training the local prediction model for each client based on the fused features include E1 to E3: E1. Input the fused features into the fully connected output layer of the local prediction model, output the electricity consumption prediction result, and calculate the prediction loss between the electricity consumption prediction result and the actual electricity consumption. In this embodiment, taking graph node v3 as an example, the fusion feature Z3=[0.72, 0.65, 0.48, 0.31, 0.25, 0.45, 0.52, 0.38, 0.12, 0.08, 0.15] of graph node v3 obtained in step S300 is input to the fully connected output layer of the local prediction model, and the electricity consumption prediction result of graph node v3 at the corresponding time point is output. Then, the actual electricity consumption at that time point is obtained as y3=36800. The prediction loss between the predicted electricity consumption and the actual electricity consumption is calculated using the cross-entropy loss function. The cross-entropy loss function measures the prediction error by calculating the difference between the probability distribution of the predicted result and the probability distribution of the actual label. The prediction loss is 0.082. E2. Obtain the network weight parameters of the current global prediction model, calculate the parameter difference between the network weight parameters of the local prediction model and the global prediction model, and calculate the regularization loss based on the parameter difference. In this embodiment, the network weight parameters of the current global prediction model are obtained. and the network weight parameters of the local prediction model Then, the parameter difference between the two is calculated, and the regularization loss is calculated based on the L2 norm of the parameter difference. The formula for calculating the regularization loss is: ,in Let be the regularization coefficient, set The regularization loss is 0.013.

[0053] E3. Update the network weight parameters of the local prediction model based on the weighted sum of the prediction loss and the regularization loss; In this embodiment, the prediction loss of 0.082 obtained in step E1 and the regularization loss of 0.013 obtained in step E2 are weighted and summed to obtain a total loss of 0.095. Since the regularization loss has already been processed by the regularization coefficient in step E2... Weighting is applied, so the total loss is directly obtained by adding the prediction loss and the regularization loss. Next, the gradient of each network weight parameter in the local prediction model is calculated based on the total loss using the backpropagation algorithm, and the network weight parameters of the local prediction model are updated using the gradient descent method. Steps E1 to E3 are repeated until the difference in the total loss between two adjacent iterations is less than a preset threshold or the preset number of iterations is reached, thus completing the training of the local prediction model.

[0054] In this embodiment of the application, step S500 performs weighted aggregation of each local prediction model based on network weight similarity to update the global prediction model until the preset conditions are met, thereby obtaining a global prediction model for electricity consumption prediction. In this embodiment, after each client completes the training of its local prediction model, it updates the global prediction model by weighted aggregation of the local prediction models. Then, the network weight parameters of the updated global prediction model are sent to each client, and each client re-executes the training process of step S400 based on the updated network weight parameters. This process is repeated until the difference between the network weight parameters of two consecutive global prediction model updates is less than a preset threshold or a preset number of global iterations is reached, thus obtaining a global prediction model for electricity consumption prediction.

[0055] The steps for weighted aggregation of local prediction models based on network weight similarity to update the global prediction model include F1~F2: F1. Calculate the cosine similarity between the network weight parameters of each local prediction model prediction layer and the current global prediction model prediction layer, and normalize the cosine similarity to obtain the aggregate weight of each local prediction model. In this embodiment, it is assumed that the distributed system contains three clients. The network weight parameters of the prediction layer of the local prediction model and the network weight parameters of the prediction layer of the current global prediction model are obtained from the three clients respectively. Then, the cosine similarity between each local prediction model and the current global prediction model is calculated. The cosine similarity is obtained by calculating the ratio of the inner product of the two network weight parameter vectors to the product of the magnitudes of the two network weight parameter vectors. The cosine similarity between the local prediction model and the global prediction model of the first client is sim1=0.92, the cosine similarity between the second client is sim2=0.85, and the cosine similarity between the third client is sim3=0.88. Next, the cosine similarity is normalized by the softmax function to obtain the aggregate weight of the local prediction model of the first client. The aggregate weight of the second client The aggregate weight of the third client .

[0056] F2. Based on the aggregation weights, the network weight parameters of each local prediction model are weighted and aggregated to complete the update of the global prediction model; In this embodiment, the network weight parameters of each local prediction model are weighted and aggregated based on the aggregated weights of each local prediction model obtained in step F1. Specifically, the network weight parameters of the local prediction model of the first client are weighted and aggregated. Multiply by combining the network weight parameters of the local prediction model of the second client with the aggregate weights. Multiply by combining the network weight parameters of the local prediction model of the third client with the aggregate weights. Multiply the three values ​​and sum them to obtain the updated network weight parameters of the global prediction model, thus completing the update of the global prediction model.

[0057] In an optional implementation, step S500, which involves weighted aggregation of local prediction models based on network weight similarity to update the global prediction model, can also employ a dynamic weighting strategy based on model performance. Specifically, in addition to calculating the network weight similarity, the prediction performance metrics of each local prediction model on the local validation set are further introduced as auxiliary weight factors. For each client, the prediction accuracy or mean absolute error of its own local prediction model on the local validation set is calculated. Then, the performance metrics are normalized and weighted together with the network weight similarity to obtain the comprehensive aggregated weight. The calculation formula is as follows: ,in This represents the network weight similarity between the i-th local prediction model and the current global prediction model. This represents the normalized performance index of the i-th local prediction model. The balancing coefficient is used; finally, the network weight parameters of each local prediction model are weighted and aggregated according to the comprehensive aggregate weight to complete the update of the global prediction model.

[0058] In summary, by optimizing the model construction logic, a deep integration of feature mining, federated collaboration, and privacy protection has been achieved, thereby improving the practicality and performance of electricity consumption prediction. In the electricity consumption data feature processing stage, it breaks through the limitations of traditional methods that only focus on a single dimension. It can simultaneously capture the temporal patterns of electricity consumption data and the feature correlations between different users, and more comprehensively explore the complex dynamic relationships inherent in the data, solving the prediction accuracy bottleneck caused by insufficient feature extraction. In the application of the federated learning framework, it improves the problem of the lack of targeting in the aggregation of traditional local prediction models. By combining the aggregation strategy with weight similarity, it not only accelerates the update efficiency of the global prediction model, but also better adapts to the differences in data distribution among different clients, avoiding model performance loss caused by data heterogeneity, and making federated collaborative modeling more in line with the needs of actual distributed scenarios. Most importantly, the optimization process of model construction is always based on the technical characteristics of federated learning, ensuring that the original electricity consumption data does not leave the client and is not shared, fully complying with data privacy regulatory requirements. Ultimately, under the premise of effectively protecting privacy and security, it improves the overall performance of the electricity consumption prediction model, which can better adapt to the actual environment of data dispersion and strict privacy in the large-scale development of smart grids, and provide more accurate decision-making basis for scenarios such as electricity management and grid dispatch.

[0059] Example 3 illustrates a method for constructing an electricity consumption prediction model based on federated learning. It should be noted that the technical solution of this system for constructing the electricity consumption prediction model based on federated learning is based on the same concept as the technical solution of the method for constructing the electricity consumption prediction model based on federated learning described above. Details not described in detail in the technical solution of the system for constructing the electricity consumption prediction model based on federated learning in this example can be found in the description of the technical solution of the method for constructing the electricity consumption prediction model based on federated learning described above.

[0060] This embodiment also provides a system for constructing an electricity consumption prediction model based on federated learning, including: Data preprocessing and graph construction module: used to obtain the historical electricity consumption sequence of each client, perform time-series decomposition processing on the electricity consumption sequence to obtain multi-dimensional feature vectors, and construct a two-sided graph containing time-series edges and numerical edges based on the multi-dimensional feature vectors; Multi-scale feature extraction module: used to extract temporal attention features from the temporal edges using a graph attention network, and to obtain numerical coding features by modeling the node features corresponding to the numerical edges using a Gaussian distribution through a graph autoencoder. Feature fusion module: used to fuse the temporal attention features and the numerical coding features to obtain fused features; Local model training module: used to train the local prediction model of each client in an iterative manner based on fused features, and to calculate the network weight similarity between each local prediction model and the current global prediction model; Global model aggregation module: used to perform weighted aggregation of each local prediction model based on the network weight similarity to update the global prediction model until a preset condition is met.

[0061] This embodiment also provides an electronic device applicable to the construction of a power consumption prediction model based on federated learning, comprising: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the method for constructing a power consumption prediction model based on federated learning as proposed in the above embodiment.

[0062] This embodiment also provides a storage medium storing a computer program that, when executed by a processor, implements the method for constructing a federated learning-based electricity consumption prediction model as proposed in the above embodiments.

[0063] The storage medium proposed in this embodiment and the method for constructing a power consumption prediction model based on federated learning proposed in the above embodiments belong to the same inventive concept. Technical details not described in detail in this embodiment can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.

[0064] Based on the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of the various embodiments of the present invention.

[0065] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A method for constructing an electricity consumption prediction model based on federated learning, characterized in that, include: The historical power consumption sequence of each client in the distributed system is obtained, the historical power consumption sequence is decomposed into time series to obtain the multi-dimensional feature vector of each client, and a two-sided graph containing time series edges and numerical edges is constructed based on the multi-dimensional feature vector. The temporal edges are subjected to feature extraction at multiple time scales using a graph attention network to obtain temporal attention features. The node features corresponding to the numerical edges are modeled using a Gaussian distribution using a graph autoencoder to obtain numerical coding features. The temporal attention features and the numerical coding features are fused to obtain the fused features; A global prediction model is initialized on the server side, and local prediction models for each client are trained iteratively based on the fusion features. The network weight similarity between each local prediction model and the current global prediction model is calculated. The local prediction models are weighted and aggregated based on the network weight similarity to update the global prediction model until a preset condition is met, thus obtaining a global prediction model for electricity consumption prediction.

2. The method for constructing a power consumption prediction model based on federated learning as described in claim 1, characterized in that, The steps for constructing temporal edges based on the multidimensional feature vectors include: Each time point corresponding to the multidimensional feature vector is used as a graph node of the bilateral graph; Set a time window. For the graph node corresponding to the current time point, take the graph nodes corresponding to each historical time point within the time window as neighbor nodes. Establish time-series edges between the current graph node and each neighbor node, and determine the connection weight of each time-series edge according to the time distance between graph nodes. Based on each temporal edge and its corresponding connection weight, construct the adjacency matrix corresponding to the temporal edge.

3. The method for constructing a power consumption prediction model based on federated learning as described in claim 2, characterized in that, The steps for constructing numerical edges based on the multidimensional feature vectors include: Obtain the multidimensional feature vectors corresponding to each graph node in the bilateral graph, calculate the cosine similarity between each pair of multidimensional feature vectors of each graph node to obtain a similarity set, and calculate the average value of all cosine similarities in the similarity set, and use the average value as the similarity threshold. Traverse the similarity set, and for graph node pairs with a cosine similarity greater than the similarity threshold, establish numerical edges between the graph node pairs, and construct the adjacency matrix corresponding to each numerical edge.

4. The method for constructing a federated learning-based electricity consumption prediction model as described in claim 3, characterized in that, The steps for extracting temporal attention features from the temporal edges using a graph attention network across multiple time scales include: Obtain the adjacency matrix corresponding to the temporal edge, and obtain multiple neighborhood adjacency matrices representing different order neighborhood relationships based on the adjacency matrix; For each neighborhood adjacency matrix, the similarity features between each pair of graph nodes are calculated, and the similarity features are normalized to obtain the attention coefficients for that neighborhood. Based on the attention coefficients in each neighborhood, the feature vectors of adjacent graph nodes are weighted and aggregated to obtain the attention features in each neighborhood. The attention features in each neighborhood are then fused to obtain the temporal attention features.

5. The method for constructing a power consumption prediction model based on federated learning as described in claim 4, characterized in that, The steps for obtaining numerical encoded features by modeling the node features corresponding to the numerical edges using a Gaussian distribution through a graph autoencoder include: Based on the adjacency matrix corresponding to the numerical edges and the multidimensional feature vectors corresponding to each graph node, the first attention weight between each pair of graph nodes is calculated. The formula for calculating the first attention weight is as follows: ; In the formula, Let i be the first attention weight for graph node i to graph node j. Let P be the adjacency matrix corresponding to the numerical edges, and let P be the learnable projection matrix. and Let be the multidimensional feature vectors of graph node i and graph node j, respectively, and T be the matrix transpose operation. Let be the dimension of the multidimensional feature vector, and softmax be the normalization exponential function. Based on the first attention weight and combined with the learnable mask matrix, the second attention weight between each pair of graph nodes is calculated. The formula for calculating the second attention weight is as follows: ; In the formula, Let be the second attention weight of graph node i to graph node j, and R be the learnable mask matrix; The first attention weight and the second attention weight are weighted and fused to obtain a fused attention weight. The multidimensional feature vectors of each graph node are then weighted and aggregated according to the fused attention weight to obtain an aggregated feature vector. The aggregated feature vector is transformed by the mean parameter matrix and the covariance parameter matrix to obtain the mean vector and covariance vector of the Gaussian distribution, respectively, and the mean vector and the covariance vector are used as the numerical encoding features.

6. The method for constructing a federated learning-based electricity consumption prediction model as described in claim 5, characterized in that, The steps for iteratively training the local prediction model for each client based on the fused features include: The fused features are input into the fully connected output layer of the local prediction model to output the electricity consumption prediction result, and the prediction loss between the electricity consumption prediction result and the actual electricity consumption is calculated. Obtain the network weight parameters of the current global prediction model, calculate the parameter difference between the network weight parameters of the local prediction model and the global prediction model, and calculate the regularization loss based on the parameter difference; The network weight parameters of the local prediction model are updated based on the weighted sum of the prediction loss and the regularization loss.

7. The method for constructing a power consumption prediction model based on federated learning as described in claim 6, characterized in that, The step of weighted aggregation of local prediction models based on the network weight similarity to update the global prediction model includes: Calculate the cosine similarity between the network weight parameters of each local prediction model prediction layer and the current global prediction model prediction layer, and normalize the cosine similarity to obtain the aggregate weight of each local prediction model. The network weight parameters of each local prediction model are weighted and aggregated according to the aggregated weights to complete the update of the global prediction model.

8. A system for constructing an electricity consumption prediction model based on federated learning, using the method described in any one of claims 1-7, characterized in that, include: Data preprocessing and graph construction module: used to obtain the historical electricity consumption sequence of each client, perform time-series decomposition processing on the electricity consumption sequence to obtain multi-dimensional feature vectors, and construct a two-sided graph containing time-series edges and numerical edges based on the multi-dimensional feature vectors; Multi-scale feature extraction module: used to extract temporal attention features from the temporal edges using a graph attention network, and to obtain numerical coding features by modeling the node features corresponding to the numerical edges using a Gaussian distribution through a graph autoencoder. Feature fusion module: used to fuse the temporal attention features and the numerical coding features to obtain fused features; Local model training module: used to train the local prediction model of each client in an iterative manner based on fused features, and to calculate the network weight similarity between each local prediction model and the current global prediction model; Global model aggregation module: used to perform weighted aggregation of each local prediction model based on the network weight similarity to update the global prediction model until a preset condition is met.

9. An electronic device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, they implement the steps of the method for constructing the electricity consumption prediction model based on federated learning as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the method for constructing a federated learning-based electricity consumption prediction model as described in any one of claims 1 to 7.