Short-term residential load prediction method of K-shop clustering and adversarial domain adaptive migration network

Through the combination of K-shape clustering and adversarial domain adaptation migration network, the problems of insufficient processing of the diversity of residential power load modes and the differences between historical data and short-term prediction data in the prior art are solved, and more efficient short-term residential load prediction is achieved, improving the accuracy and reliability of predictions.

CN119721449APending Publication Date: 2025-03-28YUSHU POWER SUPPLY CO OF STATE GRID QINGHAI ELECTRIC POWER CO +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411740617.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The prior art lacks in-depth understanding and effective processing of the diversity of residential power load patterns in short-term residential load prediction, resulting in limited prediction accuracy. At the same time, there are differences between historical data and short-term predicted data in terms of data distribution and characteristic correlation, and direct mapping cannot accurately reflect the trend of short-term load change.

Method used

Using K-shape clustering and adversarial domain adaptation to migration network, the historical power load data is clustered through K-shape time series clustering, and representative load characteristics are extracted and screened. Then, an adversarial domain adaptation migration network is built, and through an adversarial training mechanism of the generator and discriminator, the generator can effectively map historical data features to the target domain feature space, and fine-tune the model with K-shape clustering results.

Benefits of technology

It improves the accuracy and reliability of short-term residential load prediction, can better adapt to the load characteristics of different residential buildings, enhances the model's adaptability to different data distributions, and provides stronger support for the stable operation and optimized management of the power system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119721449A_ABST
    Figure CN119721449A_ABST
Patent Text Reader

Abstract

The invention discloses a short-term residential load prediction method based on K-shape clustering and an adversarial domain adaptive migration network. For the defects of a traditional prediction method, historical power loads, related weather and other data are collected firstly, clustering is carried out through a K-shape algorithm, residences with similar load modes are classified into one class, and a foundation is provided for follow-up. And extracting characteristics such as peak values and valley values from the clustering typical mode, and screening key characteristics to reduce dimensions and extract refinement. An adversarial domain adaptive migration network is constructed, and adversarial training is carried out through a generator and a discriminator, so that the generator learns effective mapping, and the discriminator accurately distinguishes features. And training the network by using historical data and performing fine tuning in combination with clustering results. During prediction, target residence features are firstly extracted and input into a generator, then a prediction value is obtained by using a linear regression model, and finally calibration is performed according to a clustering average load mode. The prediction accuracy and reliability are improved, and stable operation and optimal management of the power system are facilitated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of power system load forecasting, and in particular relates to a short-term residential load forecasting method based on K-shape clustering and adversarial domain adaptive migration network. Background Art

[0002] In the field of power systems, accurate short-term residential load forecasting is of vital importance for the rational planning of power supply, energy management, and the stable operation of the power market. However, the existing technology has many defects in this regard, which need to be solved urgently.

[0003] Traditional residential load forecasting methods often lack an in-depth understanding and effective handling of the diversity of residential electricity load patterns. Due to significant differences in residents' living habits, household electrical equipment composition, and usage patterns, different residences have power load curves that present a variety of patterns. For example, some residences have lower electricity consumption during the day, as most residents go out to work or go to school, while electricity consumption is higher at night, when various electrical appliances are used intensively; other residences may have relatively high electricity consumption during the day due to the presence of elderly people or children at home all day, and the time of peak and trough electricity consumption and the amplitude of load fluctuations are not the same. When faced with such complex diversity, traditional methods usually use a unified model and features for prediction, which cannot accurately capture the load characteristics of different types of residences, resulting in limited prediction accuracy.

[0004] In addition, the existing technology lacks an effective adaptive mechanism in the process of mapping historical data features to the target domain (short-term forecast). Since historical data and short-term forecast data may differ in data distribution, feature correlation, etc., directly using traditional methods for mapping often cannot accurately reflect the changing trend of short-term load, resulting in a large deviation between the forecast results and the actual load situation. Summary of the invention

[0005] In view of the above deficiencies in the prior art, the purpose of the present invention is to improve the accuracy and reliability of short-term residential load forecasting by K-shape clustering and adversarial domain adaptive migration network, and provide strong support for the stable operation and optimized management of the power system.

[0006] In order to achieve the above objectives, the present invention adopts the following technical solutions:

[0007] The short-term residential load forecasting method based on K-shap clustering and adversarial domain adaptation migration network includes the following steps:

[0008] S1. Data collection: collect historical power load data, including but not limited to the power consumption of each residence, timestamps, and weather conditions that may affect the load;

[0009] S2. K-shape time series clustering, using the K-shape time series clustering algorithm to cluster the collected historical power load data, output multiple clusters, and each cluster contains residences with similar load patterns;

[0010] S3. Feature extraction and selection: Extract features useful for load forecasting, such as peak, valley, volatility, trend, and periodicity, from the typical load pattern of each cluster in S2. Use feature selection methods to further screen features useful for load forecasting to reduce the complexity of the model and improve the prediction accuracy.

[0011] S4. Construct an adversarial domain adaptation transfer network. Construct an adversarial domain adaptation transfer network. The adversarial domain adaptation transfer network includes a generator and a discriminator. The generator and the discriminator are trained adversarially until the features generated by the generator can better adapt to the target domain, until the discriminator has difficulty distinguishing between real and generated features.

[0012] S5. Model training and optimization: Use historical power load data to train the adversarial domain adaptation transfer network. Through adversarial training, learn how the generator learns to generate features that can deceive the discriminator, and learn how to better map the source domain data to the target domain. Combined with the K-shape clustering results, fine-tune the model to ensure that the model can adapt to the load characteristics of different residences.

[0013] S6. Short-term load forecasting: Use the trained model to predict the short-term power load of the target residence, and calibrate the forecast results based on the typical load pattern obtained by cluster analysis to improve the accuracy of the forecast.

[0014] In S1, the data is the electricity consumption metering data of residential buildings obtained from the database of the power company. These data record the electricity consumption at certain time intervals to ensure the accuracy and completeness of the data;

[0015] At the same time, relevant weather data from the meteorological department should be collected, including temperature, humidity, wind speed, air pressure, etc., as well as date information; the time resolution of weather data should match that of power load data for subsequent correlation analysis;

[0016] Finally, the data is integrated, and the power load data and weather data are integrated according to the timestamp to ensure that the power data at each time point can correspond to the corresponding weather conditions.

[0017] The S2 includes:

[0018] S21. Initialize the cluster center and randomly select K time series from the collected historical power load data as the initial cluster center C = {c1, c2, ..., c K}, K is the preset number of clusters;

[0019] S22. Assign time series to clusters. For each residential electricity load time series x i = {i = 1, 2, ..., N}, is the total number of houses N, calculate its relationship with each cluster center c k The distance d(x) of {k=1, 2, ..., K} i ,c k ), according to the minimum distance principle, the power load time series x i Assigned to the cluster to which the nearest cluster center belongs; where d(x i ,c k ) is calculated as:

[0020]

[0021] x i represents the time series of the power load of the i-th house; c k represents the kth cluster center; n is the length of the time series, that is, the number of data points contained in the time series; x ij The time series x of the i-th residential power load i The jth data point in c kj is the jth data point in the kth cluster center; represents the time series x of the power load of the i-th residential building i The mean of is the standard deviation of the time series of the ith residential electricity load; Represents the k-th cluster center c k The mean of is the k-th cluster center c k The standard deviation of

[0022] S23. Update the cluster center. For each cluster, calculate the mean sequence of all time series in the cluster and use it as the new cluster center C n k , the specific calculation method is:

[0023] For the time series x in the cluster k , j = {j = 1, 2, ..., n k},n k is the number of elements in the cluster, and the new cluster center C n k The value at each time point is:

[0024]

[0025] That is, first sum the values ​​of all time series in the cluster at the same time point, and then divide it by the number of time series to obtain the value of the new cluster center at that time point;

[0026] S24. Convergence judgment: repeat S22 and S23 until the convergence condition is met. The convergence condition is set as the sum of the moving distances of all cluster centers in two consecutive iterations is less than the threshold ε, that is, in

[0027] When the convergence condition is met, the algorithm stops iterating, and the final power load time series corresponding to the houses with similar load patterns in each cluster is obtained;

[0028] S25. Clustering result output: when the algorithm converges, each cluster in the cluster contains residential power load time series with similar load patterns.

[0029] In S3, the peak feature is the maximum electricity demand of residences with similar load patterns within a certain time range; the valley feature is the minimum electricity consumption level of residences with similar load patterns, which is used to analyze the basic load situation of the power system; the volatility feature uses standard deviation to measure the volatility of the load pattern, and the volatility feature reflects the stability of electricity consumption in such residences. Large volatility means that residents' electricity consumption behavior is relatively irregular or is greatly affected by multiple factors; the trend feature represents the trend by calculating the linear regression slope of the load pattern, such as the regression equation: y=ax+b, where a is the slope, b is the intercept, x is the independent variable representing the time point, and y is the dependent variable representing the load value; the periodic feature is the periodic characteristics of electricity consumption in residences with similar load patterns.

[0030] In S3, the feature selection method includes:

[0031] S31. Category probability calculation: According to the statistical distribution of historical power load data, the features useful for load forecasting are divided into different categories, such as high load, medium load and low load, and the probability of each category appearing in the data set is calculated. The formula is expressed as:

[0032]

[0033] Where c represents the category, c = 1, 2, ..., C, C is the number of categories; p(c) represents the probability of category c appearing in the data set; N represents the number of samples in the data set; n c Indicates the number of samples belonging to category c;

[0034] S32. Calculation of Entropy. Entropy is used to measure the uncertainty of a random variable. The entropy of category C is expressed as:

[0035]

[0036] H(C) represents the entropy of the category; p(c) represents the probability of category c appearing in the data set;

[0037] S33. Calculation of Conditional Entropy: For each feature F, calculate its conditional entropy under different values:

[0038]

[0039] Among them, v represents the value of feature F; n c,v represents the number of samples of category c; H(C|F=v) represents the conditional entropy when the value of feature F is v; p(c|F=c) is the probability of category c appearing when the value of feature F is v, and p(c|F=c) represents the probability of each category c appearing when feature F is at a specific value v;

[0040] S34. Information gain calculation, the calculation expression of information gain calculation is:

[0041]

[0042] Among them, IG(C,F) represents information gain; V represents the number of different values ​​of feature F, that is, feature F has V different values; |F=v| is the number of samples with feature F value v; |F| is the total number of samples;

[0043] S35. Feature selection: After calculating the information gain of all extracted features, the features are sorted from large to small according to the information gain value. Based on the sorting results, the features with larger information gain are selected as the final features for load forecasting, and the features with smaller information gain are discarded.

[0044] In S4, both the generator and the discriminator adopt a multi-layer fully connected neural network structure;

[0045] S41. Generator network structure design. The number of neurons in the generator input layer is determined according to the dimension of the historical data feature vector after feature extraction and selection. The number of hidden layers is set according to the actual situation, and the number of neurons in each hidden layer decreases in turn. The activation function of the neuron adopts ReLU (function, whose expression is:

[0046] f(x)=max(0,x);

[0047] x is the independent variable of the function f(x); when the function f(x) is used to activate the generator neuron, x represents the input signal received by the neuron from the previous layer of neurons, and f(x) is the output value determined according to the value of x;

[0048] The goal of the generator is to learn a mapping function G:X→Y, where X is the feature space of historical data and Y is the feature space of the target domain; for the input historical data feature vector, the generator's multi-layer neural network is used to calculate and output the feature vector mapped to the target domain feature space; during the training process, the generator adjusts the network parameters by minimizing the loss function to make the generated features as close as possible to the real features of the target domain.

[0049] The loss function of the generator uses the mean square error (MSE), and the formula is:

[0050]

[0051] G(x i ) represents the features generated by the generator; where K is the number of samples used to train the generator, x i is the i-th historical data feature vector, y i is the corresponding real feature vector of the target domain; the mean square error loss function can measure the difference between the features generated by the generator and the real features. By minimizing this difference, the generator continuously learns how to better perform feature mapping.

[0052] S42. Discriminator network structure design. The input of the discriminator is the feature vector generated by the generator or the real feature vector of the target domain. The hidden layer structure of the discriminator is similar to that of the generator, but the last output layer of the discriminator has only one neuron and uses the Sigmoid activation function. The output value of the Sigmoid function is between 0 and 1. In the discriminator, the output of the Sigmoid function represents the probability that the input feature belongs to the real feature of the target domain. For example, an output value close to 1 indicates that the discriminator believes that the input feature is likely to be a real target domain feature, while an output value close to 1 indicates that the discriminator believes that the input feature is a false feature generated by the generator.

[0053] The goal of the discriminator is to distinguish the features generated by the generator from the features of the real target domain data, and its loss function is:

[0054]

[0055] Where D(y i ) represents the discriminator's prediction of the true target domain feature y i The predicted probability, D(G(x i )) represents the feature G(x) generated by the discriminator to the generator i )’s predicted probability;

[0056] S43. Constructing adversarial training mechanism to conduct adversarial training on generator and discriminator:

[0057] S431. First, fix the parameters of the discriminator and train the generator. The goal of the generator is to minimize its loss function L G , that is, by adjusting its own parameters, the generated features can deceive the discriminator, making it difficult for the discriminator to distinguish between the generated features and the real target domain features;

[0058] S432. Then fix the parameters of the generator and train the discriminator. The goal of the discriminator is to maximize its loss function L D , that is, by adjusting its own parameters, it improves its ability to distinguish between real and generated features; the discriminator calculates the loss function L according to the features currently generated by the generator and the real target domain features. D , and update the parameters through the gradient descent algorithm to make the discriminator predict the probability D(y i ) is closer to 1, the predicted probability D(G(x i ))Closer;

[0059] S433. Convergence condition, alternating S421 and S422 until the features generated by the generator can better adapt to the target domain and the discriminator has difficulty distinguishing between real and generated features; by setting a threshold to judge whether it has converged, when the absolute value of the difference between the predicted probabilities of the discriminator for real features and generated features is less than a certain threshold, it is considered that the adversarial training has converged; at this time, the generator has learned an effective way to map historical data features to the target domain feature space, the discriminator has also achieved a high discrimination accuracy, and the entire adversarial domain adaptation migration network has reached a relatively stable state.

[0060] The S5 includes:

[0061] S51. Training data preparation: historical power load data is divided into a training set and a validation set according to a certain ratio. The training set is used to train the adversarial domain adaptation transfer network, and the validation set is used to evaluate the performance of the model during the training process to prevent overfitting.

[0062] For each sample in the training set, the feature vector after feature extraction and selection is used as input, and the load value of the next time step is used as output;

[0063] S52. Model training, according to the adversarial training mechanism, alternately train the generator and the discriminator;

[0064] When training the generator, according to the generator's loss function L G , use the gradient descent algorithm to update the parameters of the generator. By calculating the gradient of the loss function to the parameters, the parameters are updated in the opposite direction of the gradient, so that the generator can continuously improve the generated features. The formula of the gradient descent algorithm is:

[0065]

[0066] Among them, θ G Represents the parameters of the generator; L G is the loss function of the generator; is the new value of the generator parameter after updating; α is the learning rate; Represents the current value of the generator parameters, that is, the parameters used by the generator before a parameter update;

[0067] When training the discriminator, according to the discriminator's loss function L D , the gradient descent algorithm is also used to update the parameters of the discriminator. The parameter update formula is:

[0068]

[0069] θ D Represents the parameters of the discriminator, which are similar to the generator parameters; Represents the current value of the discriminator parameters; represents the new value after the discriminator parameter is updated; L D is the loss function of the discriminator;

[0070] During the training process, hyperparameters such as learning rate are constantly adjusted to balance the training speed and model convergence.

[0071] S53. Fine-tune the model based on K-shape clustering results:

[0072] Targeted training of data within clusters. According to the K-shape clustering results in S2, for each cluster, the training data within the cluster is used to fine-tune the model. The parameters of the model will be adjusted according to the load characteristics of different clusters, so that the model can better adapt to the load patterns of different types of residences. For clusters with highly volatile load patterns, the model can pay more attention to volatility-related features during fine-tuning, and adjust the weights and biases related to volatility features in the neural network, so that the model can more accurately capture and predict the load changes of such residences.

[0073] Fine-tuning parameter settings: During the fine-tuning process, the learning rate α≤0.0001 is used to avoid destroying the overall structure of the model parameters obtained from the previous adversarial training, while at the same time being able to make fine adjustments to the clustering characteristics; the number of fine-tuning rounds should not be too many, and the number of fine-tuning rounds should be appropriately set according to the number and characteristics of the data in the cluster; by combining the K-shape clustering results for fine-tuning, the model can better adapt to the load characteristics of different residences and improve the accuracy and reliability of the prediction.

[0074] The S6 includes:

[0075] S61. Feature extraction and input. For the target house, the same feature extraction method as in S3 is used to extract its current and previous feature vectors. If features such as peaks, valleys, volatility, trends, and periodicity are used in the training data, these features should also be calculated in the same way for the target house. The feature vector is then input into the generator of the trained adversarial domain adaptation transfer network, and the generator outputs a feature vector mapped to the target domain feature space. When inputting the feature vector, ensure that its format and dimension are consistent with those during training, otherwise it may lead to prediction errors.

[0076] S62. Application of the prediction model: input the feature vector output by the generator and mapped to the target domain feature space into the linear regression model to obtain the short-term power load prediction value of the target residence; wherein the linear regression is expressed as:

[0077]

[0078] in, represents the short-term power load forecast value of the target residence, that is, the estimated value of the power load of the target residence in the future calculated by the model; k represents the dimension of the feature vector input into the linear regression model; y i is the i-th eigenvalue in the feature vector output by the generator and mapped to the feature space of the target domain; β i is the linear regression model corresponding to each feature y i The coefficient of

[0079] S63. Calibrate the prediction results: calculate the difference between the average load pattern of the cluster where the target residence is located and the predicted load pattern according to the clustering results in S2; the calculation method of the average load pattern includes:

[0080] S631. Determine the cluster of the target residential power load time series. If the target residential power load time series is assigned to cluster L during the clustering process, then the residential building belongs to cluster L.

[0081] S632. Calculate the average load pattern. For cluster L, calculate the average value of all residential power load time series at each time point. The obtained sequence is the average load pattern of the cluster. If there are n residential power load time series in cluster L, L The time series of power loads of residential buildings are The length of each time series is m (the number of time points), then the average load pattern A of cluster L = {a1, a2, ..., a m};

[0082] in,

[0083] S633. The calibration strategy is implemented. The prediction results are calibrated according to the difference metric. If the difference is large, it means that the prediction results may be biased. The prediction value is adjusted according to the average load pattern. If the prediction value is generally higher than the average load pattern, the prediction value should be lowered. Otherwise, the prediction value should be appropriately increased to make the prediction result more consistent with the typical load pattern characteristics of the cluster, thereby improving the accuracy of the prediction.

[0084] In summary, due to the adoption of the above technical solution, the beneficial technical effects of the invention are:

[0085] A short-term residential load forecasting method based on K-shape clustering and adversarial domain adaptive migration network. Through the K-shape time series clustering algorithm, residential load patterns can be effectively clustered according to their similarity, and residential buildings with similar electricity consumption behaviors can be classified into one category, thereby laying the foundation for subsequent feature extraction and model training for different types of load patterns. In the feature extraction and selection stage, features that are important for load forecasting are carefully selected, and key features are screened by methods such as information gain to reduce model complexity and improve prediction accuracy. An adversarial domain adaptive migration network is constructed, and the adversarial training mechanism of the generator and the discriminator is used to enable the generator to learn how to effectively map historical data features to the target domain feature space. At the same time, the discriminator can accurately distinguish between real and generated features, and enhance the adaptability of the model to different data distributions. The model is fine-tuned in combination with the K-shape clustering results, and the model is further optimized to adapt to the load characteristics of different residences. Through these technical means, the present invention aims to improve the accuracy and reliability of short-term residential load forecasting and provide strong support for the stable operation and optimized management of power systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0086] Figure 1 A method flow chart of a short-term residential load forecasting method based on K-shap clustering and adversarial domain adaptation migration network;

[0087] Figure 2 Flowchart of the method for K-shape time series clustering;

[0088] Figure 3 Flowchart of the feature selection method;

[0089] Figure 4 Flowchart of the method built for adversarial domain adaptation transfer network;

[0090] Figure 5 Flowchart of the method for training and optimizing the adversarial domain adaptation transfer network model;

[0091] Figure 6 Flowchart of a method for predicting short-term power load of a target residence using a trained model. DETAILED DESCRIPTION

[0092] In order to make the purpose, technical solution and advantages of the invention more clear, the invention is further described in detail below in combination with the embodiments. It should be understood that the specific embodiments described here are only used to explain the invention and are not used to limit the invention.

[0093] like Figure 1 As shown, the short-term residential load forecasting method based on K-shap clustering and adversarial domain adaptation migration network includes the following steps:

[0094] S1. Data collection: collect historical power load data, including but not limited to the power consumption of each residence, timestamp (hour, day, week), and weather conditions that may affect the load;

[0095] S2. K-shape time series clustering, using the K-shape time series clustering algorithm to cluster the collected historical power load data, output multiple clusters, and each cluster contains residences with similar load patterns;

[0096] S3. Feature extraction and selection: Extract features useful for load forecasting, such as peak, valley, volatility, trend, and periodicity, from the typical load pattern of each cluster in S2. Use feature selection methods to further screen features useful for load forecasting to reduce the complexity of the model and improve the prediction accuracy.

[0097] S4. Construct an adversarial domain adaptation transfer network. Construct an adversarial domain adaptation transfer network. The adversarial domain adaptation transfer network includes a generator and a discriminator. The generator and the discriminator are trained adversarially until the features generated by the generator can better adapt to the target domain and the discriminator has difficulty distinguishing between real and generated features. The goal of the generator in the adversarial domain adaptation transfer network is to map the features of historical data to the feature space of the target domain (short-term prediction), and the goal of the discriminator is to distinguish the features generated by the generator from the features of the real target domain data, thereby guiding the generator to generate more realistic features.

[0098] S5. Model training and optimization: Use historical power load data to train the adversarial domain adaptation transfer network. Through adversarial training, learn how the generator learns to generate features that can deceive the discriminator, and learn how to better map the source domain data to the target domain. Combined with the K-shape clustering results, fine-tune the model to ensure that the model can adapt to the load characteristics of different residences.

[0099] S6. Short-term load forecasting: Use the trained model to predict the short-term power load of the target residence, and calibrate the forecast results based on the typical load pattern obtained by cluster analysis to improve the accuracy of the forecast.

[0100] In S1, the data is the electricity consumption metering data of residential buildings obtained from the database of the power company. These data record the power consumption at a certain time interval (for example, every 15 minutes or every hour) to ensure the accuracy and completeness of the data;

[0101] At the same time, relevant weather data from the meteorological department should be collected, including temperature, humidity, wind speed, air pressure, etc., as well as date information (such as weekdays / weekends, holidays, etc.); the time resolution of weather data should match that of power load data for subsequent correlation analysis;

[0102] Finally, the data is integrated, and the power load data and weather data are integrated according to the timestamp to ensure that the power data at each time point can correspond to the corresponding weather conditions.

[0103] like Figure 2 As shown, the S2 includes:

[0104] S21. Initialize the cluster center and randomly select K time series from the collected historical power load data as the initial cluster center C = {c1, c2, ..., c K}, K is the preset number of clusters;

[0105] S22. Assign time series to clusters. For each residential electricity load time series x i = {i = 1, 2, ..., N}, is the total number of houses N, calculate its relationship with each cluster center c k The distance d(x) of {k=1, 2, ..., K} i ,c k ), according to the minimum distance principle, the power load time series x i Assigned to the cluster to which the nearest cluster center belongs; where d(x i ,c k ) is calculated as:

[0106]

[0107] x i represents the time series of the power load of the i-th house; c k represents the kth cluster center; n is the length of the time series, that is, the number of data points contained in the time series; x ij The time series x of the i-th residential power load i The jth data point in c kj is the jth data point in the kth cluster center; represents the time series x of the power load of the i-th residential building i The mean of is the standard deviation of the time series of the ith residential electricity load; Represents the k-th cluster center c k The mean of is the k-th cluster center c k The standard deviation of

[0108] S23. Update the cluster center. For each cluster, calculate the mean sequence of all time series in the cluster and use it as the new cluster center C n k , the specific calculation method is:

[0109] For the time series x in the cluster k,j ={j=1, 2, ..., n k},n k is the number of elements in the cluster, and the new cluster center C n k The value at each time point is:

[0110]

[0111] That is, first sum the values ​​of all time series in the cluster at the same time point, and then divide it by the number of time series to obtain the value of the new cluster center at that time point;

[0112] S24. Convergence judgment: repeat S22 and S23 until the convergence condition is met. The convergence condition is set as the sum of the moving distances of all cluster centers in two consecutive iterations is less than the threshold ε, that is, in

[0113] When the convergence condition is met, the algorithm stops iterating, and the final power load time series corresponding to the houses with similar load patterns in each cluster is obtained;

[0114] S25. Clustering result output. When the algorithm converges, each cluster in the cluster contains residential power load time series with similar load patterns. For example, in a cluster, the residences may show a pattern of lower power consumption during the day and higher power consumption at night, and the time of peak and trough power consumption and the amplitude of load fluctuation are relatively similar.

[0115] There are obvious differences in load patterns between different clusters. For example, one cluster may represent residential buildings that mainly use commercial electricity, with high electricity consumption during the day and low electricity consumption at night; while another cluster may be residential buildings, whose electricity consumption patterns are related to the daily life patterns of residents, such as obvious peak electricity consumption in the morning and evening.

[0116] The power load time series of each residence is associated with the cluster label to which it belongs to form a cluster allocation table; as shown in Table 1:

[0117]

[0118]

[0119] By clustering historical power load data using the K-shape algorithm, residential groups with similar load patterns can be found. Different residential buildings may have different power load curves due to factors such as residents' electricity usage habits, types of household electrical appliances, and usage patterns (for example, some residential buildings have obvious peak power consumption during the day, while other residential buildings use more electricity at night). Clustering can group these residential buildings with similar patterns into one category, so that feature extraction and model training can be performed for different types of load patterns in the future.

[0120] In S3, the peak feature is the maximum electricity demand of a residence with a similar load pattern within a certain time range (such as a day or a week); the valley feature is the minimum electricity consumption level of a residence with a similar load pattern, which is used to analyze the basic load situation of the power system; the volatility feature uses the standard deviation to measure the volatility of the load pattern, and the volatility feature reflects the stability of electricity consumption in this type of residence. Large volatility means that residents' electricity consumption behavior is relatively irregular or is greatly affected by multiple factors; the trend feature represents the trend by calculating the linear regression slope of the load pattern, such as the regression equation: y=ax+b, where a is the slope, b is the intercept, x is the independent variable representing the time point, and y is the dependent variable representing the load value; the periodic feature is the periodic characteristics of electricity consumption in residences with similar load patterns.

[0121] like Figure 3 As shown, in S3, the feature selection method includes:

[0122] S31. Category probability calculation: According to the statistical distribution of historical power load data, the features useful for load forecasting are divided into different categories, such as high load, medium load and low load, and the probability of each category appearing in the data set is calculated. The formula is expressed as:

[0123]

[0124] Where c represents the category, c = 1, 2, ..., C, C is the number of categories; p(c) represents the probability of category c appearing in the data set; N represents the number of samples in the data set; n c Indicates the number of samples belonging to category c;

[0125] S32. Calculation of Entropy. Entropy is used to measure the uncertainty of a random variable. The entropy of category C is expressed as:

[0126]

[0127] H(C) represents the entropy of the category; p(c) represents the probability of category c appearing in the data set;

[0128] S33. Calculation of Conditional Entropy: For each feature F, calculate its conditional entropy under different values:

[0129]

[0130] Among them, v represents the value of feature F; n c,v represents the number of samples of category c; H(C|F=v) represents the conditional entropy when the value of feature F is v; p(c|F=c) is the probability of category c appearing when the value of feature F is v, which represents the probability of each category c appearing when feature F is at a specific value v;

[0131] S34. Information gain calculation, the calculation expression of information gain calculation is:

[0132]

[0133] Among them, IG(C,F) represents information gain; V represents the number of different values ​​of feature F, that is, feature F has V different values; |F=v| is the number of samples with feature F value v; |F| is the total number of samples;

[0134] S35. Feature selection: after calculating the information gain of all extracted features (peak, valley, volatility, trend, periodicity, etc.), sort the features from large to small according to the information gain value; for example, after calculation, the information gain of the peak feature is 0.8, the information gain of the trend feature is 0.6, the information gain of the valley feature is 0.3, the information gain of the volatility feature is 0.2, and the information gain of the periodicity feature is 0.1, then the order after sorting is: peak feature, trend feature, valley feature, volatility feature, periodicity feature;

[0135] Select key features:

[0136] According to the sorting results, select the features with larger information gain as the final features for load forecasting; set a threshold or select several features with the highest ranking; if the threshold is set to 0.5, the peak feature and trend feature will be selected; or select the top k (such as k = 2) features, and the peak feature and trend feature will also be selected. The reason for selecting these key features is that they can provide more useful information for the prediction category, reduce the uncertainty of the model, and improve the prediction accuracy. At the same time, discarding features with smaller information gain can reduce the complexity of the model and avoid overfitting problems. Overfitting refers to the situation where the model performs well on the training data but has poor prediction ability on new data. Too many features may make the model too complex, overfit the details and noise in the training data, and ignore the overall trends and laws of the data. Through feature selection, retaining key features enables the model to focus more on the information most relevant to load forecasting and improve the generalization ability of the model, that is, the ability to predict new data.

[0137] like Figure 4 As shown, in S4, both the generator and the discriminator adopt a multi-layer fully connected neural network structure;

[0138] S41. Generator network structure design. The number of neurons in the generator input layer is determined according to the dimension of the feature vector of the historical data after feature extraction and selection. If m features such as peak value and trend are selected in the previous step, the number of neurons in the input layer is m; the number of hidden layers is set according to the actual situation, and the number of neurons in each hidden layer decreases successively. For example, the number of neurons in the first hidden layer can be half of the input layer, that is, the subsequent layers decrease in a certain proportion (such as the number of neurons in the second hidden layer is etc.); such a structural design helps to gradually extract and transform features, mapping from the original historical data feature space to the feature space of the target domain (short-term prediction);

[0139] The activation function of the neuron uses the ReLU (Rectified Linear Unit) function, which is expressed as:

[0140] f(x)=max(0,x)x is the independent variable of the function f(x); when the function f(x) is used to activate the generator neuron, x represents the input signal received by the neuron from the previous layer of neurons, and f(x) is the output value determined according to the value of x;

[0141] The ReLU function is widely used in neural networks. It can speed up the convergence of the network while reducing the amount of calculation; when the input value is greater than 0, the output is equal to the input value; when the input value is less than or equal to 0, the output is 0. This feature enables the network to effectively handle nonlinear problems during training and avoids the gradient vanishing problem (in deep networks, traditional activation functions such as the Sigmoid function may cause the gradient to gradually decrease during the back propagation process, affecting the training effect of the network).

[0142] The goal of the generator is to learn a mapping function G:X→Y, where X is the feature space of historical data and Y is the feature space of the target domain (short-term prediction); for the input historical data feature vector, the generator's multi-layer neural network is used to calculate and output the feature vector mapped to the target domain feature space; during the training process, the generator adjusts the network parameters by minimizing the loss function to make the generated features as close as possible to the real features of the target domain.

[0143] The loss function of the generator uses the mean square error (MSE), and the formula is:

[0144]

[0145] G(x i ) represents the features generated by the generator; where K is the number of samples used to train the generator, x i is the i-th historical data feature vector, y i is the corresponding real feature vector of the target domain (in the early stage of training, part of the historical data can be used as pseudo target domain data for approximation, and as the training progresses, more accurate target domain data is gradually used); the mean square error loss function can measure the degree of difference between the features generated by the generator and the real features. By minimizing this difference, the generator continuously learns how to better perform feature mapping.

[0146] S42. Discriminator network structure design. The input of the discriminator is the feature vector generated by the generator or the real feature vector of the target domain. The hidden layer structure of the discriminator is similar to that of the generator, but the last output layer of the discriminator has only one neuron and uses the Sigmoid activation function. The output value of the Sigmoid function is between 0 and 1. In the discriminator, the output of the Sigmoid function represents the probability that the input feature belongs to the real feature of the target domain. For example, an output value close to 1 indicates that the discriminator believes that the input feature is likely to be a real target domain feature, while an output value close to 1 indicates that the discriminator believes that the input feature is a false feature generated by the generator.

[0147] The goal of the discriminator is to distinguish the features generated by the generator from the features of the real target domain data, and its loss function is:

[0148]

[0149] Where D(y i ) represents the discriminator's prediction of the true target domain feature y i The predicted probability, D(G(x i )) represents the feature G(x) generated by the discriminator to the generator i )’s predicted probability;

[0150] S43. Adversarial training mechanism. During the training process, the generator and the discriminator are trained adversarially:

[0151] S431. First, fix the parameters of the discriminator and train the generator; at this time, the goal of the generator is to minimize its loss function L G , that is, by adjusting its own parameters, the generated features can deceive the discriminator, making it difficult for the discriminator to distinguish between the generated features and the real target domain features. For example, the generator changes the weights and biases of the neural network so that the output probability of the generated feature vector in the discriminator is close to 1, that is, the discriminator believes that these generated features are the real target domain features;

[0152] S432. Then fix the parameters of the generator and train the discriminator; the goal of the discriminator is to maximize its loss function L D , that is, by adjusting its own parameters, it improves its ability to distinguish between real and generated features. The discriminator calculates the loss function based on the features currently generated by the generator and the real target domain features, and updates the parameters through the gradient descent algorithm so that the discriminator predicts the probability D(y i ) is closer to 1, the predicted probability D(G(x i ))Closer;

[0153] S433. Convergence condition, alternate the above steps until the features generated by the generator can better adapt to the target domain and the discriminator has difficulty distinguishing between real and generated features. Generally, a threshold is set to determine whether it has converged. For example, when the absolute value of the difference between the predicted probabilities of the discriminator for real features and generated features is less than a certain threshold, the adversarial training is considered to have converged. At this point, the generator has learned an effective way to map historical data features to the target domain feature space, the discriminator has also achieved a high discrimination accuracy, and the entire adversarial domain adaptation migration network has reached a relatively stable state for subsequent short-term load forecasting tasks.

[0154] like Figure 5 As shown, the S5 includes:

[0155] S51. Training data preparation: historical power load data is divided into a training set and a validation set (30%) according to a certain ratio (e.g., 70%). The training set is used to train the adversarial domain adaptation transfer network, and the validation set is used to evaluate the performance of the model during the training process to prevent overfitting.

[0156] For each sample in the training set, its corresponding feature vector (after feature extraction and selection) is used as input, and the load value of the next time step is used as output (to build a supervised learning task). If it is predicted by hour, the feature vector of the current hour and the previous hour is input, and the load value of the next hour is output.

[0157] S52. Model training, according to the adversarial training mechanism, alternately train the generator and the discriminator;

[0158] When training the generator, according to the generator's loss function L G , use the gradient descent algorithm to update the parameters of the generator. By calculating the gradient of the loss function to the parameters, the parameters are updated in the opposite direction of the gradient, so that the generator can continuously improve the generated features. The formula of the gradient descent algorithm is:

[0159]

[0160] Among them, θ G Represents the parameters of the generator; L G is the loss function of the generator; is the new value of the generator parameter after updating; α is the learning rate; Represents the current value of the generator parameters, that is, the parameters used by the generator before a parameter update;

[0161] When training the discriminator, according to the discriminator's loss function L D , the gradient descent algorithm is also used to update the parameters of the discriminator. The parameter update formula is:

[0162]

[0163] θ D Represents the parameters of the discriminator, which are similar to the generator parameters; Represents the current value of the discriminator parameters; represents the new value after the discriminator parameter is updated; L D is the loss function of the discriminator;

[0164] During the training process, hyperparameters such as learning rate are constantly adjusted to balance the training speed and model convergence.

[0165] S53. Fine-tune the model based on K-shape clustering results:

[0166] Targeted training of data within clusters. According to the K-shape clustering results in S2, for each cluster, the training data within the cluster is used to fine-tune the model. The parameters of the model will be adjusted according to the load characteristics of different clusters, so that the model can better adapt to the load patterns of different types of residences. For clusters with highly volatile load patterns, the model can pay more attention to volatility-related features during fine-tuning, and adjust the weights and biases related to volatility features in the neural network, so that the model can more accurately capture and predict the load changes of such residences.

[0167] Fine-tuning parameter settings: During the fine-tuning process, a smaller learning rate (such as α≤0.0001) is used to avoid destroying the overall structure of the model parameters obtained from the previous adversarial training, while at the same time being able to make fine adjustments to the clustering characteristics; the number of fine-tuning rounds should not be too many, and is generally set appropriately according to the number and characteristics of the data in the cluster (for example, when the amount of data in each cluster is large, more fine-tuning rounds can be set, such as 10-20 rounds; when the amount of data is small, fewer rounds can be set, such as 3-5 rounds); by combining the K-shape clustering results for fine-tuning, the model can better adapt to the load characteristics of different residences and improve the accuracy and reliability of the prediction.

[0168] like Figure 6 As shown, the S6 includes:

[0169] S61. Feature extraction and input. For the target house, first extract its current and previous feature vectors (using the same feature extraction method as in S3); if features such as peaks, valleys, volatility, trends, and periodicity are used in the training data, then these features should be calculated in the same way for the target house. Then input the feature vector into the generator of the trained adversarial domain adaptation transfer network, and the generator outputs a feature vector mapped to the target domain feature space; when inputting the feature vector, ensure that its format and dimension are consistent with those during training, otherwise it may cause prediction errors;

[0170] S62. Application of the prediction model, inputting the feature vector output by the generator and mapped to the target domain feature space into the linear regression model to obtain the short-term power load prediction value of the target residence;

[0171] Linear regression is expressed as:

[0172]

[0173] in, represents the short-term power load forecast value of the target residence, that is, the estimated value of the power load of the target residence in the future calculated by the model; k represents the dimension of the feature vector input into the linear regression model; y iis the i-th eigenvalue in the feature vector output by the generator and mapped to the feature space of the target domain; β i is the linear regression model corresponding to each feature y i The coefficient of

[0174] S63. Calibrate the prediction results, and calculate the difference between the average load pattern of the cluster where the target residence is located and the predicted load pattern according to the clustering results in S2;

[0175] The calculation method of the average load mode includes:

[0176] S631. Determine the cluster of the target residential power load time series. If the target residential power load time series is assigned to cluster L during the clustering process, then the residential building belongs to cluster L.

[0177] S631. Calculate the average load pattern. For cluster L, calculate the average value of all residential power load time series at each time point. The obtained sequence is the average load pattern of the cluster. If there are n residential power load time series in cluster L, L The time series of power loads of residential buildings are The length of each time series is m (the number of time points), then the average load pattern A of cluster L = {a1, a2, ..., a m};

[0178] in,

[0179] The prediction results are calibrated according to the difference metric. If the difference is large, it means that the prediction results may be biased. The prediction value is adjusted according to the average load pattern. If the prediction value is generally higher than the average load pattern, the prediction value should be lowered. Otherwise, the prediction value should be appropriately increased to make the prediction result more consistent with the typical load pattern characteristics of the cluster, thereby improving the accuracy of the prediction.

[0180] The above description is a preferred embodiment of the invention and is not intended to limit the invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the invention should be included in the protection scope of the invention.

Claims

1. A short-term residential load forecasting method based on K-shap clustering and adversarial domain adaptation migration network, characterized in that: The following steps are involved: S1. Data collection: collect historical power load data, including but not limited to the power consumption of each residence, timestamp, and weather conditions that may affect the load; S2. K-shape time series clustering, using the K-shape time series clustering algorithm to cluster the collected historical power load data, output multiple clusters, and each cluster contains residences with similar load patterns; S3. Feature extraction and selection: extract features useful for load forecasting from the typical load patterns of each cluster in S2, and further screen the features useful for load forecasting through feature selection methods to reduce the complexity of the model and improve the prediction accuracy; S4. Construct an adversarial domain adaptation transfer network. Construct an adversarial domain adaptation transfer network. The adversarial domain adaptation transfer network includes a generator and a discriminator. The generator and the discriminator are trained adversarially until the features generated by the generator can better adapt to the target domain and the discriminator has difficulty distinguishing between real and generated features. S5. Model training and optimization: Use historical power load data to train the adversarial domain adaptation transfer network. Through adversarial training, learn how the generator learns to generate features that can deceive the discriminator, and learn how to better map the source domain data to the target domain. Combined with the K-shape clustering results, the model is fine-tuned to ensure that the model can adapt to the load characteristics of different residences; S6. Short-term load forecasting: Use the trained model to predict the short-term power load of the target residence, and calibrate the forecast results based on the typical load pattern obtained by cluster analysis to improve the accuracy of the forecast.

2. The short-term residential load forecasting method based on K-shap clustering and adversarial domain adaptive migration network according to claim 1 is characterized in that: In S1, the data is the electricity metering data of residential houses obtained from the database of the power company. These data record the electricity consumption at certain time intervals to ensure the accuracy and completeness of the data; at the same time, relevant weather data from the meteorological department is collected, including temperature, humidity, wind speed and air pressure, as well as date information; the time resolution of the weather data should match the power load data for subsequent correlation analysis; finally, the data is integrated, and the power load data and weather data are integrated according to the timestamp to ensure that the power data at each time point can correspond to the corresponding weather conditions.

3. The short-term residential load forecasting method based on K-shap clustering and adversarial domain adaptive migration network according to claim 1 is characterized in that: The S2 includes: S21. Initialize the cluster center and randomly select K time series from the collected historical power load data as the initial cluster center C = {c1, c2, ..., c K }, K is the preset number of clusters; S22. Assign time series to clusters. For each residential electricity load time series x i = {i = 1, 2, ..., N}, is the total number of houses N, calculate its relationship with each cluster center c k The distance d(x) of {k=1, 2, ..., K} i ,c k ), according to the minimum distance principle, the power load time series x i Assigned to the cluster to which the nearest cluster center belongs; where d(x i ,c k ) is calculated as: x i represents the time series of the power load of the i-th house; c k represents the kth cluster center; n is the length of the time series, that is, the number of data points contained in the time series; x ij The time series x of the i-th residential power load i The jth data point in c kj is the jth data point in the kth cluster center; represents the time series x of the power load of the i-th residential building i The mean of is the standard deviation of the time series of the ith residential electricity load; Represents the k-th cluster center c k The mean of is the k-th cluster center c k The standard deviation of S23. Update the cluster center. For each cluster, calculate the mean sequence of all time series in the cluster and use it as the new cluster center C n k , the specific calculation method is: For the time series x in the cluster k,j ={j=1, 2, ..., n k },n k is the number of elements in the cluster, and the new cluster center C n k The value at each time point is: That is, first sum the values ​​of all time series in the cluster at the same time point, and then divide it by the number of time series to obtain the value of the new cluster center at that time point; S24. Convergence judgment: repeat S22 and S23 until the convergence condition is met. The convergence condition is set as the sum of the moving distances of all cluster centers in two consecutive iterations is less than the threshold ε, that is, in When the convergence condition is met, the algorithm stops iterating, and the final power load time series corresponding to the houses with similar load patterns in each cluster is obtained; S25. Clustering result output: when the algorithm converges, each cluster in the cluster contains residential power load time series with similar load patterns.

4. The short-term residential load forecasting method based on K-shap clustering and adversarial domain adaptive migration network according to claim 1 is characterized in that: In S3, the peak feature is the maximum electricity demand of a residence with a similar load pattern within a certain time range; the valley feature is the minimum electricity consumption level of a residence with a similar load pattern, which is used to analyze the basic load of the power system; the volatility feature uses the standard deviation to measure the volatility of the load pattern, and the volatility feature reflects the stability of electricity consumption in such residences. Large volatility means that residents' electricity consumption behavior is relatively irregular or is greatly affected by multiple factors; trend The feature represents the trend by calculating the linear regression slope of the load pattern. The regression equation is: y = ax + b, where a is the slope, b is the intercept, x as the independent variable represents the time point, and y as the dependent variable represents the load value; The periodic characteristics are the electricity consumption cycle characteristics of residences with similar load patterns.

5. The short-term residential load forecasting method based on K-shap clustering and adversarial domain adaptive migration network according to claim 1 is characterized in that: In S3, the feature selection method includes: S31. Category probability calculation: According to the statistical distribution of historical power load data, the features useful for load forecasting are divided into different categories, such as high load, medium load and low load, and the probability of each category appearing in the data set is calculated. The formula is expressed as: Where c represents the category, c = 1, 2, ..., C, C is the number of categories; p(c) represents the probability of category c appearing in the data set; N represents the number of samples in the data set; n c Indicates the number of samples belonging to category c; S32. Calculation of entropy. Entropy is used to measure the uncertainty of a random variable. The entropy of category C is expressed as: H(C) represents the entropy of the category; p(c) represents the probability of category c appearing in the data set; S33. Calculation of conditional entropy. For each feature F, calculate its conditional entropy at different values: Among them, v represents the value of feature F; n c,v represents the number of samples of category c; H(C|F=v) represents the conditional entropy when the value of feature F is v; p(c|F=c) is the probability of category c appearing when the value of feature F is v, and p(c|F=c) represents the probability of each category c appearing when feature F is at a specific value v; S34. Information gain calculation, the calculation expression of information gain calculation is: Among them, IG(C,F) represents information gain; V represents the number of different values ​​of feature F, that is, feature F has V different values; |F=v| is the number of samples with feature F value v; |F| is the total number of samples; S35. Feature selection: After calculating the information gain of all extracted features, the features are sorted from large to small according to the information gain value. Based on the sorting results, the features with larger information gain are selected as the final features for load forecasting, and the features with smaller information gain are discarded.

6. The short-term residential load forecasting method based on K-shap clustering and adversarial domain adaptive migration network according to claim 1 is characterized in that: The S4 includes: S41. Generator network structure design. The number of neurons in the generator input layer is determined according to the dimension of the feature vector of the historical data after feature extraction and selection. The number of hidden layers is set according to the actual situation, and the number of neurons in each hidden layer decreases in turn. The activation function of the neuron adopts the ReLU function, which is expressed as: f(x)=max(0,x); f(x)=max(0,x)x is the independent variable of the function f(x); when the function f(x) is used to activate the generator neuron, x represents the input signal received by the neuron from the previous layer of neurons, and f(x) is the output value determined according to the value of x; The goal of the generator is to learn a mapping function G:X→Y, where X is the feature space of historical data and Y is the feature space of the target domain. For the input feature vector of historical data, the generator calculates through its multi-layer neural network and outputs a feature vector mapped to the feature space of the target domain. During the training process, the generator adjusts the network parameters by minimizing the loss function so that the generated features are as close as possible to the real features of the target domain. The loss function of the generator uses mean square error, and the formula is: G(x i ) represents the features generated by the generator; where K is the number of samples used to train the generator, x i is the i-th historical data feature vector, y i is the corresponding real feature vector of the target domain; the mean square error loss function can measure the difference between the features generated by the generator and the real features. By minimizing this difference, the generator continuously learns how to better perform feature mapping; S42. Discriminator network structure design. The input of the discriminator is the feature vector generated by the generator or the real feature vector of the target domain. The hidden layer structure of the discriminator is similar to that of the generator, but the last output layer of the discriminator has only one neuron and uses the Sigmoid activation function. The output value of the Sigmoid function is between 0 and 1. In the discriminator, the output of the Sigmoid function represents the probability that the input feature belongs to the real feature of the target domain; The goal of the discriminator is to distinguish the features generated by the generator from the features of the real target domain data, and its loss function is: Where D(y i ) represents the discriminator's prediction of the true target domain feature y i The predicted probability, D(G(x i )) represents the feature G(x) generated by the discriminator to the generator i )’s predicted probability; S43. Construction of adversarial training mechanism, method for adversarial training of generator and discriminator: S431. First, fix the parameters of the discriminator and train the generator. The goal of the generator is to minimize its loss function L G , that is, by adjusting its own parameters, the generated features can deceive the discriminator, making it difficult for the discriminator to distinguish between the generated features and the real target domain features; S432. Then fix the parameters of the generator and train the discriminator. The goal of the discriminator is to maximize its loss function L D , that is, by adjusting its own parameters, it improves its ability to distinguish between real and generated features; the discriminator calculates the loss function L according to the features currently generated by the generator and the real target domain features. D , and update the parameters through the gradient descent algorithm to make the discriminator predict the probability D(y i ) is closer to 1, the predicted probability D(G(x i ))Closer; S433. Convergence condition, alternating S421 and S422 until the features generated by the generator can better adapt to the target domain and the discriminator has difficulty distinguishing between real and generated features; by setting a threshold to judge whether it has converged, when the absolute value of the difference between the predicted probabilities of the discriminator for real features and generated features is less than a certain threshold, it is considered that the adversarial training has converged; at this time, the generator has learned an effective way to map historical data features to the target domain feature space, the discriminator has also achieved a high discrimination accuracy, and the entire adversarial domain adaptation migration network has reached a relatively stable state.

7. The short-term residential load forecasting method based on K-shap clustering and adversarial domain adaptive migration network according to claim 1 is characterized in that: The S5 includes: S51. Training data preparation: historical power load data is divided into a training set and a validation set according to a certain ratio. The training set is used to train the adversarial domain adaptation transfer network, and the validation set is used to evaluate the performance of the model during the training process to prevent overfitting. The ratio of the training set to the validation set is 7:

3. For each sample in the training set, the feature vector after feature extraction and selection is used as input, and the load value of the next time step is used as output; S52. Model training, according to the adversarial training mechanism, alternately train the generator and the discriminator; When training the generator, according to the generator's loss function L G , use the gradient descent algorithm to update the parameters of the generator. By calculating the gradient of the loss function to the parameters, the parameters are updated in the opposite direction of the gradient, so that the generator can continuously improve the generated features. The formula of the gradient descent algorithm is: Among them, θ G Represents the parameters of the generator; L G is the loss function of the generator; is the new value of the generator parameter after updating; α is the learning rate; Represents the current value of the generator parameters, that is, the parameters used by the generator before a parameter update; When training the discriminator, according to the discriminator's loss function L D , the gradient descent algorithm is also used to update the parameters of the discriminator. The parameter update formula is: θ D Represents the parameters of the discriminator, which are similar to the generator parameters; Represents the current value of the discriminator parameters; represents the new value after the discriminator parameter is updated; L D is the loss function of the discriminator; During the training process, hyperparameters such as learning rate are constantly adjusted to balance the training speed and model convergence. S53. Fine-tune the model based on K-shape clustering results: Targeted training of data within clusters. According to the K-shape clustering results in S2, for each cluster, the training data within the cluster is used to fine-tune the model. The parameters of the model will be adjusted according to the load characteristics of different clusters, so that the model can better adapt to the load patterns of different types of residences. For clusters with highly volatile load patterns, the model can pay more attention to volatility-related features during fine-tuning, and adjust the weights and biases related to volatility features in the neural network, so that the model can more accurately capture and predict the load changes of such residences. Fine-tuning parameter settings: During the fine-tuning process, the learning rate α≤0.0001 is used to avoid destroying the overall structure of the model parameters obtained from the previous adversarial training, while at the same time being able to make fine adjustments to the clustering characteristics; the number of fine-tuning rounds should not be too many, and the number of fine-tuning rounds should be appropriately set according to the number and characteristics of the data in the cluster; by combining the K-shape clustering results for fine-tuning, the model can better adapt to the load characteristics of different residences and improve the accuracy and reliability of the prediction.

8. The short-term residential load forecasting method based on K-shap clustering and adversarial domain adaptive migration network according to claim 1 is characterized in that: The S6 includes: S61. Feature extraction and input. For the target house, the same feature extraction method as in S3 is used to extract its current and previous feature vectors. The feature vector is then input into the generator of the trained adversarial domain adaptation transfer network, and the generator outputs a feature vector mapped to the target domain feature space. When inputting the feature vector, ensure that its format and dimension are consistent with those during training, otherwise it may lead to prediction errors. S62. Application of the prediction model: input the feature vector output by the generator and mapped to the target domain feature space into the linear regression model to obtain the short-term power load prediction value of the target residence; wherein the linear regression is expressed as: in, represents the short-term power load forecast value of the target residence, that is, the estimated value of the power load of the target residence in the future calculated by the model; k represents the dimension of the feature vector input into the linear regression model; y i is the i-th eigenvalue in the feature vector output by the generator and mapped to the feature space of the target domain; β i is the linear regression model corresponding to each feature y i The coefficient of S63. Calibrate the prediction results, based on the clustering results in S2, calculate the difference between the average load pattern of the cluster where the target residence is located and the predicted load pattern.

9. The short-term residential load forecasting method based on K-shap clustering and adversarial domain adaptive migration network according to claim 8 is characterized in that: The calculation method of the average load mode includes: S631. Determine the cluster of the target residential power load time series. If the target residential power load time series is assigned to cluster L during the clustering process, then the residential building belongs to cluster L. S632. Calculate the average load pattern. For cluster L, calculate the average value of all residential power load time series at each time point. The obtained sequence is the average load pattern of the cluster. If there are n residential power load time series in cluster L, L The time series of power loads of residential buildings are The length of each time series is m, then the average load pattern A of cluster L = {a1, a2, ..., a m }; in, S633. The calibration strategy is implemented. The prediction results are calibrated according to the difference metric. If the difference is large, it means that the prediction results may be biased. The prediction value is adjusted according to the average load pattern. If the prediction value is generally higher than the average load pattern, the prediction value should be lowered. Otherwise, the prediction value should be appropriately increased to make the prediction result more consistent with the typical load pattern characteristics of the cluster, thereby improving the accuracy of the prediction.