Natural gas demand quantity prediction method, device, equipment and medium
By performing deduplication and noise reduction processing on natural gas data, and constructing sparsity evaluation and self-attention distillation mechanism formulas, a long sequence time series prediction model is generated, which solves the problem that existing technology is difficult to process high-dimensional, nonlinear time series data, and improves Improve the accuracy and stability of natural gas demand forecast.
Patent Information
- Application Number
- CN202410619812.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-17
- Publication Date
- 2024-08-30
AI Technical Summary
Existing natural gas demand forecasting methods are difficult to handle high-dimensional, nonlinear and complex time series data, resulting in inaccurate and unstable forecast results and requiring a large amount of manual parameter adjustment and domain knowledge.
Through data deduplication and noise reduction processing, the query vector sparsity evaluation formula, the probabilistic sparse self-attention formula and the self-attention distillation mechanism formula are constructed to generate a long sequence time series prediction model, and the model is used to encode and sparsely evaluate natural gas data. , distillation and decoding, and output the natural gas demand prediction results.
It improves the accuracy and stability of natural gas demand forecasting, reduces forecasting complexity, can adaptively select useful information from time series, does not require manual parameter adjustment and domain expertise, and has stronger generalization capabilities and robustness. .
Smart Images

Figure CN118569554A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of deep neural network technology, and in particular to a natural gas demand prediction method, device, equipment and medium. Background Art
[0002] The current natural gas demand forecasting methods are mainly based on traditional statistical models and empirical models, such as ARIMA (Autoregressive Integrated Moving Average Model), VAR (Vector autoregression), etc. These models have some shortcomings and deficiencies in data processing and model building: on the one hand, these methods can usually only handle some simple linear and stationary time series data models, and it is difficult to deal with high-dimensional, nonlinear and complex data features; on the other hand, these methods often need to rely on manual experience and domain knowledge for model parameter adjustment and feature extraction, so it takes a lot of time and effort. In addition, these methods often cannot handle noise and abnormal data well, and may have problems such as overfitting or underfitting, resulting in inaccurate and unstable forecasting results.
[0003] It can be seen from the above that how to process high-dimensional, nonlinear and complex time series data, improve the accuracy and stability of natural gas demand forecasting, and reduce the complexity of natural gas demand forecasting are problems to be solved in this field. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a natural gas demand forecasting method, device, equipment and medium, which can process high-dimensional, nonlinear and complex time series data, improve the accuracy and stability of natural gas demand forecasting, and reduce the complexity of natural gas demand forecasting. The specific scheme is as follows:
[0005] In a first aspect, the present application discloses a natural gas demand forecasting method, comprising:
[0006] Acquire natural gas data, and perform data deduplication and data noise reduction processing on the natural gas data to obtain processed natural gas data;
[0007] Construct a query vector sparsity evaluation formula, a probabilistic sparse self-attention formula, and a self-attention distillation mechanism formula, and generate a long sequence time series prediction model of natural gas demand based on the query vector sparsity evaluation formula, the probabilistic sparse self-attention formula, the self-attention distillation mechanism formula, and a decoder;
[0008] The long sequence time series prediction model is used to perform encoding operations, sparsity evaluation, distillation, data embedding and decoding operations on the processed natural gas data to output a natural gas demand prediction result.
[0009] Optionally, performing data deduplication and data noise reduction processing on the natural gas data to obtain the processed natural gas data includes:
[0010] Deduplication of the natural gas data to obtain deduplicated natural gas data;
[0011] Performing data denoising on the natural gas data after deduplication to obtain the natural gas data after denoising; wherein the data denoising includes data cleaning, data standardization processing and data outlier processing;
[0012] The natural gas data after noise reduction is processed by correlation array using the Pearson correlation coefficient method to obtain the processed natural gas data.
[0013] Optionally, construct a query vector sparsity evaluation formula, including:
[0014] Construct a query vector sparsity evaluation formula based on the query vector sparsity measurement formula and the relative entropy divergence formula;
[0015] The query vector sparsity measurement formula is:
[0016]
[0017] Among them, q i is the i-th row in the query vector matrix Q, k j is the jth row in the key vector matrix K, v j is the jth row in the value vector matrix V, k(q i , k j ) is an asymmetric exponential function, is the square root of the feature dimension, p(k j |q i ) is the attention probability distribution;
[0018] The relative entropy divergence formula includes a discrete random variable relative entropy divergence formula and a continuous random variable relative entropy divergence formula;
[0019] The discrete random variable relative entropy divergence formula is:
[0020]
[0021] Where D is the relative entropy, P(x) and Q(x) are the two probability distributions of the value of x;
[0022] The relative entropy divergence formula of the continuous random variable is:
[0023]
[0024] Optionally, the query vector sparsity evaluation formula is:
[0025]
[0026] Among them, q i is the i-th row in the query vector matrix, is the jth row in the transposed key vector matrix, L K is the length of the query vector, is the square root of the feature dimension.
[0027] Optionally, the probabilistic sparse self-attention formula is:
[0028]
[0029] Among them, Q is the query vector matrix, K is the key vector matrix, and Softmax is the conversion of normalized similarity scores into attention weights. is a sparse matrix of the same size as q, is the square root of the feature dimension, and V is the value vector matrix.
[0030] Optionally, the self-attention distillation mechanism formula is:
[0031]
[0032] Among them, MaxPool is the maximum pooling downsampling, ELU is the activation function, Convld is the one-dimensional convolution performed in the time dimension, [·] AB Sparse self-attention and other operations for multi-head problems, is the j-th distillation layer at time t.
[0033] Optionally, the long sequence time series prediction model is used to perform encoding operations, sparsity evaluation, distillation, data embedding and decoding operations on the processed natural gas data to output a natural gas demand prediction result, including:
[0034] Using a long sequence time series prediction model, respectively performing encoding operations, sparsity evaluation and distillation operations on the processed natural gas data to obtain the encoded natural gas data;
[0035] Performing data embedding on the processed natural gas data to obtain embedded natural gas data;
[0036] The decoder in the long sequence time series prediction model decodes the encoded natural gas data and the embedded natural gas data to output a natural gas demand prediction result.
[0037] In a second aspect, the present application discloses a natural gas demand prediction device, comprising:
[0038] A data processing module, used for acquiring natural gas data, performing data deduplication and data noise reduction processing on the natural gas data, so as to obtain the processed natural gas data;
[0039] A model building module, used to build a query vector sparsity evaluation formula, a probabilistic sparse self-attention formula, and a self-attention distillation mechanism formula, and generate a long sequence time series prediction model of natural gas demand based on the query vector sparsity evaluation formula, the probabilistic sparse self-attention formula, the self-attention distillation mechanism formula, and a decoder;
[0040] The demand prediction module is used to use the long sequence time series prediction model to perform encoding operations, sparsity evaluation, distillation, data embedding and decoding operations on the processed natural gas data to output the natural gas demand prediction result.
[0041] In a third aspect, the present application discloses an electronic device, comprising:
[0042] Memory, used to store computer programs;
[0043] The processor is used to execute the computer program to implement the above-mentioned natural gas demand forecasting method.
[0044] In a fourth aspect, the present application discloses a computer storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the steps of the aforementioned natural gas demand forecasting method are implemented.
[0045] It can be seen that the present application provides a natural gas demand prediction method, including acquiring natural gas data, performing data deduplication and data noise reduction processing on the natural gas data to obtain the processed natural gas data; constructing a query vector sparsity evaluation formula, a probability sparse self-attention formula, and a self-attention distillation mechanism formula, and generating a long sequence time series prediction model for natural gas demand based on the query vector sparsity evaluation formula, the probability sparse self-attention formula, the self-attention distillation mechanism formula and a decoder; using the long sequence time series prediction model to perform encoding operations, sparsity evaluation, distillation, data embedding and decoding operations on the processed natural gas data to output the natural gas demand prediction result. The present application can improve the quality and reliability of data by deduplicating and denoising the data, construct a query vector sparsity evaluation formula, a probabilistic sparse self-attention formula, and a self-attention distillation mechanism formula, thereby generating a long sequence time series prediction model for natural gas demand. The long sequence time series prediction model can adaptively select useful information of the time series, does not require manual parameter adjustment and coupling domain expertise, reduces the complexity of natural gas demand prediction, and has stronger generalization ability and robustness, and can process high-dimensional, nonlinear and complex time series data, thereby improving the accuracy and stability of natural gas demand prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] 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 or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0047] Figure 1 A flow chart of a natural gas demand forecasting method disclosed in this application;
[0048] Figure 2 A flow chart of a natural gas demand forecasting method disclosed in this application;
[0049] Figure 3 This is a diagram of the overall framework for natural gas demand prediction disclosed in this application;
[0050] Figure 4 This is a schematic diagram of the structure of a natural gas demand prediction device disclosed in this application;
[0051] Figure 5 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.
[0053] The current natural gas demand forecasting methods are mainly based on traditional statistical models and empirical models, such as ARIMA, VAR, etc. These models have some shortcomings and deficiencies in data processing and model building: on the one hand, these methods can usually only handle some simple linear and stationary time series data models, and it is difficult to deal with high-dimensional, nonlinear and complex data features; on the other hand, these methods often need to rely on manual experience and domain knowledge for model parameter adjustment and feature extraction, so it takes a lot of time and effort. In addition, these methods often cannot handle noise and abnormal data well, and may have problems such as overfitting or underfitting, resulting in inaccurate and unstable forecast results. As can be seen from the above, how to process high-dimensional, nonlinear and complex time series data, improve the accuracy and stability of natural gas demand forecasting, and reduce the complexity of natural gas demand forecasting are problems to be solved in this field.
[0054] See also Figure 1 As shown, the embodiment of the present invention discloses a method for predicting natural gas demand, which may specifically include:
[0055] Step S11: acquiring natural gas data, and performing data deduplication and data noise reduction processing on the natural gas data to obtain the processed natural gas data.
[0056] Step S12: construct a query vector sparsity evaluation formula, a probabilistic sparse self-attention formula, and a self-attention distillation mechanism formula, and generate a long sequence time series prediction model for natural gas demand based on the query vector sparsity evaluation formula, the probabilistic sparse self-attention formula, the self-attention distillation mechanism formula, and the decoder.
[0057] In this embodiment, the process of constructing the query vector sparsity evaluation formula, the probabilistic sparse self-attention formula, and the self-attention distillation mechanism formula is as follows:
[0058] (1) Constructing a query vector sparsity evaluation formula. Construct a query vector sparsity evaluation formula based on the query vector sparsity measurement formula and the relative entropy divergence formula; the query vector sparsity measurement formula is:
[0059]
[0060] Among them, q iis the i-th row in the query vector matrix Q, k j is the jth row in the key vector matrix K, v j is the jth row in the value vector matrix V, k(q i , k j ) is an asymmetric exponential function, is the square root of the feature dimension, p(k j |q i ) is the attention probability distribution;
[0061] The relative entropy divergence formula includes a discrete random variable relative entropy divergence formula and a continuous random variable relative entropy divergence formula;
[0062] The discrete random variable relative entropy divergence formula is:
[0063]
[0064] Where D is the relative entropy, P(x) and Q(x) are the two probability distributions of the value of x;
[0065] The relative entropy divergence formula of the continuous random variable is:
[0066]
[0067] In this embodiment, the construction principle of the query vector sparsity evaluation formula for measuring the sparsity of the query vector is as follows:
[0068] Let Q, K, and V be matrices consisting of query vectors, key vectors, and value vectors, respectively. Since not every dot product of QK is a valid value, it is not necessary to spend a lot of time processing this data, so query sparsity measurement can be performed. The i-th row of the final output Z is expressed as the query vector sparsity evaluation formula.
[0069] in, is the attention probability distribution, that is, the distribution of keys under the condition of a given i-th query. If the attention probability distribution is close to the uniform distribution, that is:
[0070] q(k j |q i )=1 / L K ;
[0071] This means that the query is "lazy" and cannot select important keys. Otherwise, it means that the query is "active". Since active queries contribute a lot to self-attention, while lazy queries contribute little, we should try to select active queries as much as possible.
[0072] (2) The query vector sparsity evaluation formula is:
[0073]
[0074] Among them, q i is the i-th row in the query vector matrix, is the jth row in the transposed key vector matrix, L K is the length of the query vector, is the square root of the feature dimension.
[0075] In this embodiment, the principle of constructing the query vector sparsity evaluation formula is as follows: According to the KL (relative entropy) divergence formula, the evaluation formula for the sparsity of the i-th query is:
[0076]
[0077] in, for q i For all keys of LSE (Log-Sum-Exp, logarithmic sum exponential function), is the arithmetic mean. However, such a calculation still has O(L Q L K ) memory usage, and LSE has potential numerical stability issues. Based on this, a query vector sparsity evaluation formula is constructed. The approximate process is as follows:
[0078]
[0079] According to the theorem: for each query, q i ∈R d and k in the key set K j ∈R d , the sparseness of the i-th query M(q i , upper and lower bounds of K):
[0080]
[0081] Then the above query vector sparsity evaluation formula can be obtained.
[0082] The above process only involves taking the max and summing, i.e. the dot product, which is simpler to operate.
[0083] (3) The probabilistic sparse self-attention formula is:
[0084]
[0085] Among them, Q is the query vector matrix, K is the key vector matrix, and Softmax is the conversion of normalized similarity scores into attention weights. is a sparse matrix of the same size as q, is the square root of the feature dimension, and V is the value vector matrix.
[0086] In this embodiment, when ProbSparse Attention randomly samples K for each Q, the sampling result of each head is the same, that is, the sampled K is the same. However, since each layer of self-attention will perform a linear transformation on QKV, this makes the QK corresponding to different heads at the same position in the sequence different, so the difference for Q for each head is different, which is equivalent to each head adopting a different optimization strategy. Based on the proposed metric, each key is only concerned with the dominant query to obtain the formula for ProbSparse self-attention, that is, the above-mentioned probabilistic sparse self-attention formula. The specific implementation steps are: 1. Randomly sample a certain amount of keys for each query; 2. Calculate the sparsity measurement M(q, K) for each query; 3. Select u queries with the highest sparsity measurement, u = c × lnL Q ; 4. Only calculate the dot product of u queries and all keys to get the attention score; 5. The score corresponding to other queries is the mean of the input of the self-attention layer (mean(V)) to ensure that the input and output sequence lengths are both L.
[0087] (4) The self-attention distillation mechanism formula is:
[0088]
[0089] Among them, MaxPool is the maximum pooling downsampling, ELU is the activation function, Convld is the one-dimensional convolution performed in the time dimension, [·] AB Sparse self-attention and other operations for multi-head problems, is the j-th distillation layer at time t.
[0090] In this embodiment, the construction principle of the Encoder: self-attention distilling formula is as follows: the sequence X input at time t t Expressed as According to the ProbSparse Self-attention process introduced in the above algorithm, the result of attention will inevitably be redundant, so the self-attention distillation operation is proposed to extract the main attention, which will greatly shorten the time dimension of the input. Specifically, the process from the jth layer to the j+1th layer obtains the self-attention distillation mechanism formula. The self-attention distillation operation reduces the total memory usage to O((2-ε)LlogL), where ε is a very small number. In order to enhance the robustness of the distillation operation, the encoder architecture also establishes a stack of multiple encoders, each stack is an independent small encoder, and as the stack increases, the distillation operation layer and the input length are gradually reduced by half each time, and finally all the stack outputs are spliced together.
[0091] In this embodiment, the principle of Generative Style Decoder is as follows: The decoder consists of two parts: the first part is the output of the encoder (i.e. the encoded natural gas data), and the second part is the decoder input after embedding (i.e. the embedded natural gas data), with the latter half of the input masked with 0. In long-term prediction problems, using generative inference can alleviate the speed drop. Feed the following vector into the decoder:
[0092]
[0093] in, is the start token. is a placeholder for the target sequence (set the scalar to 0). Masked multi-head attention can be applied to ProbSparse self-attention by setting the dot product of the mask to negative infinity. It prevents each position from paying attention to future positions, thus avoiding autoregression. A fully connected layer obtains the final output, with a very large L y It depends on whether you are performing univariate prediction or multivariate prediction. The start token is an effective technique in "dynamic decoding" of NLP (Natural Language Processing), which is extended here to a generative approach. This application does not select a specific flag as a token, but instead samples an L in the input sequence. tokenThe long sequence, which is the earlier segment before the output sequence.
[0094] Step S13: using the long sequence time series prediction model to perform encoding operations, sparsity evaluation, distillation, data embedding and decoding operations on the processed natural gas data to output a natural gas demand prediction result.
[0095] In this embodiment, the processed natural gas data is encoded, evaluated for sparsity, and distilled using a long sequence time series prediction model to obtain the encoded natural gas data; the processed natural gas data is embedded to obtain the embedded natural gas data; the encoded natural gas data and the embedded natural gas data are decoded based on a decoder in the long sequence time series prediction model to output a natural gas demand prediction result.
[0096] In this embodiment, natural gas data is obtained, and data deduplication and data noise reduction are performed on the natural gas data to obtain the processed natural gas data; a query vector sparsity evaluation formula, a probability sparse self-attention formula, and a self-attention distillation mechanism formula are constructed, and a long sequence time series prediction model for natural gas demand is generated based on the query vector sparsity evaluation formula, the probability sparse self-attention formula, the self-attention distillation mechanism formula, and a decoder; and the processed natural gas data is respectively encoded, sparsity evaluated, distilled, embedded, and decoded using the long sequence time series prediction model to output a natural gas demand prediction result. The present application can improve the quality and reliability of data by deduplicating and denoising the data, construct a query vector sparsity evaluation formula, a probabilistic sparse self-attention formula, and a self-attention distillation mechanism formula, thereby generating a long sequence time series prediction model for natural gas demand. The long sequence time series prediction model can adaptively select useful information of the time series, does not require manual parameter adjustment and coupling domain expertise, reduces the complexity of natural gas demand prediction, and has stronger generalization ability and robustness, and can process high-dimensional, nonlinear and complex time series data, thereby improving the accuracy and stability of natural gas demand prediction.
[0097] See also Figure 2 As shown, the embodiment of the present invention discloses a method for predicting natural gas demand, which may specifically include:
[0098] Step S21: acquiring natural gas data, performing data deduplication on the natural gas data to obtain the deduplicated natural gas data, performing data denoising on the deduplicated natural gas data to obtain the denoised natural gas data, and performing correlation array processing on the denoised natural gas data using a Pearson correlation coefficient method to obtain the processed natural gas data; wherein the data denoising includes data cleaning, data standardization processing, and data outlier processing.
[0099] In this embodiment, after obtaining the natural gas data, it is necessary to perform data deduplication, data noise reduction and related array processing operations on the data. (1) Data deduplication is an important step in the data processing process, which aims to eliminate redundant information in the data set. It is necessary to import the original natural gas data from the data source, and then accurately identify those data items that are exactly the same by comparing each record in the data set. The core of the deduplication operation is to retain the only record in each duplicate data group and completely delete other duplicate records, so as to ensure that each data in the data set is unique, providing a clear and accurate data basis for subsequent analysis. (2) Data noise reduction is another indispensable step in data processing. The main goal is to clean up errors and outliers in the data to improve the quality and reliability of the data. Noise reduction involves two main aspects: data cleaning and outlier processing. In the data cleaning stage, it is necessary to carefully check each item in the data set to find and correct spelling errors, format errors, etc. to ensure the accuracy and consistency of the data. In addition, it is also necessary to standardize the data, such as unifying units and converting data types, for subsequent analysis and comparison. Outlier processing is another important aspect of data noise reduction. Outliers refer to values that are significantly deviated from the normal data distribution range. They may be caused by data entry errors, measurement errors, or special events. In order to identify these outliers, methods such as box plots and IQR (InterQuartile Range) can be used. Once outliers are identified, it is necessary to decide whether to delete these values or use some method (such as mean replacement, median replacement, etc.) to replace them reasonably according to the specific situation. Through noise reduction processing, the noise interference in the data can be effectively reduced, and the accuracy and reliability of data analysis can be improved. (3) The most correlated array is selected by the Pearson correlation coefficient method. The Pearson correlation coefficient between two variables is defined as the quotient of the covariance and standard deviation between the two variables:
[0100]
[0101] Among them, ρ is the overall correlation coefficient, cov(X, Y) is the covariance of variables X and Y, σ X , σ Yare the standard deviations of variables X and Y, respectively, and E is the expected value. By estimating the covariance and standard deviation of the sample, we can get the Pearson correlation coefficient, which is usually represented by the lowercase letter τ:
[0102]
[0103] τ can also be expressed by (X i , Y i ) The standard score mean estimate of the sample points is obtained, and the expression equivalent to the above formula is obtained:
[0104]
[0105] in, and σX are respectively i The sample standard score, sample mean, and sample standard deviation, and σY are Y i The standard score of the sample, the sample mean, and the sample standard deviation.
[0106] The closer the Pearson correlation coefficient is to 1, the stronger the positive correlation between the two variables is; the closer it is to -1, the stronger the negative correlation is; and close to 0, it means there is almost no linear correlation between the two variables. In practical applications, the correlation coefficient value and significance test (such as t-test) are usually combined to evaluate whether the correlation between two variables is significant.
[0107] Step S22: construct a query vector sparsity evaluation formula, a probabilistic sparse self-attention formula, and a self-attention distillation mechanism formula, and generate a long sequence time series prediction model for natural gas demand based on the query vector sparsity evaluation formula, the probabilistic sparse self-attention formula, the self-attention distillation mechanism formula, and the decoder.
[0108] Step S23: using the long sequence time series prediction model to perform encoding operations, sparsity evaluation, distillation, data embedding and decoding operations on the processed natural gas data to output a natural gas demand prediction result.
[0109] The long-sequence time series prediction model of natural gas demand generated in this application is an informer (time series prediction) model, which is improved on the transformer (sequence model based on attention mechanism) based on the sparse self-attention mechanism. It includes four processes: input, encoding, decoding and output. The overall architecture is as follows: Figure 3As shown in the figure: first, natural gas data is obtained, such as wind energy data, photovoltaic energy data, water conservancy data and bioenergy data, and then the natural gas data is preprocessed, including data deduplication and data noise reduction processing; then, the query vector sparsity evaluation formula, the probability sparse self-attention formula and the self-attention distillation mechanism formula are constructed, and a long sequence time series prediction model of natural gas demand is generated based on the query vector sparsity evaluation formula, the probability sparse self-attention formula, the self-attention distillation mechanism formula and the decoder; then, the long sequence time series prediction model is used to encode, evaluate sparsity and distill the processed natural gas data respectively to obtain the encoded natural gas data; and, the processed natural gas data is embedded (i.e., Embedding operation) to obtain the embedded natural gas data; finally, the encoded natural gas data and the embedded natural gas data are decoded based on the decoder to output the natural gas demand prediction result.
[0110] The innovations of this application include: (1) applying the natural language processing mechanism to long- and short-term natural gas demand forecasting, and constructing a long-sequence time series forecasting model for natural gas demand; (2) using the probabilistic sparse self-attention mechanism to screen out the most important query vectors, reducing the computational complexity, greatly improving the algorithm's computational efficiency, and making it more efficient and quicker in practical applications; (3) using the query vector sparsity evaluation formula to construct the model, breaking the limitation that the model cannot accept longer sequence inputs, and can perform longer-period forecasts than traditional models.
[0111] In this embodiment, natural gas data is obtained, and data deduplication and data noise reduction are performed on the natural gas data to obtain the processed natural gas data; a query vector sparsity evaluation formula, a probability sparse self-attention formula, and a self-attention distillation mechanism formula are constructed, and a long sequence time series prediction model for natural gas demand is generated based on the query vector sparsity evaluation formula, the probability sparse self-attention formula, the self-attention distillation mechanism formula, and a decoder; and the processed natural gas data is respectively encoded, sparsity evaluated, distilled, embedded, and decoded using the long sequence time series prediction model to output a natural gas demand prediction result. The present application can improve the quality and reliability of data by deduplicating and denoising the data, construct a query vector sparsity evaluation formula, a probabilistic sparse self-attention formula, and a self-attention distillation mechanism formula, thereby generating a long sequence time series prediction model for natural gas demand. The long sequence time series prediction model can adaptively select useful information of the time series, does not require manual parameter adjustment and coupling domain expertise, reduces the complexity of natural gas demand prediction, and has stronger generalization ability and robustness, and can process high-dimensional, nonlinear and complex time series data, thereby improving the accuracy and stability of natural gas demand prediction.
[0112] See also Figure 4 As shown, the embodiment of the present invention discloses a natural gas demand prediction device, which may specifically include:
[0113] The data processing module 11 is used to obtain natural gas data, and perform data deduplication and data noise reduction processing on the natural gas data to obtain the processed natural gas data;
[0114] A model building module 12 is used to build a query vector sparsity evaluation formula, a probability sparse self-attention formula, and a self-attention distillation mechanism formula, and generate a long sequence time series prediction model of natural gas demand based on the query vector sparsity evaluation formula, the probability sparse self-attention formula, the self-attention distillation mechanism formula, and a decoder;
[0115] The demand prediction module 13 is used to use the long sequence time series prediction model to perform encoding operations, sparsity evaluation, distillation, data embedding and decoding operations on the processed natural gas data to output the natural gas demand prediction result.
[0116] In this embodiment, natural gas data is obtained, and data deduplication and data noise reduction are performed on the natural gas data to obtain the processed natural gas data; a query vector sparsity evaluation formula, a probability sparse self-attention formula, and a self-attention distillation mechanism formula are constructed, and a long sequence time series prediction model for natural gas demand is generated based on the query vector sparsity evaluation formula, the probability sparse self-attention formula, the self-attention distillation mechanism formula, and a decoder; and the processed natural gas data is respectively encoded, sparsity evaluated, distilled, embedded, and decoded using the long sequence time series prediction model to output a natural gas demand prediction result. The present application can improve the quality and reliability of data by deduplicating and denoising the data, construct a query vector sparsity evaluation formula, a probabilistic sparse self-attention formula, and a self-attention distillation mechanism formula, thereby generating a long sequence time series prediction model for natural gas demand. The long sequence time series prediction model can adaptively select useful information of the time series, does not require manual parameter adjustment and coupling domain expertise, reduces the complexity of natural gas demand prediction, and has stronger generalization ability and robustness, and can process high-dimensional, nonlinear and complex time series data, thereby improving the accuracy and stability of natural gas demand prediction.
[0117] In some specific embodiments, the data processing module 11 may specifically include:
[0118] A data deduplication module, used for performing data deduplication on the natural gas data to obtain the deduplicated natural gas data;
[0119] A data denoising module, used for performing data denoising on the natural gas data after deduplication to obtain the natural gas data after denoising; wherein the data denoising includes data cleaning, data standardization processing and data outlier processing;
[0120] The correlation array processing module is used to perform correlation array processing on the natural gas data after noise reduction by using the Pearson correlation coefficient method to obtain the processed natural gas data.
[0121] In some specific embodiments, the model building module 12 may specifically include:
[0122] A query vector sparsity evaluation formula construction module is used to construct a query vector sparsity evaluation formula based on a query vector sparsity measurement formula and a relative entropy divergence formula;
[0123] The query vector sparsity measurement formula is:
[0124]
[0125] Among them, q i is the i-th row in the query vector matrix Q, k j is the jth row in the key vector matrix K, v j is the jth row in the value vector matrix V, k(q i , k j ) is an asymmetric exponential function, is the square root of the feature dimension, p(k j |q i ) is the attention probability distribution;
[0126] The relative entropy divergence formula includes a discrete random variable relative entropy divergence formula and a continuous random variable relative entropy divergence formula;
[0127] The discrete random variable relative entropy divergence formula is:
[0128]
[0129] Where D is the relative entropy, P(x) and Q(x) are the two probability distributions of the value of x;
[0130] The relative entropy divergence formula of the continuous random variable is:
[0131]
[0132] In some specific embodiments, the query vector sparsity evaluation formula is:
[0133]
[0134] Among them, qi is the i-th row in the query vector matrix, is the jth row in the transposed key vector matrix, L K is the length of the query vector, is the square root of the feature dimension.
[0135] In some specific embodiments, the probabilistic sparse self-attention formula is:
[0136]
[0137] Among them, Q is the query vector matrix, K is the key vector matrix, and Softmax is the conversion of normalized similarity scores into attention weights. is a sparse matrix of the same size as q, is the square root of the feature dimension, and V is the value vector matrix.
[0138] In some specific embodiments, the self-attention distillation mechanism formula is:
[0139]
[0140] Among them, MaxPool is the maximum pooling downsampling, ELU is the activation function, Convld is the one-dimensional convolution performed in the time dimension, [·] AB Sparse self-attention and other operations for multi-head problems, is the j-th distillation layer at time t.
[0141] In some specific embodiments, the demand prediction module 13 may specifically include:
[0142] The encoding, sparsity evaluation and distillation module is used to perform encoding operations, sparsity evaluation and distillation operations on the processed natural gas data using a long sequence time series prediction model to obtain the encoded natural gas data;
[0143] A data embedding module, used for embedding the processed natural gas data to obtain the embedded natural gas data;
[0144] A decoding module is used to decode the encoded natural gas data and the embedded natural gas data based on the decoder in the long sequence time series prediction model to output a natural gas demand prediction result.
[0145] Figure 5A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the natural gas demand forecasting method performed by the electronic device disclosed in any of the aforementioned embodiments.
[0146] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0147] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 221, a computer program 222 and data 223, etc. The storage method can be temporary storage or permanent storage.
[0148] Among them, the operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20 to realize the operation and processing of the data 223 in the memory 22 by the processor 21, which can be Windows, Unix, Linux, etc. In addition to including a computer program that can be used to complete the natural gas demand forecasting method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks. In addition to data transmitted from an external device received by the natural gas demand forecasting device, the data 223 can also include data collected by its own input and output interface 25, etc.
[0149] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0150] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium, in which a computer program is stored. When the computer program is loaded and executed by a processor, the steps of the natural gas demand prediction method disclosed in any of the aforementioned embodiments are implemented.
[0151] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0152] The above is a detailed introduction to a natural gas demand prediction method, device, equipment and storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for a person skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A natural gas demand forecasting method, characterized in that: include: Acquire natural gas data, and perform data deduplication and data noise reduction processing on the natural gas data to obtain processed natural gas data; Construct a query vector sparsity evaluation formula, a probabilistic sparse self-attention formula, and a self-attention distillation mechanism formula, and generate a long sequence time series prediction model of natural gas demand based on the query vector sparsity evaluation formula, the probabilistic sparse self-attention formula, the self-attention distillation mechanism formula, and a decoder; The long sequence time series prediction model is used to perform encoding operations, sparsity evaluation, distillation, data embedding and decoding operations on the processed natural gas data to output a natural gas demand prediction result.
2. The natural gas demand forecasting method according to claim 1, characterized in that: The performing data deduplication and data noise reduction processing on the natural gas data to obtain the processed natural gas data includes: Deduplication of the natural gas data to obtain deduplicated natural gas data; Performing data denoising on the natural gas data after deduplication to obtain the natural gas data after denoising; wherein the data denoising includes data cleaning, data standardization processing and data outlier processing; The natural gas data after noise reduction is processed by correlation array using the Pearson correlation coefficient method to obtain the processed natural gas data.
3. The natural gas demand forecasting method according to claim 1, characterized in that: Construct a query vector sparsity evaluation formula, including: Construct a query vector sparsity evaluation formula based on the query vector sparsity measurement formula and the relative entropy divergence formula; The query vector sparsity measurement formula is: Among them, q i is the i-th row in the query vector matrix Q, k j is the jth row in the key vector matrix K, v j is the jth row in the value vector matrix V, k(q i , k j ) is an asymmetric exponential function, is the square root of the feature dimension, p(k j |q i ) is the attention probability distribution; The relative entropy divergence formula includes a discrete random variable relative entropy divergence formula and a continuous random variable relative entropy divergence formula; The discrete random variable relative entropy divergence formula is: Where D is the relative entropy, P(x) and Q(x) are the two probability distributions of the value of x; The relative entropy divergence formula of the continuous random variable is:
4. The natural gas demand forecasting method according to claim 3, characterized in that: The query vector sparsity evaluation formula is: Among them, q i is the i-th row in the query vector matrix, is the jth row in the transposed key vector matrix, L K is the length of the query vector, is the square root of the feature dimension.
5. The natural gas demand forecasting method according to claim 4, characterized in that: The probabilistic sparse self-attention formula is: Among them, Q is the query vector matrix, K is the key vector matrix, and Softmax is the conversion of normalized similarity scores into attention weights. is a sparse matrix of the same size as q, is the square root of the feature dimension, and V is the value vector matrix.
6. The natural gas demand forecasting method according to claim 5, characterized in that: The self-attention distillation mechanism formula is: Among them, MaxPool is the maximum pooling downsampling, ELU is the activation function, Convld is the one-dimensional convolution performed in the time dimension, [·] AB Sparse self-attention and other operations for multi-head problems, is the j-th distillation layer at time t.
7. The natural gas demand forecasting method according to any one of claims 1 to 6, characterized in that: The long sequence time series prediction model is used to perform encoding operations, sparsity evaluation, distillation, data embedding and decoding operations on the processed natural gas data to output a natural gas demand prediction result, including: Using a long sequence time series prediction model, respectively performing encoding operations, sparsity evaluation and distillation operations on the processed natural gas data to obtain the encoded natural gas data; Performing data embedding on the processed natural gas data to obtain embedded natural gas data; The decoder in the long sequence time series prediction model decodes the encoded natural gas data and the embedded natural gas data to output a natural gas demand prediction result.
8. A natural gas demand forecasting device, characterized in that: include: A data processing module, used for acquiring natural gas data, performing data deduplication and data noise reduction processing on the natural gas data, so as to obtain the processed natural gas data; A model building module, used to build a query vector sparsity evaluation formula, a probabilistic sparse self-attention formula, and a self-attention distillation mechanism formula, and generate a long sequence time series prediction model of natural gas demand based on the query vector sparsity evaluation formula, the probabilistic sparse self-attention formula, the self-attention distillation mechanism formula, and a decoder; The demand prediction module is used to use the long sequence time series prediction model to perform encoding operations, sparsity evaluation, distillation, data embedding and decoding operations on the processed natural gas data to output the natural gas demand prediction result.
9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor is used to execute the computer program to implement the natural gas demand forecasting method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store a computer program; wherein, when the computer program is executed by a processor, the natural gas demand forecasting method according to any one of claims 1 to 7 is implemented.
