Short-term power load forecasting method and device based on attention mechanism clustering model
By adopting a clustering mode based on attention mechanism in short-term power load prediction, the load data is divided into different categories and a prediction model is established, the problem of poor prediction accuracy in the existing technology is solved, and higher load prediction accuracy and reliability of the power system are achieved.
Patent Information
- Application Number
- CN202410062427.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-16
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-01-16
AI Technical Summary
The prior art lacks consideration in short-term power load prediction, and the use of a single model leads to poor prediction accuracy, especially under factors that affect load data complexity and diversity.
A short-term power load prediction method based on the clustering mode of attention mechanism is adopted to divide the load data into different categories, and a corresponding prediction model is established, and the membership is dynamically adjusted through the attention mechanism to capture the local characteristics and structural information of the data.
Through the combination of clustering and attention mechanism, the accuracy of short-term power load prediction is improved, load changes can be predicted more accurately, and the supply and demand balance and reliability of the power system are enhanced.
Smart Images

Figure CN117807460B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power system load forecasting, and in particular to a short-term power load forecasting method and device based on an attention mechanism clustering model. Background Art
[0002] As a prediction at the end of the power system, the load forecast at the power consumption end refers to the prediction of the power consumption load of the power system in the future, including the prediction of civil, commercial and industrial power load. The load forecast at the power consumption end has application value in fields such as power grid dispatching. For example, the load forecast at the power consumption end can help power system operators predict the power demand in the future, so as to reasonably arrange the power generation plan and power dispatching to maintain the supply and demand balance of the power system and ensure the reliable supply of energy; through accurate power load forecasting, power system operators can more effectively plan and optimize the operation of power equipment and save operating costs; accurate power load forecasting can reduce the risk of power outages and improve the reliability and stability of the power system; accurate power load forecasting can help avoid excessive investment or waste of resources and provide support for the sustainable development of the power system.
[0003] Research on load forecasting also faces some difficulties. On the one hand, load forecasting requires a lot of data support, including historical electricity consumption data, weather data, economic data, etc., but these data often have uncertainties, which will challenge the prediction accuracy; on the other hand, load forecasting at the power consumption end is affected by many factors, including seasonal changes, weather changes, holidays, economic conditions, etc. These factors are intertwined and difficult to predict. Based on this, research on load forecasting at the power consumption end is of great significance.
[0004] The closest to the present invention is the convolutional neural network short-term load forecasting model. The convolutional neural network can automatically learn the feature representation of the input data through the convolution layer and the pooling layer. It has strong feature extraction capabilities and can effectively utilize the advantages of parallel computing to accelerate the training and reasoning process. However, due to the volatility, nonlinearity and non-stationarity of the load time series, as well as the diversity of influencing factors, including meteorology (such as temperature), seasons, calendars (such as working days and non-working days) and random factors, the above method does not take into account the complexity of load data, and the prediction accuracy using a single model is poor. Summary of the invention
[0005] The present invention provides a short-term power load forecasting method and device based on the attention mechanism clustering model, which solves the problem of insufficient consideration of the complexity of load data in the prior art and poor prediction accuracy using a single model. It realizes the classification of loads into different categories, establishes prediction models corresponding to different load data, and improves the accuracy of short-term power load forecasting.
[0006] In a first aspect, the present invention provides a short-term power load forecasting method based on an attention mechanism clustering model, the method comprising:
[0007] S101, obtain the initial data set and the trained load category prediction model and Load value prediction model ; wherein the initial data set includes: multi-day feature data average values and load labels;
[0008] S102: Input the characteristic data average value and the load label into the trained load category prediction model In the process, the load category is predicted to obtain the load category prediction value of the day to be predicted;
[0009] S103, respectively calculating the load category forecast value of the day to be forecasted The probability of each load category label in the load category labels is obtained to obtain the probability corresponding to the load category prediction value of the to-be-predicted day; wherein the sum of the multiple probabilities is 1;
[0010] S104, input the known sampling point data into the trained In the load value prediction model, the corresponding load prediction value; wherein the known sampling point data includes: power load, characteristic data;
[0011] S105, using the The load forecast value and the corresponding probability are weighted to obtain the load forecast value of the point to be forecasted;
[0012] S106, determine the next point to be predicted, and update the true value of the current prediction point, then execute S104 to S105 to predict the next point to be predicted, and obtain the load prediction value of the next point to be predicted, until all points to be predicted are predicted, and obtain the set of load prediction values for the day to be tested.
[0013] In combination with the first aspect, in a possible implementation, the load category prediction model Perform training to obtain the trained load category prediction model ,include:
[0014] The initial data set is preprocessed to obtain a data set and the optimal number of categories ;
[0015] Using the optimal number of classifications Get the corresponding load category labels and use the load category labels and long short-term memory network to build a load category prediction model ;
[0016] Get the dataset The data in the data are processed to obtain a data set ; wherein the data set including: the characteristic data and the load category label;
[0017] The dataset Normalize and get the normalized data set ;
[0018] Set the time step for the normalized dataset Divide and obtain the training set , and test set , ;
[0019] The training set , Input into the data loader to get the training data loader , the test set , Input into the data loader to get the test data loader ;
[0020] Build a long short-term memory network model and set the optimal loss and number of training times;
[0021] Set the LSTM network model to training mode and use the training data loader , the training set , The load category prediction model The parameters are updated to obtain an updated short-term memory network model;
[0022] Set the LSTM network model to evaluation mode and use the test data loader , the test set , The load category prediction model The parameters are evaluated to obtain the evaluation results;
[0023] Determine a minimum value between the evaluation result and the optimal loss, and determine the minimum value as the optimal loss;
[0024] The parameters of the long short-term memory network model are repeatedly updated according to the number of training times to obtain a trained load category prediction model. .
[0025] In combination with the first aspect, in a possible implementation manner, training the load value prediction model to obtain a trained load value prediction model includes:
[0026] The initial data set is preprocessed to obtain a data set and the optimal number of categories ;
[0027] Using the optimal number of classifications Corresponding load category labels, the dataset The data with the same load category label in are divided into the same data set, and the a first data set; wherein the first data set is a data set constructed on a daily basis;
[0028] The The first data set is obtained by removing the load category label revise the first dataset and The revised first dataset is converted to A second data set; among them, The second data set is a data set including the power load of each sampling point and the characteristic data;
[0029] Get the The data in the second data set are normalized to obtain Normalized data;
[0030] The dataset is analyzed using the normalized data, time step and number of features. Process and obtain the training set , and test set , ;
[0031] Input the data in the training set into a data loader to obtain a training data loader, and input the data in the test set into a data loader to obtain a test data loader;
[0032] Constructed with the The second dataset corresponds to Load value prediction model , and set the loss function;
[0033] The load value prediction model is trained using the training data, the test data and the loss function to obtain a trained load value prediction model. .
[0034] In combination with the first aspect, in a possible implementation manner, the initial data set is preprocessed to obtain a data set and the optimal number of categories ,include:
[0035] Using the initial data set, the power load set and feature dataset ;
[0036] Using the power load set and the feature dataset , get the data set ; wherein the data set Including: the power load set and the feature dataset ;
[0037] Set multiple categories , using the clustering method with attention mechanism and different number of categories to classify the dataset Perform clustering to get the number of each category The corresponding membership matrix and cluster centers;
[0038] Solving the maximum value of each row in the plurality of membership matrices respectively, and determining the load category label using the column index value corresponding to the maximum value;
[0039] Using the power load set and the load category labels, calculate the number of Corresponding silhouette coefficients, multiple silhouette coefficients are obtained;
[0040] Determine the number of categories corresponding to the maximum value among the multiple silhouette coefficients The optimal number of categories , and with the optimal number of classifications The corresponding membership matrix and cluster center are the optimal membership matrix and the optimal cluster center;
[0041] Add load category labels to the dataset , get the data set .
[0042] In combination with the first aspect, in a possible implementation manner, the number of setting categories , using a clustering method that incorporates an attention mechanism to classify the data set according to the number of categories Perform clustering to get the number of each category The corresponding membership matrix and cluster centers include:
[0043] Get the initialized membership matrix and use The mean algorithm initializes the cluster center, and calculates the initialized cluster center to obtain the cluster center ;
[0044] Using the cluster centers , respectively calculate the power load set Each data and the cluster center Multiple distances between ;
[0045] Using the exponential function and the multiple distances Calculate the attention weight matrix , calculate the power load set The element in the attention weight matrix corresponding to each data ;
[0046] Using the attention weight matrix , the cluster center and the power load set Updating the initialized membership matrix to obtain an updated membership matrix;
[0047] Using the membership matrix and the power load set , updating the cluster center to obtain an updated cluster center;
[0048] Determine whether the difference between the updated membership matrix and the membership matrix is less than a first threshold;
[0049] If yes, then output the updated membership matrix and the updated cluster centers; if no, recalculate the attention weight matrix using the updated membership matrix and the updated cluster centers. , the recalculated membership matrix and the recalculated cluster centers, until the difference between the recalculated membership matrix and the updated membership matrix is less than the first threshold.
[0050] In combination with the first aspect, in a possible implementation, the long short-term memory network model includes: a hidden layer and a fully connected layer, and the output dimension of the long short-term memory network model is 1.
[0051] In a second aspect, the present invention provides a short-term power load forecasting device based on an attention mechanism clustering model, the device comprising:
[0052] A data acquisition module is used to acquire an initial data set; wherein the initial data set includes: an average value of characteristic data of multiple days and a load label;
[0053] A load category prediction module is used to input the characteristic data average value and the load label into the trained load category prediction model In the process, the load category is predicted to obtain the load category prediction value of the day to be predicted;
[0054] The probability calculation module is used to calculate the load category forecast value of the predicted day. The probability of each load category label in the load category labels is obtained to obtain the probability corresponding to the load category prediction value of the to-be-predicted day; wherein the sum of the multiple probabilities is 1;
[0055] Load forecasting module, used to input known sampling point data into the trained In the load value prediction model, the corresponding load prediction value; wherein the known sampling point data includes: power load, characteristic data;
[0056] A prediction value calculation module is used to utilize the The load forecast value and the corresponding probability are weighted to obtain the load forecast value of the point to be forecasted;
[0057] The load forecast value set acquisition module is used to determine the next point to be predicted and update the true value of the current prediction point, and then execute S104 to S105 to predict the next point to be predicted to obtain the load forecast value of the next point to be predicted, until the prediction is completed for all points to be predicted, and the load forecast value set for the day to be tested is obtained.
[0058] In a third aspect, the present invention provides a short-term power load forecasting server based on an attention mechanism clustering model, the server comprising a memory and a processor;
[0059] The memory is used to store computer executable instructions;
[0060] The processor is used to execute the computer executable instructions to implement a short-term power load forecasting method based on an attention mechanism clustering model.
[0061] In a fourth aspect, the present invention provides a computer-readable storage medium having executable instructions, which can implement a short-term power load forecasting method based on an attention mechanism clustering model when a computer executes the executable instructions.
[0062] One or more technical solutions provided in the present invention have at least the following technical effects or advantages:
[0063] (1) The present invention uses a clustering method to first distinguish the categories of load days, and integrates the attention mechanism into the clustering algorithm, which can dynamically adjust the membership degree according to the similarity between the data sample and the cluster center, and better capture the local characteristics and structural information of the data;
[0064] (2) When the present invention performs load forecasting, the probability that the load on that day belongs to each category is first predicted, and then the load forecast values obtained by each model are weighted and summed to obtain the final load forecast value, thereby ultimately improving the load forecasting effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments of the present invention or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0066] Figure 1 A flowchart of the steps of a short-term power load forecasting method based on an attention mechanism clustering model provided in an embodiment of the present invention;
[0067] Figure 2 A flow chart for obtaining the optimal number of categories provided by an embodiment of the present invention;
[0068] Figure 3 The first type of data graph provided by the embodiment of the present invention;
[0069] Figure 4 The second type of data graph provided by the embodiment of the present invention;
[0070] Figure 5 A comparison diagram of the prediction results of the present invention and the direct prediction results of CNN provided in an embodiment of the present invention;
[0071] Figure 6 The present invention provides a specific overall flow chart of the use of the embodiment of the present invention. DETAILED DESCRIPTION
[0072] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0073] The present invention provides a short-term power load forecasting method based on the attention mechanism clustering model. Figure 1As shown, the method includes the following steps S101 to S106.
[0074] S101, obtain the initial data set and the trained load category prediction model and A load value prediction model is proposed; the initial data set includes: the average value of multi-day feature data and load labels.
[0075] Specifically, in step S101, the characteristics include: temperature, humidity, light irradiance and wind speed. The load data represents the load value at the sampling point.
[0076] For example, the continuous The power load data of the day (more than one year). The sampling data points for each day are The sampling time interval is Minutes, after preprocessing, the load data The day contains Load data. The load data of the day constitutes the power load set ,in, It is The daily load data includes The load value of the sampling point is expressed as ,in, Indicates Tiandi The load value of each sampling point.
[0077] Similarly, continuous The average temperature for the day , relative humidity , light irradiance and wind speed As feature data, The feature data of the day constitutes the feature data set ,in, Indicates The characteristic data of the day, ,in, Respectively represent Average temperature, relative humidity, light irradiance and wind speed of the day.
[0078] Combine the load data and characteristic data to form the initial data set:
[0079] .
[0080] Here, the data preprocessing specifically includes: preprocessing the initial data set to obtain a data set and the optimal number of categories , for the optimal number of classifications The obtained flowchart is as follows Figure 2 As shown, the following steps S201 to S207 are included.
[0081] S201, using the initial data set, obtain the power load set and feature dataset .
[0082] S202, using power load collection and feature dataset , get the data set ; Among them, the data set Includes: Power load set and feature dataset .
[0083] S203, setting the number of multiple categories , using clustering methods that incorporate attention mechanisms and different numbers of categories to classify the dataset Perform clustering to get the number of each category The corresponding membership matrix and cluster centers.
[0084] Specifically include: (1) For a given data set , take its power load set , set the number of categories and the attention weight coefficient , use the clustering algorithm to obtain the cluster center and membership matrix, including:
[0085] (1.1) First, the membership matrix Initialize, for The matrix needs to be initialized so that each row is evenly distributed and the sum is 1, that is:
[0086]
[0087] in, Indicates Samples Belong to The degree of class, Indicates a The matrix of Includes one day The load value of each sampling point.
[0088] (1.2) In order to make the clustering converge faster, use The K-Means algorithm is used to initialize the cluster centers.
[0089] (1.2.1) First, for the power load set , randomly given a shape The initial cluster center , The mean The cluster centers are .
[0090] (1.2.2) Calculate the power load set The distance between all samples in (1.2.1) and each cluster center in (1.2.1) is calculated, and the sample with the smallest distance is selected as the category of the sample. The distance calculation formula is:
[0091]
[0092] in, Representation sample To cluster center distance.
[0093] (1.2.3) After all samples have been classified, the new cluster center is obtained by calculating the centroid of all samples belonging to each category. , No. Cluster Centers The calculation formula is:
[0094]
[0095] in, Indicates categories, Indicates belonging to of the sample.
[0096] (1.2.4) Determine whether the convergence condition is met. If , then let , then go to step (1.2.2), if , then keep the current cluster center unchanged.
[0097] After the iterations from (1.2.1) to (1.2.4) above, the final output is As a fuzzy Initial cluster center of the mean algorithm , is a The matrix of Cluster Centers Expressed as .
[0098] (1.3) Calculate the attention weight. Calculate the Euclidean distance between all data samples and each cluster center, where Samples With Cluster Centers The distance between , the calculation formula is as follows:
[0099]
[0100] Then, the attention weight matrix is calculated using the exponential function , whose elements The calculation formula is as follows:
[0101]
[0102] Among them, exp(.) represents the natural constant e The exponential function with base , Represents data samples With cluster center The similarity.
[0103] Normalize the attention weight matrix by column to ensure that the sum of each column is 1 for subsequent use. It should be noted that the attention weight matrix obtained here is is a The matrix of .
[0104] (1.4) Use , cluster center And power load set , update the membership matrix to obtain , updated Sample pair The membership degree of cluster centers It is expressed as follows:
[0105]
[0106] in, Indicates Samples to The distance between cluster centers.
[0107] (1.5) Use power load set And the updated membership matrix obtained by (1.4) Cluster Center Update, The cluster center calculation formula is:
[0108]
[0109] (1.6) Determine the changes of the new and old membership matrices With threshold Comparison, It is expressed as follows:
[0110]
[0111] if , then let And go to step (1.3), otherwise, at this time and For power load collection , Number of categories and the attention weight coefficient The membership matrix and cluster center results obtained.
[0112] Number of categories The data set is divided into different categories or clusters, The choice of directly affects the results and effects of clustering. Now in order to find the optimal number of categories for the clustering process, we set the number of categories to , select the attention weight coefficient , and obtain multiple membership matrices.
[0113] S204, respectively solving the maximum value of each row in the plurality of membership matrices, and determining the load category label using the column index value corresponding to the maximum value.
[0114] Specifically, when By finding the sample The column index value corresponding to the maximum membership degree is used to determine the label label of the clustering result. The value range of label is .
[0115] S205, using power load collection and load category labels, counting the number of Corresponding silhouette coefficients, multiple silhouette coefficients are obtained.
[0116] Specifically, the silhouette coefficient is used to evaluate the quality of clustering. The silhouette coefficient combines the sample spacing and the comparison of the distance within and between clusters to evaluate the clustering quality by measuring the compactness and separation of the clustering results. The silhouette coefficient is calculated by the following formula:
[0117]
[0118] in, It refers to The average distance between a sample and other samples in the same cluster, that is, the intra-cluster distance; It refers to The average distance between a sample and the nearest sample in a different cluster is the inter-cluster distance. The value range is from -1 to 1. The closer to 1, the The classification of the sample is correct and the distance to other samples of the same type is relatively close, and the clustering effect is good; similarly, when its value is close to -1, it means that the first When a sample is misclassified and is far away from other samples of the same type, the clustering effect is poor; When the value of is close to 0, The samples are on the edge of two classes, indicating that the clustering result is unclear.
[0119] S206, determining the number of categories corresponding to the maximum value among the multiple silhouette coefficients The optimal number of categories , and with the optimal number of classifications The corresponding membership matrix and cluster center are the optimal membership matrix and the optimal cluster center.
[0120] Specifically, the power load group And the load category label obtained by clustering calculates the number of categories The corresponding silhouette coefficient is , When the corresponding contour coefficient is the largest, it means that when the load is divided into When there are 100 categories, the clustering effect is best, so choose As the optimal number of classifications, the corresponding cluster center and membership matrix are the optimal cluster centers. and the optimal membership matrix .
[0121] S207, add load category labels to the dataset , get the data set .
[0122] Specifically, according to the optimal number of classifications and clustering results, the data set is Adding Load Category Labels ,in Representative Samples The load category label is , then we can get a data set containing load value data, characteristic data and load category labels ,
[0123] .
[0124] Here, the load value prediction model is trained to obtain a trained load value prediction model, which specifically includes the following steps.
[0125] S301, preprocessing the initial data set to obtain a data set and the optimal number of categories .
[0126] Specifically, the initial data is processed according to steps S201 to S207 to obtain a data set and the optimal number of categories .
[0127] S302, using the best classification number Corresponding load category labels, and the dataset The data with the same load category label in are divided into the same data set, and the A first data set; wherein the first data set is a data set constructed on a daily basis.
[0128] Specifically, for a dataset with load category labels ,according to load categories and divide the data with the same category labels into the same data set.
[0129] S303, The first data set, removing the load category label, is obtained revise the first dataset and The first dataset was converted to A second data set; among them, The second data set is a data set including power load and characteristic data of each sampling point.
[0130] Specifically, after removing the load category label, the power load set is still constructed by day, and one sample contains one day The load value of each point and the characteristic data of the day are taken as a sample to reconstruct the data set. common Datasets, Indicates that the load category label is A single sample contains the load value of a sampling point and four feature data, and the label is If the number of days it contains is , the corresponding data set can be expressed as:
[0131]
[0132] in Respectively represent the load category labels The load value, temperature, humidity, light irradiance and wind speed of the first point are obtained by analogy. A second data set.
[0133] S304, obtain The data in the second data set are normalized to obtain The normalized data.
[0134] Specifically, the The method proposed here is described by taking a dataset as an example. The data in the table is normalized, and the normalized data satisfies:
[0135]
[0136] in, Indicates that the label is In the dataset A load value, represents the normalized result, , Label The minimum and maximum values of the load in the data set are obtained. Similarly, the temperature, humidity, light irradiance and wind speed data are also normalized, and the formula is as follows:
[0137]
[0138]
[0139]
[0140]
[0141] S305, using normalized data, time steps and number of features to analyze the data set Process and obtain the training set , and test set , .
[0142] Specifically, the dataset is divided by the time step time_step, the normalized data, and the number of features feature_size. Setting time_step to 20 means using the load values, temperature, humidity, light irradiance, and wind speed of the previous 20 points to predict the load value of the current point. Here, the value of feature_size is 5, which refers to one load value and four feature data. The dataset is divided into 75% (rounded down) training sets and 25% test sets, and then converted into a trainable tensor to obtain a training set with a dimension of 3. , , whose sizes are , ,in:
[0143]
[0144] in, Indicates rounding down. Get the test set , , whose sizes are , ,in .
[0145] S306, input the training set data into the data loader to obtain the training data loader, and input the test set data into the data loader to obtain the test data loader.
[0146] Specifically, the batch size batch_size is set to 128, , Put it into the data loader to generate the training data loader ,Will , Put it into the data loader to generate a test data loader .
[0147] S307, built with The second dataset corresponds to Load value prediction model .
[0148] Specifically, a convolutional neural network model is first created. The model consists of three single-dimensional convolutional layers, two fully connected layers, and a ReLU activation function. According to the characteristics of the load data, the size of the input feature is set to 5, the number of output channels of the three convolutional layers is set to [10, 20, 30], the convolution kernel size is set to 3, the output size is 1, and a convolutional neural network model is created. After a series of convolution and fully connected operations, the input data finally outputs a vector with 1 feature.
[0149] Then, set the model to training mode for training, initialize the loss, set running_loss=0, and use the following to accumulate the loss values for each batch:
[0150] (1) When in training mode, for the training data loader For each batch in and target value data , their sizes are and , clear the optimizer's gradient buffer to prevent gradient accumulation, and use the model to forward propagate the input data to get the predicted value .
[0151] (2) Calculate the predicted value using the given loss function With target value data In this load forecasting algorithm, the mean square error (MSE) loss function is used to measure the difference between the predicted value output by the model and the target value. The calculation formula is:
[0152]
[0153] in, Indicates The true value of the load, Indicates The load forecast value size, in each batch, The size is 128.
[0154] (3) Calculate the gradient based on the loss value and pass the gradient information back to the model parameters. Select the Adam optimizer to update the model parameters to reduce the loss. Then add the loss value of the current batch to running_loss to calculate the average loss.
[0155] (4) Calculate the average loss of the entire training set, ,in, represents the loss of the current training cycle, yes The length of the dataset.
[0156] Then, set the mode to evaluation mode, initialize the loss, and set test_running_loss=0 to accumulate the loss value of each test batch, including:
[0157] 1) For training data loader For each batch in and target value data , their sizes are and , use the model to forward propagate the input data to get the predicted value . Calculate the loss:
[0158]
[0159] in, Indicates i The true value of the load, Indicates i The load forecast value is n =128.
[0160] 2) Add the loss value of the current batch to test_running_loss in order to calculate the average loss.
[0161] 3) Calculate the average loss of the entire test set:
[0162]
[0163] in, represents the test loss of the current training cycle, express The length of the dataset.
[0164] 4) Determine whether to update the optimal loss value. If , then let .
[0165] S308, training the load value prediction model using the training data, the test data and the loss function to obtain a trained load value prediction model .
[0166] Here, the training process from S301 to S308 is repeated, and the load value prediction model is repeated 50 times in the process of continuously updating the model parameters, and finally the corresponding load value prediction model is obtained. .
[0167] Specifically, for load category prediction models The training process includes the following steps S401 to S409.
[0168] S401, preprocessing the initial data set to obtain a data set and the optimal number of categories .
[0169] Specifically, the initial data is processed using steps S201 to S207 to obtain a data set and the optimal number of categories .
[0170] S402, obtain data set The data in the data are processed to obtain the data set ; Among them, the data set Includes: characteristic data and load category labels.
[0171] Specifically, delete the load data, retain the feature data and load category labels, and obtain the data set , dataset It is expressed as:
[0172]
[0173] in Contains the Average temperature, relative humidity, solar irradiance, wind speed, and load category label for the day.
[0174] S403, the data set Normalize and get the normalized data set .
[0175] Specifically, read the data set The load category labels are normalized based on the data in the table. The normalized data satisfies:
[0176]
[0177] in, Indicates The label value of the day, represents the normalized result, , are the minimum and maximum values in the category label. Similarly, the temperature, humidity, light irradiance and wind speed data are also normalized, and the formula is as follows:
[0178]
[0179]
[0180]
[0181]
[0182] S404, set the time step for the normalized data set Divide and obtain the training set , and test set , .
[0183] Specifically, for the data set , the data set is divided by the time step time_step, the normalized data, and the number of features feature_size. Here, time_step is set to 10, which means that the temperature, humidity, light irradiance, wind speed, and load category labels of the previous 10 days are used to predict the load category label of the current date. The value of feature_size here is 5, which means four feature data and one load category label for one day. The data set is divided into 75% (rounded down) training set and 25% test set, and then converted into a trainable tensor. A training set with a dimension of 3 is obtained. , , whose sizes are , ,in . Get the test set , , whose sizes are , ,in .
[0184] S405, the training set , Input into the data loader to get the training data loader , the test set , Input into the data loader to get the test data loader .
[0185] Specifically, the batch size batch_size is set to 128, , Put it into the data loader to generate the training data loader ,Will , Put it into the data loader to generate a test data loader .
[0186] S406, construct a long short-term memory network model, set the loss function of the long short-term memory network model, and set the optimal loss function. , using the Adam algorithm as the optimization algorithm, the input data is trained to obtain the load category prediction model .
[0187] Specifically, the model includes one hidden layer and one fully connected layer. According to the characteristics of load data, the batch size is 128, the time step is 10, the input feature dimension is 5, the size is 10, it contains one hidden layer and one fully connected layer, the hidden state dimension is 12, and the output dimension is 1.
[0188] S407, set the long short-term memory network model to training mode, using the training data loader Load category prediction model The parameters are updated to obtain an updated long short-term memory network model.
[0189] Specifically, first set the model to training mode, initialize the loss, and let , used to accumulate the loss value of each batch.
[0190] Then, for the training data loader Each batch in the process includes obtaining input data and target value data , their sizes are and , clear the optimizer's gradient buffer to prevent gradient accumulation, and use the model to forward propagate the input data to get the predicted value .
[0191] Then use the mean square error (MSE) loss function to calculate the predicted value With target value data The loss between is calculated as:
[0192]
[0193] in, Indicates The actual value of the daily load category, Indicates Daily load category forecast values, in each batch, The size is 128.
[0194] Then the gradient is calculated based on the loss value, and the gradient information is passed back to the model parameters, and the Adam optimizer is used to update the model parameters to reduce the loss. Then the loss value of the current batch is added to in order to calculate the average loss.
[0195] Finally, the average loss of the entire training set is calculated, ,in, represents the loss of the current training cycle, yes The length of the dataset.
[0196] S408, set the short-term memory network model to evaluation mode, using the test data loader , test set , Load category prediction model The parameters are updated to obtain the secondary updated short-term memory network model.
[0197] Specifically, first set the mode to evaluation mode, initialize the loss, and let , used to accumulate the loss value of each test batch.
[0198] Then, for the training data loader Each batch in: Specifically includes: Get input data and target value data , their sizes are and , use the model to forward propagate the input data to get the predicted value . Calculate the loss:
[0199]
[0200] in, Indicates The actual value of the daily load category, Indicates Daily load category forecast value, =128.
[0201] Then add the loss value of the current batch to in order to calculate the average loss.
[0202] Then calculate the average loss of the entire test set:
[0203]
[0204] in, refers to the test loss of the current training cycle, yes The length of the dataset.
[0205] Finally, determine whether to update the optimal loss value. If , then let .
[0206] S409, repeatedly updating the parameters of the short-term memory network model to obtain a trained load category prediction model .
[0207] Specifically, according to the training process in step S401 and step S408, the parameters of the short-term memory network model are continuously updated, and the load value prediction model is repeated 100 times in the process of continuously updating the model parameters, and finally the load category prediction model is obtained. .
[0208] It should be noted that the category label is However, the category prediction value output by the model obtained in step S409 may be a non-integer after denormalization. If a prediction label is required, it is necessary to compare the denormalized prediction value with the load category label value and select the nearest load category label as the prediction label.
[0209] S102: Input the feature data average value and load label into the trained load category prediction model In the process, the load category is predicted to obtain the load category forecast value for the day to be predicted.
[0210] Specifically, the forecast is based on the average temperature, relative humidity, light irradiance, wind speed and load category of the 10 days before the forecast. The load category of the day is obtained, and the load category forecast value of the day to be predicted is obtained, which is expressed as , called the Daily load category forecast value.
[0211] S103, respectively calculate the load category forecast value of the day to be forecasted The probability of each load category label in the load category labels is calculated to obtain the probability corresponding to the load category prediction value of the predicted day; wherein the sum of multiple probabilities is 1.
[0212] Specifically, the load categories of the day are calculated as The probability of belonging to each category is 1:
[0213]
[0214] in, The load category label for that day is The probability of .
[0215] if Exactly equal to A number in ,So
[0216]
[0217] if With this The values of the category labels are not equal, so first calculate The distance from each category label value: ,in express With label value The distance .
[0218] Then get the inverse of the distance : .
[0219] Then the load category label for the day is obtained as Probability: .
[0220] S104, input the known sampling point data into the trained In the load value prediction model, the corresponding load prediction values; among which, the known sampling point data include: power load and characteristic data.
[0221] For example, the load values, temperature, humidity, light irradiance and wind speed of the 20 points before the prediction point are respectively sent to the load prediction model In the Load forecast values: ,in Indicates Tiandi Points in the model The load forecast value obtained in .
[0222] S105, using The load forecast value and the corresponding probability are weighted and calculated to obtain the load forecast value of the point to be predicted.
[0223] For example, the load forecast value of each point is obtained by weighting and summing the probability of the load category to which the load belongs on that day. :
[0224] .
[0225] S106, determine the next point to be predicted, and update the true value of the current prediction point, then execute S104 to S105 to predict the next point to be predicted, and obtain the load prediction value of the next point to be predicted, until all points to be predicted are predicted, and obtain the set of load prediction values for the day to be tested.
[0226] Specifically, update the true value of the current prediction point and judge Is it equal to , if equal, then the load values of all the predicted points on the test day have been predicted, and the set of load prediction values for the test day can be obtained; if not equal, let , execute S104 to S105 to predict the next point to be predicted.
[0227] The present invention also provides a specific use embodiment, such as Figure 6 shown.
[0228] Step 1: Preprocess the collected load data. Collect the power load data of a cement plant in a certain area for 371 consecutive days from March 1, 2022 to March 6, 2023. First, preprocess the load data, mainly including removing invalid data and erroneous data, and filling missing values. There are 96 sampling data points per day, and the sampling interval is 15 minutes. After preprocessing, the load data contains 371 consecutive days. The load data of 371 days constitute the power load set ,in, It is The load data for the day contains the load values of 96 sampling points, expressed as ,in, Indicates Tiandi The load value of each sampling point.
[0229] Similarly, collect the average temperature corresponding to these 371 consecutive days , relative humidity , light irradiance and wind speed As feature data, 371 days of feature data constitute a feature data set ,in, Indicates The characteristic data of the day, ,in, Respectively represent Average temperature, relative humidity, light irradiance and wind speed of the day.
[0230] Combine load data and characteristic data to form the initial data set .
[0231] Step 2: For the data set obtained in step 1 , the Attention mechanism is integrated into the clustering algorithm, clustering analysis is performed on the load data, and corresponding load category labels are attached to the load data according to the clustering results to obtain a labeled data set .
[0232] Set the number of categories , select the attention weight coefficient , use the clustering algorithm with attention mechanism to get the membership matrix corresponding to the number of categories and cluster centers .exist In, when We can find the sample by The column index value corresponding to the maximum membership degree is used to determine the label label of the clustering result. The value range of label is .
[0233] The silhouette coefficient is used to evaluate the clustering effect. And the load category label obtained by clustering calculates the number of categories The corresponding silhouette coefficient is obtained from the experimental results. , the power load set silhouette coefficient is closest to 1, and the result is 0.5276, which means that when the load is divided into 2 categories, the clustering effect is the best. Then 2 is selected as the best number of categories, and the corresponding cluster center and membership matrix are the best cluster centers. and the optimal membership matrix .
[0234] For the best number of classifications and clustering results, give the data set Adding Load Category Labels ,in Representative Samples The category label is , then we can get a data set containing load value data, characteristic data and load category labels , specifically expressed as:
[0235]
[0236] Draw two cluster centers and samples belonging to two categories, such as Figure 3 and Figure 4 As shown, the red dotted line is the category center and the black curve is the sample belonging to this category.
[0237] Step 3: Train two load forecasting models based on convolutional neural networks. For the dataset with load category labels obtained in step 2 According to the two load categories, the data with the same category label are divided into the same data set, and the feature data and load category labels are removed. At this time, the power load set is still constructed by day. One load data contains the load values of 96 points in one day. Now the load value of a single sampling point is used as a load data, and the four feature data of 96 sampling points every day are collected to reconstruct the data set and obtain the data set. , , for these two data sets, two load forecasting models are established , .
[0238] Reading the dataset The data in Indicates that the load category label is Datasets, Normalize the data, divide the data set into training set and test set in a ratio of 3:1, select mean square error as the loss function, select Adam as the optimization algorithm, predict the current load value with the load value and characteristic data of the previous 20 sampling points, input the training set data into the convolutional neural network model training, and obtain the convolutional neural network load forecasting model , input the test set data into the model to get the predicted value, compare the true value and the predicted value, and get the mean absolute percentage error MAPE, which is expressed as:
[0239]
[0240] in, is the number of predicted load values, For the The actual value of the load, For the The load prediction value is obtained through experiments. The MAPE in is 0.056, The MAPE in is 0.054.
[0241] Step 4: Use the long short-term memory network to build a load category prediction model. For the data set with load category labels obtained in step 2, use the feature data and load category labels to build a long short-term memory network load category prediction model. .
[0242] Read The data in the dataset was deleted, the load data was deleted, the retained feature data and load category label data were normalized, the training set and the test set were divided into training set and test set according to the ratio of 3:1, the input dimension of the long short-term memory network model was set to 5, the number of hidden layer nodes was 12, the output dimension was 1, the batch size was 128, one hidden layer and one fully connected layer were set, the mean square error was selected as the loss function, the Adam algorithm was used as the optimization algorithm, the average temperature, relative humidity, light irradiance, wind speed and load category data of the 10 days before the target day were used to predict the load category of the target day, and the training set data was input to train the load category prediction model. , use the test set to verify the model prediction effect. The model output value is a decimal between 0 and 1, and the prediction label is determined based on its size. Assume that the model outputs The result for the day is , then Day Category Forecast Label Given by the following rules:
[0243]
[0244] Compare the predicted labels of the test set with the true labels to obtain the model prediction accuracy. The experiment shows that the accuracy of using this model to predict load categories is 91.1%.
[0245] Step 5: The above steps are all carried out in blocks, and different forecasting models are constructed. Now we describe the entire load forecasting process. The entire load forecasting process adopts a rolling forecasting method. When the forecast day points to the first According to the following steps, predict the load value at each point.
[0246] (5.1) First use the load category prediction model obtained in step 4 , based on the average temperature, relative humidity, light irradiance, wind speed and load category of the 10 days before the forecast date. The load category of the day is obtained, and the forecast result is expressed as , called the Daily load category forecast value.
[0247] Now calculate the probability that the load category of the day belongs to the two categories respectively, and the sum of the probabilities belonging to each category is 1:
[0248]
[0249] in, The load category label for that day is The probability of .
[0250] if is exactly equal to 0 or 1, then when hour, ;when hour, .
[0251] if is neither 0 nor 1, then
[0252]
[0253] (5.2) Order , predict m Tiandi n The load value of a point.
[0254] (5.3) The load values, temperature, humidity, light irradiance and wind speed of the 20 points before the prediction point are respectively sent to the load prediction model , , we get the corresponding two load forecast values: ,in Indicates m Tiandi n Points in the model The load forecast value is obtained by weighting the load forecast value and the probability of the load category on that day to obtain the final load forecast value at that point. :
[0255]
[0256] (5.4) Before predicting the load value of the next point, update the real data of the current point.
[0257] (5.5)Judgment Is it equal to 96? If so, go to the next step. If not, set , and go to step (5.3).
[0258] (5.6) All real data for that day have been updated, and the data is sent to the clustering in step 2 to obtain the load category label for that day. Let , go to step (5.1).
[0259] In order to verify the results of the present invention, a control group was set up to verify the predicted effect of the present invention.
[0260] For the unclustered data set in step 1 , similarly convert the data set constructed in days into a data set constructed in sampling points , then it contains 35616 points, each of which contains five data points: load value, temperature, humidity, light irradiance and wind speed. Using the convolutional neural network with the same parameters as in step 3, the data is normalized and trained according to the training and testing ratio of 3:1 to obtain the load forecasting model , comparing the predicted value and the true value, we get a MAPE of 7.89%, while the MAPE predicted in step 5 is 6.75%. Plot the prediction results of the two methods for a certain day, such as Figure 5 As shown, the black solid line is the true value of the load, the blue long dashed line is the prediction result of step 5, and the red short dashed line is the result without category prediction. Direct prediction results: It can be seen that the prediction results obtained according to the steps of the present invention are closer to the true value.
[0261] The present invention adopts a clustering method to first distinguish the categories of load days, and integrates the attention mechanism into the clustering algorithm, which can dynamically adjust the membership degree according to the similarity between the data sample and the cluster center, and better capture the local characteristics and structural information of the data; when performing load forecasting, first predict the probability that the load of the day belongs to each category, and then perform weighted summation on the load forecast values obtained by each model to obtain the final load forecast value, thereby ultimately improving the load forecasting effect.
[0262] The present invention provides a short-term power load forecasting device based on an attention mechanism clustering model, the device comprising: a data acquisition module, a load category prediction module, a probability calculation module, a load prediction module, a load prediction value set acquisition module and an output module.
[0263] The data acquisition module is used to acquire an initial data set, wherein the initial data set includes: an average value of characteristic data of multiple days and a load label.
[0264] Load category prediction module, which is used to input the feature data average value and load label into the trained load category prediction model In the process, the load category is predicted to obtain the load category forecast value for the day to be predicted.
[0265] The probability calculation module is used to calculate the load category forecast value of the forecast day. The probability of each load category label in the load category labels is calculated to obtain the probability corresponding to the load category prediction value of the predicted day; wherein the sum of multiple probabilities is 1.
[0266] Load forecasting module, used to input known sampling point data into the trained In the load value prediction model, the corresponding load prediction values; among which, the known sampling point data include: power load and characteristic data.
[0267] Prediction value calculation module, used to use The load forecast value and the corresponding probability are weighted and calculated to obtain the load forecast value of the point to be predicted.
[0268] The load forecast value set acquisition module is used to determine the next point to be predicted and update the true value of the current prediction point, and then execute S104 to S105 to predict the next point to be predicted to obtain the load forecast value of the next point to be predicted, until the prediction is completed for all points to be predicted, and the load forecast value set for the day to be tested is obtained.
[0269] The devices or modules described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. For the convenience of description, the above devices are described in various modules according to their functions. When implementing the present invention, the functions of each module can be implemented in the same or multiple software and / or hardware. Of course, the module that implements a certain function can also be implemented by combining multiple sub-modules or sub-units.
[0270] The method, device or module described in the present invention can be implemented in a computer-readable program code. The controller can be implemented in any appropriate manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (English: Application Specific Integrated Circuit; Abbreviation: ASIC), a programmable logic controller and an embedded microcontroller. Examples of controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included in it for implementing various functions can also be regarded as structures within the hardware component. Or even, the means for realizing various functions may be regarded as both a software module for realizing the method and a structure within a hardware component.
[0271] Some modules in the apparatus of the present invention may be described in the general context of computer executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, classes, etc. that perform specific tasks or implement specific abstract data types. The present invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0272] The present invention provides a short-term power load forecasting server based on an attention mechanism clustering model, the server comprising a memory and a processor; the memory is used to store computer executable instructions; the processor is used to execute the computer executable instructions to implement a short-term power load forecasting method based on the attention mechanism clustering model.
[0273] The present invention provides a computer-readable storage medium having executable instructions. When a computer executes the executable instructions, a short-term power load forecasting method based on an attention mechanism clustering model can be implemented.
[0274] The above storage media include but are not limited to random access memory (RAM), read-only memory (ROM), cache, hard disk drive (HDD) or memory card. The memory can be used to store computer program instructions.
[0275] Although the present invention provides method operation steps as described in the embodiments or flowcharts, more or fewer operation steps may be included based on conventional or non-creative labor. The order of steps listed in this embodiment is only one way of executing the order of many steps and does not represent the only execution order. When the actual device or client product is executed, it can be executed in sequence or in parallel according to the method shown in this embodiment or the accompanying drawings (for example, in a parallel processor or multi-threaded processing environment).
[0276] It can be seen from the description of the above implementation methods that those skilled in the art can clearly understand that the present invention can be implemented by means of software plus necessary hardware. Based on such an understanding, the technical solution of the present invention, in essence or in other words, the part that contributes to the prior art, can be embodied in the form of a software product, or can be embodied in the implementation process of data migration. The computer software product can be stored in a storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for a computer device (which can be a personal computer, a mobile terminal, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention or certain parts of the embodiments.
[0277] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. All or part of the present invention can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, mobile communication terminals, multi-processor systems, microprocessor-based systems, programmable electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc.
[0278] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some or all of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the present invention.
Claims
1. A short-term power load forecasting method based on attention mechanism clustering mode, characterized in that: include: S101, obtain the initial data set and the trained load category prediction model M l and K b Load value prediction model M i ; wherein the initial data set includes: average values of characteristic data for multiple days and load labels; wherein the load value prediction model is trained to obtain a trained load value prediction model, including: The initial data set is preprocessed to obtain the data set D2 and the optimal classification number K b Specifically, the initial data set is preprocessed to obtain the data set D2 and the optimal classification number K b ,include: Using the initial data set, a power load set X and a feature data set F are obtained; Using the power load set X and the feature data set F, a data set D1 is obtained; wherein the data set D1 includes: the power load set X and the feature data set F; Set multiple number of categories K1, cluster the data set D1 using a clustering method that incorporates an attention mechanism and different number of categories, and obtain a membership matrix and a clustering center corresponding to each number of categories K1; respectively solve the maximum value of each row in the multiple membership matrices, and use the column index value corresponding to the maximum value to determine the load category label; Using the power load set X and the load category label, calculate the silhouette coefficient corresponding to each category number K1 to obtain multiple silhouette coefficients; Determine the number of categories K1 corresponding to the maximum value of the multiple silhouette coefficients as the optimal classification number K b , and with the optimal number of classifications K b The corresponding membership matrix and cluster center are the optimal membership matrix and the optimal cluster center; Adding the load category label to the data set D1 to obtain a data set D2; Specifically, the number of categories K1 is set, and the data set D1 is clustered according to the number of categories using a clustering method that incorporates an attention mechanism, so as to obtain a membership matrix and a clustering center corresponding to each number of categories K1, including: Obtaining an initialized membership matrix and initializing cluster centers using a K-means algorithm, and calculating the initialized cluster centers to obtain cluster centers c; Using the cluster center c, multiple distances d between each data in the power load set X and the cluster center c are calculated respectively. ij ; Using the exponential function and the plurality of distances d ij Calculate the attention weight matrix AW, and calculate the element aw in the attention weight matrix corresponding to each data in the power load set X ij ; Using the attention weight matrix AW, the cluster center c and the power load set X, the initialized membership matrix is updated to obtain an updated membership matrix; Using the membership matrix and the power load set X, the cluster center is updated to obtain an updated cluster center; Determine whether the difference between the updated membership matrix and the membership matrix is less than a first threshold; If yes, output the updated membership matrix and the updated cluster centers; if no, recalculate the attention weight matrix AW, the recalculated membership matrix and the recalculated cluster centers using the updated membership matrix and the updated cluster centers until the difference between the recalculated membership matrix and the updated membership matrix is less than the first threshold; S102: Input the feature data average value and the load label into the trained load category prediction model M. l In the process, the load category is predicted to obtain the load category prediction value of the day to be predicted; S103, respectively calculating the load category forecast value of the to-be-forecasted day belonging to K b The probability of each load category label in the load category labels is obtained to obtain the probability corresponding to the load category prediction value of the to-be-predicted day; wherein the sum of the multiple probabilities is 1; S104, input the known sampling point data into the trained K b In the load value prediction model, the corresponding K b A load prediction value; wherein the known sampling point data includes: power load, characteristic data; S105, using the K b The load forecast value and the corresponding probability are weighted to obtain the load forecast value of the point to be forecasted; S106, determine the next point to be predicted, and update the true value of the current prediction point, then execute S104 to S105 to predict the next point to be predicted, and obtain the load prediction value of the next point to be predicted, until all points to be predicted are predicted, and obtain the set of load prediction values for the day to be tested.
2. The short-term power load forecasting method based on the attention mechanism clustering model according to claim 1 is characterized in that: The load category prediction model M l Perform training to obtain the trained load category prediction model M l ,include: The initial data set is preprocessed to obtain the data set D2 and the optimal classification number K b ; Using the optimal number of classifications K b Get the corresponding K b load category labels and use the K b load category labels and long short-term memory network to build a load category prediction model M l ; Acquire the data in the data set D2, and process the data to obtain a data set D3; wherein the data set D3 includes: the characteristic data and the load category label; Normalizing the data set D3 to obtain a normalized data set D3; Set the time step to divide the normalized data set D3 to obtain the training set X t ' rain , Y tr ' ain and the test set X t ' est , Y t ' est ; The training set X t ' rain , Y tr ' ain Input into the data loader to get the training data loader train l ' oader , the test set X t ' est , Y t ' est Input into the data loader to get the test data loader test l ' oader ; Build a long short-term memory network model and set the optimal loss and number of training times; Set the long short-term memory network model to training mode, and use the training data loader train l ' oader , the training set X t ' rain , Y tr ' ain The load category prediction model M l The parameters are updated to obtain an updated short-term memory network model; Set the LSTM network model to evaluation mode and use the test data loader test l ' oader , the test set X t ' est , Y t ' est The load category prediction model M l The parameters are evaluated to obtain the evaluation results; Determine a minimum value between the evaluation result and the optimal loss, and determine the minimum value as the optimal loss; The parameters of the long short-term memory network model are repeatedly updated according to the number of training times to obtain the trained load category prediction model M l .
3. The short-term power load forecasting method based on the attention mechanism clustering model according to claim 1 is characterized in that: The load value prediction model is trained to obtain a trained load value prediction model, including: The initial data set is preprocessed to obtain the data set D2 and the optimal classification number K b ; Using the optimal number of classifications K b The corresponding K b load category labels, and divide the data with the same load category labels in the data set D2 into the same data set to obtain K b a first data set; wherein the first data set is a data set constructed on a daily basis; The K b The first data set is K, and the load category label is removed. b revise the first dataset and K b The revised first dataset is converted to K b The second data set, K b The second data set is a data set including the power load of each sampling point and the characteristic data; Get the K b The data in the second data set are normalized to obtain K b Normalized data; The data set D2 is processed using the normalized data, time step and number of features to obtain a training set X train , Y train and the test set X test , Y test ; Input the data in the training set into a data loader to obtain a training data loader, and input the data in the test set into a data loader to obtain a test data loader; Constructed with the K b The K corresponding to the second dataset b Load value prediction model M i , and set the loss function; The load value prediction model is trained using the training data, the test data and the loss function to obtain a trained load value prediction model M. i .
4. The short-term power load forecasting method based on the attention mechanism clustering model according to claim 2 is characterized in that: The long short-term memory network model includes: a hidden layer and a fully connected layer, and the output dimension of the long short-term memory network model is 1.
5. A short-term power load forecasting device based on attention mechanism clustering mode, characterized in that: include: A data acquisition module, used to acquire an initial data set; The initial data set includes: average values of characteristic data of multiple days and load labels; wherein the load value prediction model is trained to obtain a trained load value prediction model, including: The initial data set is preprocessed to obtain the data set D2 and the optimal classification number K b Specifically, the initial data set is preprocessed to obtain the data set D2 and the optimal classification number K b ,include: Using the initial data set, a power load set X and a feature data set F are obtained; Using the power load set X and the feature data set F, a data set D1 is obtained; wherein the data set D1 includes: the power load set X and the feature data set F; Set multiple number of categories K1, cluster the data set D1 using a clustering method that incorporates an attention mechanism and different number of categories, and obtain a membership matrix and a clustering center corresponding to each number of categories K1; respectively solve the maximum value of each row in the multiple membership matrices, and use the column index value corresponding to the maximum value to determine the load category label; Using the power load set X and the load category label, calculate the silhouette coefficient corresponding to each category number K1 to obtain multiple silhouette coefficients; Determine the number of categories K1 corresponding to the maximum value of the multiple silhouette coefficients as the optimal classification number K b , and with the optimal number of classifications K b The corresponding membership matrix and cluster center are the optimal membership matrix and the optimal cluster center; Adding the load category label to the data set D1 to obtain a data set D2; Specifically, the number of categories K1 is set, and the data set D1 is clustered according to the number of categories using a clustering method that incorporates an attention mechanism, so as to obtain a membership matrix and a clustering center corresponding to each number of categories K1, including: Obtaining an initialized membership matrix and initializing cluster centers using a K-means algorithm, and calculating the initialized cluster centers to obtain cluster centers c; Using the cluster center c, multiple distances d between each data in the power load set X and the cluster center c are calculated respectively. ij ; Using the exponential function and the plurality of distances d ij Calculate the attention weight matrix AW, and calculate the element aw in the attention weight matrix corresponding to each data in the power load set X ij ; Using the attention weight matrix AW, the cluster center c and the power load set X, the initialized membership matrix is updated to obtain an updated membership matrix; Using the membership matrix and the power load set X, the cluster center is updated to obtain an updated cluster center; Determine whether the difference between the updated membership matrix and the membership matrix is less than a first threshold; If yes, output the updated membership matrix and the updated cluster centers; if no, recalculate the attention weight matrix AW, the recalculated membership matrix and the recalculated cluster centers using the updated membership matrix and the updated cluster centers until the difference between the recalculated membership matrix and the updated membership matrix is less than the first threshold; A load category prediction module is used to input the characteristic data average value and the load label into the trained load category prediction model M l In the process, the load category is predicted to obtain the load category prediction value of the day to be predicted; The probability calculation module is used to calculate the load category forecast value of the predicted day belonging to K b The probability of each load category label in the load category labels is obtained to obtain the probability corresponding to the load category prediction value of the to-be-predicted day; wherein the sum of the multiple probabilities is 1; The load forecasting module is used to input the known sampling point data into the trained K b In the load value prediction model, the corresponding K b A load prediction value; wherein the known sampling point data includes: power load, characteristic data; A prediction value calculation module is used to use the K b The load forecast value and the corresponding probability are weighted to obtain the load forecast value of the point to be forecasted; The load forecast value set acquisition module is used to determine the next point to be predicted and update the true value of the current prediction point, and then execute S104 to S105 to predict the next point to be predicted to obtain the load forecast value of the next point to be predicted, until the prediction is completed for all points to be predicted, and the load forecast value set for the day to be tested is obtained.
6. A short-term power load forecasting server based on attention mechanism clustering mode, characterized in that: including memory and processor; The memory is used to store computer executable instructions; The processor is used to execute the computer executable instructions to implement the short-term power load forecasting method based on the attention mechanism clustering model as described in any one of claims 1-4.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium has executable instructions, and when the computer executes the executable instructions, it can implement the short-term power load forecasting method based on the attention mechanism clustering model as described in any one of claims 1-4.
Citation Information
Patent Citations
Short-term Load Forecasting Method Based on TCN and IPSO-LSSVM Combined Model
AU2020104000A4
Cyclic neural network short-period load predication method based on information entropy clustering and attenuation mechanism
CN107590567A