Data prediction method based on local mean decomposition and SMA-Transformer
Through the combined method of local mean decomposition and SMA-Transformer, the problems of insufficient data dependence and high model complexity in household change relationship time series prediction are solved, and a more efficient and robust prediction effect is achieved.
Patent Information
- Application Number
- CN202410811078.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-10-22
AI Technical Summary
The existing technology has insufficient data dependence, high model complexity, and over-fitting problems in household-to-household change relationship timing prediction, making it difficult to maintain prediction accuracy and robustness when the power supply relationship is unstable.
A data prediction method based on local mean decomposition (LMD) and SMA-Transformer is used to decompose complex signals into product function components through LMD, and use SMA to optimize the parameters of the Transformer neural network for prediction.
It improves prediction accuracy and robustness, reduces computational costs, reduces data requirements, avoids overfitting, and enhances the ability to capture time series data patterns.
Smart Images

Figure CN118825979A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of time series prediction, and in particular relates to a data prediction method based on local mean decomposition and SMA-Transformer. Background Art
[0002] The relationship between household transformers in active low-voltage distribution networks refers to the process of reducing the electric energy of high-voltage power grids to low-voltage power through transformers in the power distribution network system, and then transferring it to the indoor electrical equipment in the community or a single building. In actual operation, it is very important to accurately predict the relationship between household transformers. When performing time series prediction on the relationship data of household transformers in active low-voltage distribution networks, the prediction methods can usually be divided into three categories: data-driven, model-driven, and hybrid methods. The data-driven method relies on historical consumption patterns and statistical principles, and uses time series, regression, and clustering methods to predict short-term power supply relationships in the future; the model-driven method, based on the physical laws of the power grid, combines load and line models, and reveals the relationship between power consumption behavior and power supply. Provides a framework; the hybrid method combines the advantages of the above two approaches, using machine learning techniques such as decision trees, random forests, and neural networks to identify patterns from historical data, while considering physical models, thereby enhancing the accuracy and robustness of predictions.
[0003] Each method has its shortcomings. The data-driven method is highly dependent on data integrity and is easily hindered by data loss and anomalies. The prediction effect will be weakened when the power supply relationship is unstable. The modeling process of the model-driven method is complex and computationally expensive, and the model may not be complete. Although the hybrid method can parse patterns in big data, it requires a large amount of data input and faces challenges in model interpretability and parameter tuning, and the problem of overfitting needs to be avoided. Therefore, it is necessary to design a data prediction method based on local mean decomposition and SMA-Transformer to solve the above problems. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a data prediction method based on local mean decomposition and SMA-Transformer, which aims to accurately dispatch energy, improve energy efficiency and reduce emissions, and encourage users to participate in energy management through intelligent fault detection and rapid response, thereby further promoting the development of intelligent control systems.
[0005] In order to achieve the above technical effects, the technical solution adopted by the present invention is:
[0006] A data prediction method based on local mean decomposition and SMA-Transformer includes the following steps:
[0007] S1, collect the data required for Transformer model construction and build a dataset;
[0008] S2, performing local mean LMD decomposition on the active low-voltage distribution network household-to-transformer relationship data processed in step S1, decomposing it into multiple performance function PF components;
[0009] The LMD signal decomposition algorithm can adaptively decompose complex non-stationary signals into a series of product functions (PF). In this algorithm, each product function has a clear physical meaning, where the envelope signal represents the instantaneous amplitude function, and the pure frequency modulation signal can be used to obtain the instantaneous frequency. Through the LMD algorithm, complex non-stationary signals can be decomposed into these product functions PF with clear physical meanings.
[0010] S3, using the slime mold optimization algorithm SMA to find the optimal parameters of the Transformer neural network. By using SMA to iteratively optimize, after reaching the number of iterations, the optimal parameters at this time are used as the initial weights and thresholds of the Transformer neural network;
[0011] S4, using Transformer to separately predict each PF component obtained in step S2, and superimposing each predicted value to obtain a predicted value.
[0012] Preferably, in step S1, collecting data required for model construction and constructing a data set includes:
[0013] S101, collects the household transformer relationship data of the active low-voltage distribution network, including household transformer capacity, power type and power consumption; and performs data cleaning and deduplication to ensure the accuracy and completeness of the data;
[0014] Data cleaning includes identifying and processing errors, incompleteness and inaccuracy in the data. Processing includes processing missing values, outliers, correcting incorrect data formats and processing duplicate data. For missing values, fill, delete or interpolate them; for outliers, judge and process them through statistical analysis.
[0015] Data deduplication involves identifying and removing duplicate records in a data set to ensure that each record in the data set is unique. Duplicate records may interfere with data analysis and modeling.
[0016] S102, importing the cleaned and deduplicated data into an Excel file according to a predefined data field structure, and normalizing and standardizing the data format;
[0017] S103, time-encoding the data imported in step S102, adding a timestamp to the active low-voltage distribution network user-to-user relationship data as input for the subsequent Transformer neural network;
[0018] S1031, Timestamp Conversion:
[0019] For each timestamp, convert it into a Unix timestamp in seconds; extract the timestamp from the acquired active low-voltage distribution network user-to-user relationship data, for example, each second since January 1, 2020 represents the time;
[0020] S1032, relative time coding: for each time point, calculate the time interval between it and the starting time point in the data set, take k minutes as a time unit, and represent each time point as the number of k minutes relative to the starting time as the input of the relative time coding; k minutes is preferably 15 minutes;
[0021] S104, obtaining active low-voltage distribution network household-transformer relationship data with time coding information, and completing the data set construction.
[0022] Preferably, in step S2, the step of performing local mean LMD decomposition on the active low-voltage distribution network household-transformer relationship data processed in step S1 includes:
[0023] S201, taking the active low-voltage distribution network household transformer relationship data as the input signal x(t), and calculating its mean function m 11 (t):
[0024] Analyze the input signal x(t) and calculate all the extreme points p it contains i ,i=1,2,...,N;
[0025] Calculate the mean sequence m of the input signal x(t) i , the formula is as follows:
[0026]
[0027] In the formula, p i represents the extreme point, p i+1 Indicates the next extreme point;
[0028] The mean sequence m is calculated by the sliding average method. i The constructed curve is smoothed to obtain the mean function m of the input signal x(t) 11 (t);
[0029] S202, calculating the envelope estimation function a of the input signal x(t) 11 (t):
[0030] Calculate the envelope estimate a of the input signal x(t) i :
[0031]
[0032] The envelope estimate a is calculated by the moving average method i The curve is smoothed to obtain the envelope estimation function a of the input signal x(t) 11 (t);
[0033] S203, subtract the mean function m from the input signal x(t) 11 (t), and obtain the difference signal h of its input signal x(t) 11 (t):
[0034] h 11 (t) = x(t) - m 11 (t);
[0035] In the formula, m 11 (t) calculated by step S201;
[0036] S204, calculating the pure frequency modulation signal s of the input signal x(t) 1j (t):
[0037] For the difference signal h 11 (t) is subjected to amplitude demodulation processing to obtain s 11 (t):
[0038]
[0039] In the formula, h 11 (t) and a 11 (t) calculated by step S203 and step S202;
[0040] Repeat the above steps and set s 11 (t) is used as the input signal x(t) in step S201, and is set to x1(t). Steps S201 to S203 are repeated until the whole process is performed j times. When the envelope function a obtained in step S202 is 1j When (t) = 1, the pure FM signal s is calculated. 1j (t);
[0041] S205, the envelope estimation function a calculated in step S202 is 11 (t) to obtain the amplitude function A1(t) of the input signal x(t):
[0042]
[0043] In the formula, a 1n (t) represents the envelope estimation function calculated at the jth iteration;
[0044] S206, calculate the first PF component F1(t) of the input signal x(t):
[0045] F1(t)=a1(t)*s 1j (t);
[0046] S207, calculate the first residual component u1(t) of the input signal x(t):
[0047] u1(t)=x(t)-F1(t);
[0048] S208, calculate all L PF components of the input signal x(t), set X(t) = u1(t), use it as the input of step S201, and repeat steps S207 to S208 until N PF components are obtained, that is, F n (t), n = 1, 2, ..., N, and when the residual component U(t) is a monotonic function, the iteration is stopped. At this time, the input signal x(t) is:
[0049]
[0050] Among them, F n (t), n = 1, 2, ..., N represents the N PF components of the active low-voltage distribution network user-to-user relationship data after LMD decomposition;
[0051] S209, using the PF component obtained in step S208 as an input function of the subsequent network to perform prediction.
[0052] Preferably, in step S3, the SMA optimization algorithm is used to find the optimal parameters of the Transformer neural network, and the specific process is as follows:
[0053] S301, initialize the population and set the parameters of the optimization algorithm, such as the population size N, the maximum number of iterations max t ;
[0054] S302, calculating the fitness value of each individual in the population and sorting them;
[0055] S303, updating the position of the slime mold population and updating the weight;
[0056] S304, updating the optimal position and calculating the current optimal position according to the fitness value of the population;
[0057] S305, determine whether the optimal condition is currently met, and if so, output the optimal result; if not, return to step S302 to continue the iterative optimization process until the optimal condition is met, and output the optimal parameters corresponding to the Transformer neural network.
[0058] Preferably, in step S4, using Transformer to separately predict each PF component obtained in step S2, and superimposing each predicted value to obtain a predicted value includes:
[0059] S401, input representation: the active low-voltage distribution network user-to-transformer relationship data with time coding information processed in step S104 is segmented according to a fixed time window or sequence length to form an input sequence, and the data of each time step is used as an input vector;
[0060] S402, position encoding: position encoding is performed on each time step in the sequence processed in step S401 so that the model can distinguish the order relationship between different time steps. Position encoding can be performed in different ways, such as using a fixed formula to calculate the position encoding vector, or obtaining the position encoding through learning;
[0061] S403, encoder-decoder structure: Construct the encoder-decoder structure of the Transformer model. The encoder part is responsible for encoding and abstractly representing the sequence in step S402, and the decoder part is responsible for converting the encoded representation into a predicted output. This structure allows the model to learn long-term dependencies in time series data;
[0062] S404, self-attention calculation: The self-attention mechanism is used in the encoder and decoder to calculate the correlation between the representation of each time step and other time steps. The self-attention mechanism helps the model capture the dependencies and important patterns between different time steps in the input sequence;
[0063] S405, decoder prediction: In the decoder, known historical data and context information are used in combination with the context vector calculated by self-attention to perform time series prediction. The prediction results of several future time steps can be obtained through the prediction output of the decoder;
[0064] S406, training and optimization: using the data processed in step S403 to train the model, and optimizing the model parameters through the SMA optimization algorithm in step S3, so that the model can perform time series prediction more accurately;
[0065] S407, compare the predicted value P with the true value Z, use the mean absolute percentage error (MAPE) as the error function, and output the predicted value when the error reaches the threshold. The formula is as follows:
[0066]
[0067] In the formula, P represents the predicted value and Z represents the true value.
[0068] The beneficial effects of the data prediction method based on local mean decomposition and SMA-Transformer provided by the present invention are as follows:
[0069] 1. In the data decomposition stage, the LMD algorithm is used to adaptively decompose the active low-voltage distribution network household transformer relationship data into a series of product function PF components, which can effectively solve the influence of sub-stationary signals;
[0070] 2. In the prediction stage, the Transformer network with good time series prediction performance is selected. The advantage of Transformer in time series prediction is that it can handle long-term dependencies, has global perception ability, and has strong parallel computing capabilities, which enables it to more effectively capture the laws and patterns in time series data and improve prediction accuracy;
[0071] 3. The SMA global optimization algorithm is selected, which is an optimization algorithm developed based on the behavioral characteristics of slime mold in finding food. It simulates the behavior of slime mold in the process of finding food, has excellent global optimization ability, and effectively prevents falling into local optimality. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 It is the overall process framework of the present invention;
[0073] Figure 2 is a flow chart of the LMD decomposition algorithm in the present invention;
[0074] Figure 3 This is a flow chart of the SMA optimization algorithm in an embodiment of the present invention;
[0075] Figure 4 It is a diagram of the Transformer process in an embodiment of the present invention;
[0076] Figure 5 Schematic diagram of the attention mechanism of the Transformer architecture in an embodiment of the present invention;
[0077] Figure 6 Schematic diagram of causal convolution of the Transformer architecture in an embodiment of the present invention;
[0078] Figure 7 Schematic diagram of dilated convolution of the Transformer architecture in an embodiment of the present invention. DETAILED DESCRIPTION
[0079] Embodiment 1:
[0080] like Figure 1 As shown, a data prediction method based on local mean decomposition and SMA-Transformer includes the following steps:
[0081] S1, collect the data required for Transformer model construction and build a dataset;
[0082] S2, performing local mean LMD decomposition on the active low-voltage distribution network household-to-transformer relationship data processed in step S1, decomposing it into multiple performance function PF components;
[0083] The LMD signal decomposition algorithm can adaptively decompose complex non-stationary signals into a series of product functions (PF). In this algorithm, each product function has a clear physical meaning, where the envelope signal represents the instantaneous amplitude function, and the pure frequency modulation signal can be used to obtain the instantaneous frequency. Through the LMD algorithm, complex non-stationary signals can be decomposed into these product functions PF with clear physical meanings.
[0084] S3, using the slime mold optimization algorithm SMA to find the optimal parameters of the Transformer neural network. By using SMA to iteratively optimize, after reaching the number of iterations, the optimal parameters at this time are used as the initial weights and thresholds of the Transformer neural network;
[0085] S4, using Transformer to separately predict each PF component obtained in step S2, and superimposing each predicted value to obtain a predicted value.
[0086] Preferably, in step S1, collecting data required for model construction and constructing a data set includes:
[0087] S101, collects the household transformer relationship data of the active low-voltage distribution network, including household transformer capacity, power type and power consumption; and performs data cleaning and deduplication to ensure the accuracy and completeness of the data;
[0088] Data cleaning includes identifying and processing errors, incompleteness and inaccuracy in the data. Processing includes processing missing values, outliers, correcting incorrect data formats and processing duplicate data. For missing values, fill, delete or interpolate them; for outliers, judge and process them through statistical analysis.
[0089] Data deduplication involves identifying and removing duplicate records in a data set to ensure that each record in the data set is unique. Duplicate records may interfere with data analysis and modeling.
[0090] S102, importing the cleaned and deduplicated data into an Excel file according to a predefined data field structure, and normalizing and standardizing the data format;
[0091] S103, time-encoding the data imported in step S102, adding a timestamp to the active low-voltage distribution network user-to-user relationship data as input for the subsequent Transformer neural network;
[0092] S1031, Timestamp Conversion:
[0093] For each timestamp, convert it into a Unix timestamp in seconds; extract the timestamp from the acquired active low-voltage distribution network user-to-user relationship data, for example, each second since January 1, 2020 represents the time;
[0094] S1032, relative time coding: for each time point, calculate the time interval between it and the starting time point in the data set, take k minutes as a time unit, and represent each time point as the number of k minutes relative to the starting time as the input of the relative time coding; k minutes is preferably 15 minutes;
[0095] S104, obtaining active low-voltage distribution network household-transformer relationship data with time coding information, and completing the data set construction.
[0096] like Figure 2 As shown, preferably, in step S2, the step of performing local mean LMD decomposition on the active low-voltage distribution network household-transformer relationship data processed in step S1 includes:
[0097] S201, taking the active low-voltage distribution network household transformer relationship data as the input signal x(t), and calculating its mean function m 11 (t):
[0098] Analyze the input signal x(t) and calculate all the extreme points p it contains i ,i=1,2,...,N;
[0099] Calculate the mean sequence m of the input signal x(t) i , the formula is as follows:
[0100]
[0101] In the formula, p i represents the extreme point, p i+1 Indicates the next extreme point;
[0102] The mean sequence m is calculated by the sliding average method. i The constructed curve is smoothed to obtain the mean function m of the input signal x(t) 11 (t);
[0103] S202, calculating the envelope estimation function a of the input signal x(t) 11 (t):
[0104] Calculate the envelope estimate a of the input signal x(t) i :
[0105]
[0106] The envelope estimate a is calculated by the moving average method i The curve is smoothed to obtain the envelope estimation function a of the input signal x(t) 11 (t);
[0107] S203, subtract the mean function m from the input signal x(t) 11 (t), and obtain the difference signal h of its input signal x(t) 11 (t):
[0108] h 11 (t) = x(t) - m 11 (t);
[0109] In the formula, m 11 (t) calculated by step S201;
[0110] S204, calculating the pure frequency modulation signal s of the input signal x(t) 1j (t):
[0111] For the difference signal h 11 (t) is subjected to amplitude demodulation processing to obtain s 11 (t):
[0112]
[0113] In the formula, h 11 (t) and a 11 (t) calculated by step S203 and step S202;
[0114] Repeat the above steps and set s 11 (t) is used as the input signal x(t) in step S201, and is set to x1(t). Steps S201 to S203 are repeated until the whole process is performed j times. When the envelope function a obtained in step S202 is 1j When (t) = 1, the pure FM signal s is calculated. 1j (t);
[0115] S205, the envelope estimation function a calculated in step S202 is 11 (t) to obtain the amplitude function A1(t) of the input signal x(t):
[0116]
[0117] In the formula, a 1n(t) represents the envelope estimation function calculated at the jth iteration;
[0118] S206, calculate the first PF component F1(t) of the input signal x(t):
[0119] F1(t)=a1(t)*s 1j (t);
[0120] S207, calculate the first residual component u1(t) of the input signal x(t):
[0121] u1(t)=x(t)-F1(t);
[0122] S208, calculate all L PF components of the input signal x(t), set X(t) = u1(t), use it as the input of step S201, and repeat steps S207 to S208 until N PF components are obtained, that is, F n (t), n = 1, 2, ..., N, and when the residual component U(t) is a monotonic function, the iteration is stopped. At this time, the input signal x(t) is:
[0123]
[0124] Among them, F n (t), n = 1, 2, ..., N represents the N PF components of the active low-voltage distribution network user-to-user relationship data after LMD decomposition;
[0125] S209, using the PF component obtained in step S208 as an input function of the subsequent network to perform prediction.
[0126] Preferably, in step S3, the SMA optimization algorithm is used to find the optimal parameters of the Transformer neural network, and the specific process is as follows:
[0127] S301, initialize the population and set the parameters of the optimization algorithm, such as the population size N, the maximum number of iterations max t ;
[0128] S302, calculating the fitness value of each individual in the population and sorting them;
[0129] S303, updating the position of the slime mold population and updating the weight;
[0130] S304, updating the optimal position and calculating the current optimal position according to the fitness value of the population;
[0131] S305, determine whether the optimal condition is currently met, and if so, output the optimal result; if not, return to step S302 to continue the iterative optimization process until the optimal condition is met, and output the optimal parameters corresponding to the Transformer neural network.
[0132] Preferably, in step S4, using Transformer to separately predict each PF component obtained in step S2, and superimposing each predicted value to obtain a predicted value includes:
[0133] S401, input representation: the active low-voltage distribution network user-to-transformer relationship data with time coding information processed in step S104 is segmented according to a fixed time window or sequence length to form an input sequence, and the data of each time step is used as an input vector;
[0134] S402, position encoding: position encoding is performed on each time step in the sequence processed in step S401 so that the model can distinguish the order relationship between different time steps. Position encoding can be performed in different ways, such as using a fixed formula to calculate the position encoding vector, or obtaining the position encoding through learning;
[0135] S403, encoder-decoder structure: Construct the encoder-decoder structure of the Transformer model. The encoder part is responsible for encoding and abstractly representing the sequence in step S402, and the decoder part is responsible for converting the encoded representation into a predicted output. This structure allows the model to learn long-term dependencies in time series data;
[0136] S404, self-attention calculation: The self-attention mechanism is used in the encoder and decoder to calculate the correlation between the representation of each time step and other time steps. The self-attention mechanism helps the model capture the dependencies and important patterns between different time steps in the input sequence;
[0137] S405, decoder prediction: In the decoder, known historical data and context information are used in combination with the context vector calculated by self-attention to perform time series prediction. The prediction results of several future time steps can be obtained through the prediction output of the decoder;
[0138] S406, training and optimization: using the data processed in step S403 to train the model, and optimizing the model parameters through the SMA optimization algorithm in step S3, so that the model can perform time series prediction more accurately;
[0139] S407, compare the predicted value P with the true value Z, use the mean absolute percentage error (MAPE) as the error function, and output the predicted value when the error reaches the threshold. The formula is as follows:
[0140]
[0141] In the formula, P represents the predicted value and Z represents the true value.
[0142] Embodiment 2:
[0143] like Figure 3 As shown, in step S3, the specific steps of finding the optimal parameters of the Transformer neural network through the SMA algorithm are:
[0144] SMA is an optimization algorithm developed based on the behavioral characteristics of slime molds in finding food. It simulates the behavior of slime molds in the process of finding food, including oscillation, contraction, and the formation of venous networks. The SMA algorithm simulates these biological behaviors to find the optimal solution to the problem. The characteristics of the algorithm include parallel search for multiple potential solutions and exploration of unknown areas. It is a bio-inspired optimization algorithm. Its process includes the slime mold approaching the food stage, surrounding the food stage, and capturing the food stage:
[0145] Slime mold approaches food stage: The weight of the search area is proportional to the surrounding food concentration. When the food concentration does not meet the standard, the weight of the area will decrease, resulting in a shift to other areas for search. The formula for position update of the slime mold approaching food stage is as follows:
[0146]
[0147] Among them, v b is a random parameter in the range [-α,α], and the value of α is shown in formula (2); v c is a random parameter that decreases linearly from 1 to 0 in the range [0,1]; r is a random parameter in the range [0,1]; p is the maximum limit number, and its value is shown in formula (3); t represents the current number of iterations; X t is the current optimal position; W is the weight, and its weight update formula is shown in formula (4); X A (t) and X B (t) is the random slime mold position;
[0148]
[0149] Among them, max t is the maximum number of iterations;
[0150] p=tanh|S(i)-DF|,i∈1,2,...,n; (3)
[0151] Where S(i) represents the fitness of X, and DF represents the best fitness obtained in all iterations;
[0152]
[0153] Among them, b F represents the optimal fitness obtained in the current iteration process, w F Indicates the worst fitness value obtained in the current iteration; condition is that S(i) is the individual in the first half of the population, i = N / 2, SmellIndex represents the sorted fitness value sequence, which is arranged in ascending order in the minimum value problem, and its formula is as follows:
[0154] SmellIndex = sort(S); (5)
[0155] Surrounding food stage: The surrounding food stage simulates the positive and negative feedback of the slime mold vein organization. The higher the food concentration searched by the slime mold vein, the stronger its oscillation, the faster the cytoplasm flows, and the thicker the vein. The formula for position update in the slime mold surrounding food stage is as follows:
[0156]
[0157] Among them, rand and z are random values in the range [0,1]; UB and LB represent the upper and lower limits of the search range respectively; z is the transition probability, indicating whether the slime mold searches for the best individual or other food sources, and p is the same as above, indicating the maximum limit number;
[0158] Food Capture Phase: The food capture phase is also called the oscillation phase. b and v c It shows the behavior of slime mold capturing food. The oscillation frequency of slime mold changes with the food concentration. The lower the food concentration, the lower the oscillation frequency of slime mold and the slower it approaches the food. When slime mold surrounds the best food source, it increases its oscillation frequency and accelerates the surrounding of food. Mathematically, as the iteration proceeds, v b It oscillates in the value range [-α,α] and gradually approaches 0, v c It oscillates between [-1,1] and gradually approaches 0.
[0159] Embodiment three:
[0160] like Figure 4 As shown in Figure 1, Transformer is a neural network architecture based on the attention mechanism, which is suitable for time series forecasting tasks, such as load forecasting. Its attention mechanism and encoder-decoder structure enable it to capture long-term dependencies and complex associations in time series data, thereby improving forecasting accuracy. Transformer has the following characteristics:
[0161] (1) Attention mechanism: The attention mechanism of Transformer is one of its key features, which allows the model to focus on information at different positions in the input sequence when processing sequence data. Through the self-attention mechanism, Transformer is able to calculate the importance of each input position to the current position, which is different from the traditional recurrent neural network RNN and convolutional neural network CNN. In this way, the model is able to consider all positions in the input sequence at the same time, thereby better capturing long-distance dependencies and global information in the sequence. This ability enables Transformer to perform well in natural language processing tasks and time series prediction tasks. Transformer uses a multi-head attention mechanism, generally stacking multiple attention units side by side to improve the generalization ability of its network. Its schematic diagram is as follows: Figure 5 shown.
[0162] In the figure, Query: a vector used to calculate the attention score, which is a representation of the current position and is used to find information related to the current position; Key: used to determine which values are most relevant to the query vector at the current position, thereby determining the focus of attention. The Key vector encodes the position information in the input sequence, which helps to determine the correlation between different positions; Value: contains the numerical information related to each key, which is used as the basis for weighted summation to calculate the final context representation.
[0163] (2) Vector Mapping: An important step in Transformer is vector mapping, which usually includes mapping the input vector to query, key, and value vectors, and mapping the context vector after self-attention calculation to the output vector. First, each position in the input sequence is linearly mapped to obtain query, key, and value vectors. Then, these vectors are multiplied by the weight matrix and processed by the activation function to map the original input vector to a higher-dimensional representation space, so that more complex association calculations can be performed in the self-attention mechanism.
[0164] (3) Temporal convolution: Transformer uses temporal convolution, which combines causal convolution and dilated convolution. Causal convolution limits the unidirectional correlation between input data and output data, while dilated convolution increases the receptive field of the convolution kernel, reduces unnecessary connections, and obtains the ability to extract global features. Causal convolution is shown in the figure. Figure 6 As shown, the dilated convolution is shown in Figure 7 shown.
Claims
1. A data prediction method based on local mean decomposition and SMA-Transformer, characterized in that: The following steps are involved: S1, collect the data required for Transformer model construction and build a dataset; S2, performing local mean LMD decomposition on the active low-voltage distribution network household-to-transformer relationship data processed in step S1, decomposing it into multiple product function PF components; S3, using the slime mold optimization algorithm SMA to find the optimal parameters of the Transformer neural network. By using SMA to iteratively optimize, after reaching the number of iterations, the optimal parameters at this time are used as the initial weights and thresholds of the Transformer neural network; S4, using Transformer to separately predict each PF component obtained in step S2, and superimposing each predicted value to obtain a predicted value.
2. The data prediction method based on local mean decomposition and SMA-Transformer according to claim 1, characterized in that: In step S1, the data required for model construction is collected and the data set is constructed including: S101, collect the household transformer relationship data of the active low-voltage distribution network, including household transformer capacity, power type and power consumption; and perform data cleaning and deduplication; S102, importing the cleaned and deduplicated data into an Excel file according to a predefined data field structure, and normalizing and standardizing the data format; S103, time-encoding the data imported in step S102, adding a timestamp to the active low-voltage distribution network user-to-user relationship data as input for the subsequent Transformer neural network; S1031, Timestamp Conversion: For each timestamp, convert it to a Unix timestamp; S1032, relative time coding: for each time point, calculate the time interval between it and the starting time point in the data set, take k minutes as a time unit, and represent each time point as the number of k minutes relative to the starting time as the input of relative time coding; S104, obtaining active low-voltage distribution network household-transformer relationship data with time coding information, and completing the data set construction.
3. The data prediction method based on local mean decomposition and SMA-Transformer according to claim 1, characterized in that: In step S2, the step of performing local mean LMD decomposition on the active low-voltage distribution network household-transformer relationship data processed in step S1 includes: S201, taking the active low-voltage distribution network household transformer relationship data as the input signal x(t), and calculating its mean function m 11 (t): Analyze the input signal x(t) and calculate all the extreme points p it contains i ,i=1,2,...,N; Calculate the mean sequence m of the input signal x(t) i , the formula is as follows: In the formula, p i represents the extreme point, p i+1 Indicates the next extreme point; The mean sequence m is calculated by sliding average method. i The constructed curve is smoothed to obtain the mean function m of the input signal x(t) 11 (t); S202, calculating the envelope estimation function a of the input signal x(t) 11 (t): Calculate the envelope estimate a of the input signal x(t) i : The envelope estimate a is calculated by the moving average method i The curve is smoothed to obtain the envelope estimation function a of the input signal x(t) 11 (t); S203, subtract the mean function m from the input signal x(t) 11 (t), and obtain the difference signal h of its input signal x(t) 11 (t): h 11 (t)=x(t)-m 11 (t); In the formula, m 11 (t) calculated by step S201; S204, calculating the pure frequency modulation signal s of the input signal x(t) 1j (t): For the difference signal h 11 (t) is subjected to amplitude demodulation processing to obtain s 11 (t): In the formula, h 11 (t) and a 11 (t) calculated by step S203 and step S202; Repeat the above steps and set s 11 (t) is used as the input signal x(t) in step S201, and is set to x1(t). Steps S201 to S203 are repeated until the whole process is performed j times. When the envelope function a obtained in step S202 is 1j When (t) = 1, the pure FM signal s is calculated. 1j (t); S205, the envelope estimation function a calculated in step S202 is 11 (t) to obtain the amplitude function A1(t) of the input signal x(t): In the formula, a 1n (t) represents the envelope estimation function calculated at the jth iteration; S206, calculate the first PF component F1(t) of the input signal x(t): F1(t)=a1(t)*s 1j (t); S207, calculate the first residual component u1(t) of the input signal x(t): u1(t)=x(t)-F1(t); S208, calculate all L PF components of the input signal x(t), set X(t) = u1(t), use it as the input of step S201, and repeat steps S207 to S208 until N PF components are obtained, that is, F n (t), n = 1, 2, ..., N, and when the residual component U(t) is a monotonic function, the iteration is stopped. At this time, the input signal x(t) is: Among them, F n (t), n = 1, 2, ..., N represents the N PF components of the active low-voltage distribution network user-to-user relationship data after LMD decomposition; S209, using the PF component obtained in step S208 as an input function of the subsequent network to perform prediction.
4. The data prediction method based on local mean decomposition and SMA-Transformer according to claim 1, characterized in that: In step S3, the SMA optimization algorithm is used to find the optimal parameters of the Transformer neural network. The specific process is as follows: S301, initialize the population and set the parameters of the optimization algorithm, such as the population size N, the maximum number of iterations max t ; S302, calculating the fitness value of each individual in the population and sorting them; S303, updating the position of the slime mold population and updating the weight; S304, updating the optimal position and calculating the current optimal position according to the fitness value of the population; S305, determine whether the optimal condition is currently met, and if so, output the optimal result; if not, return to step S302 to continue the iterative optimization process until the optimal condition is met, and output the optimal parameters corresponding to the Transformer neural network.
5. The data prediction method based on local mean decomposition and SMA-Transformer according to claim 1, characterized in that: In step S4, each PF component obtained in step S2 is predicted separately using Transformer, and each predicted value is superimposed to obtain a predicted value including: S401, input representation: the active low-voltage distribution network user-to-transformer relationship data with time coding information processed in step S104 is segmented according to a fixed time window or sequence length to form an input sequence, and the data of each time step is used as an input vector; S402, position encoding: position encoding is performed on each time step in the sequence processed in step S401 so that the model can distinguish the order relationship between different time steps. Position encoding can be performed in different ways, such as using a fixed formula to calculate the position encoding vector, or obtaining the position encoding through learning; S403, encoder-decoder structure: Construct the encoder-decoder structure of the Transformer model. The encoder part is responsible for encoding and abstractly representing the sequence in step S402, and the decoder part is responsible for converting the encoded representation into a predicted output. This structure allows the model to learn long-term dependencies in time series data; S404, self-attention calculation: The self-attention mechanism is used in the encoder and decoder to calculate the correlation between the representation of each time step and other time steps. The self-attention mechanism helps the model capture the dependencies and important patterns between different time steps in the input sequence; S405, decoder prediction: In the decoder, known historical data and context information are used in combination with the context vector calculated by self-attention to perform time series prediction. The prediction results of several future time steps can be obtained through the prediction output of the decoder; S406, training and optimization: using the data processed in step S403 to train the model, and optimizing the model parameters through the SMA optimization algorithm in step S3, so that the model can perform time series prediction more accurately; S407, compare the predicted value P with the true value Z, use the mean absolute percentage error (MAPE) as the error function, and output the predicted value when the error reaches the threshold. The formula is as follows: In the formula, P represents the predicted value and Z represents the true value.
