Natural gas demand prediction method and system based on comparative learning

By adopting a contrast learning-based method in natural gas demand forecasting, combining overlapping sampling, noise enhancement and Smooth L1 loss loss function, pre-trained models are built and fine-tuned, the problems of noise and industry characteristics in natural gas demand forecasting are solved, and higher prediction accuracy and robustness are achieved.

CN120046773AActive Publication Date: 2025-05-27NANKAI UNIV +1
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202510048691.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-13
Publication Date
2025-05-27
Estimated Expiration
2045-01-13

AI Technical Summary

Technical Problem

The existing technology is difficult to effectively deal with noise problems in industrial data and differences in natural gas consumption patterns in different industries in natural gas demand forecasting, resulting in insufficient prediction accuracy and generalization.

Method used

Using a method based on contrast learning, the combination of overlapping sampling comparison learning loss function, noise enhancement comparison learning loss function and Smooth L1 loss loss function is used to construct the pre-trained model, and the model is fine-tuned through the root mean square error loss to improve the robustness and accuracy of the prediction.

Benefits of technology

It improves the accuracy and robustness of natural gas demand forecasting, can more effectively handle industry characteristics in multi-user scenarios, reduces the impact of noise on prediction, and achieves better prediction results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120046773A_ABST
    Figure CN120046773A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence prediction energy demand utilization, in particular to a natural gas demand prediction method and system based on comparative learning. Defining original time series data, and preprocessing the original time series data to obtain complete time series data; performing comparative learning task design training on the complete time sequence data to obtain an overall target loss function; using root-mean-square error loss to adjust the overall target loss function to obtain a natural gas demand prediction model based on comparative learning; and predicting the natural gas demand according to the natural gas demand prediction model based on comparative learning to obtain a natural gas demand result. According to the invention, through fusion of comparative learning and noise filtering design, the technical problem of inaccurate prediction caused by too large noise of the natural gas data set is solved, and the technical effect of accurately predicting the natural gas demand is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of artificial intelligence for predicting energy demand utilization, and particularly to a natural gas demand prediction method and system based on contrastive learning. Background Art

[0002] Achieving efficient natural gas scheduling requires accurate demand prediction, but there are two key challenges to address. First, industrial datasets often contain a large amount of noise, which may obscure the true natural gas consumption patterns and complicate accurate demand prediction. The noise in the data may come from various sources, such as sensor errors, data transmission problems, or data recording problems, etc. These inaccuracies may distort the actual usage data, making it difficult to identify the true consumption trends and anomalies. Second, the natural gas consumption patterns vary greatly across different industries. For example, in industrial applications, natural gas is used for power generation, heating, steam production, and mechanical operations, where the usage is usually driven by different production cycles and operational requirements, resulting in unpredictable peaks and valleys; in the commercial sector, natural gas is mainly used for cooking, heating, and hot water supply, and the demand is affected by business hours and seasonal changes, such as the increase in heating demand during colder periods. The differences in consumption patterns across different industries complicate the modeling process and reduce the prediction accuracy of traditional methods.

[0003] Traditional methods for natural gas demand prediction, such as time series analysis and regression models, lay the foundation for prediction by using historical data to identify trends and patterns. With the development of deep learning, recent research has mainly focused on some models based on recurrent neural networks, convolutional neural networks, and the Transformer architecture and its variants. These models have significantly improved prediction accuracy and generalization compared to traditional solutions. However, most of these methods still rely on end-to-end learning methods. In recent years, self-supervised representation learning has made significant progress in the fields of computer vision and natural language processing, and is increasingly being applied to time series prediction to improve prediction performance.

[0004] Most academic research on time series prediction is based on public datasets, ignoring the relatively serious noise problems and industry-specific problems commonly existing in real industrial datasets. The current state-of-the-art research using contrastive learning for time series usually combines the masked modeling task with the contrastive learning task, attempting to obtain better representations and thus better prediction performance. However, due to the presence of noise, masked modeling and contrastive learning may instead lead to learning incorrect feature information, resulting in worse representations and not achieving better prediction performance. These studies also rarely consider the relationships brought by the user industry characteristics in multi-user scenarios, failing to fully utilize the existing features, which also leads to suboptimal representation learning and suboptimal prediction results.

[0005] In summary, predicting natural gas demand for real industrial and commercial scenarios based on natural gas consumption data is an innovative topic with important research significance and application value. Summary of the Invention

[0006] The present invention aims to solve at least one of the technical problems existing in the related art. To this end, the present invention provides a natural gas demand prediction method and system based on contrastive learning.

[0007] The present invention provides a natural gas demand prediction method based on contrastive learning, including the following steps: S1: Define the original time series data, and preprocess the original time series data to obtain complete time series data; S2: Design and train a contrastive learning task for the complete time series data to obtain an overlapping sampling contrastive learning loss function, a noise augmentation contrastive learning loss function, and a Smooth L1 loss function; S3: According to the overlapping sampling contrastive learning loss function, the noise augmentation contrastive learning loss function, and the Smooth L1 loss function, obtain an overall objective loss function, and train according to the overall objective loss function to obtain a pre-trained model; S4: Calculate the root mean square error loss, and adjust the pre-trained model to obtain a natural gas demand prediction model based on contrastive learning; S5: Predict the natural gas demand according to the natural gas demand prediction model based on contrastive learning to obtain a natural gas demand result.

[0008] According to the natural gas demand prediction method based on contrastive learning provided by the present invention, S1 includes the following steps: S11: Organize the collected time series data to obtain the original time series data with a length of , where , , where is the data of the original time series data, is the data ordinal number of the original time series data, ; S12: Filter out the original time series data with a length less than the length threshold; Calculate the Z-score of the original time series data. The Z-score calculation formula is: where is the Z-score, is the average value of the original time series data, is the standard deviation of the original time series data, Calculate the proportion of the Z - scores of the original time - series data that are greater than the Z - score threshold : Among them, is the number of Z - scores of a set of original time - series data that are greater than the Z - score threshold; If is greater than the Z - score proportion threshold, the corresponding original time - series data is removed. If is less than or equal to the Z - score proportion threshold, the corresponding original time - series data is retained, and the filtered original time - series data is obtained; S13: Use the SAITS model to fill in the missing values for the filtered original time - series data to obtain the complete time - series data.

[0009] According to the present invention, a natural gas demand prediction method based on contrastive learning is provided. S2 includes the following steps: S21: Sample the complete time - series data at the same sampling interval and sampling size to obtain a number of initial time - period samples of the same length, and generate multiple overlapping time - period samples through a sliding window method. The initial time - period samples and the overlapping time - period samples are time - period samples , and encode the time - period samples to generate embedding vectors Among them, is the encoding function, is the learnable positional embedding; Among the time - period samples there are For the overlapping first sample and the second sample , the first sample and the second sample form a sampling sample , among which, is the number of overlapping pairs; Randomly select from the sampling samples sampling samples as positive - example samples , and the remaining sampling samples as negative - example samples , among which, and are sample ordinals, , ; The first sample The corresponding first embedding vector is ; The second sample The corresponding second embedding vector is ; The positive example sample The corresponding positive embedding vector is ; The negative example sample The corresponding negative embedding vector is ; S22: Screen the false negative samples from the positive and negative embedding vectors to obtain a set of false negative samples ; S23: Through comparing and learning the first embedding vector, the second embedding vector, the positive embedding vector, and the negative embedding vector after removing the set of false negative samples, obtain the overlapping sampling contrast learning loss function ; S24: Perform noise-enhanced contrast on the positive and negative embedding vectors to obtain enhanced positive embedding vectors, and perform noise-enhanced contrast learning on the positive embedding vector, the second embedding vector, and the enhanced positive embedding vectors to obtain the noise-enhanced contrast learning loss function ; S25: Use the positive embedding vector, the negative embedding vector, and the enhanced positive embedding vectors to perform noise filtering learning on the time period samples to obtain the Smooth L1 loss function .

[0010] According to the present invention, a natural gas demand prediction method based on contrast learning is provided. S22 includes the following steps: S221: Calculate the cosine similarity between the positive and negative embedding vectors: Wherein, is the cosine similarity of the embedding vectors, is the vector modulus; S222: Obtain the first set of false negative embedding vectors : Wherein, is the set of the top cosine similarities with the highest ranking of the calculated cosine similarities of the embedding vectors, is the ranking threshold, is the preset ranking ratio hyperparameter; S223: Obtain the second set of false negative embedding vectors : Among them, represents the industry corresponding to the positive embedding vector or the negative embedding vector, represents the same; S224: Obtain the false negative sample set through the first false negative embedding vector set and the second false negative embedding vector set : .

[0011] According to the present invention, a natural gas demand prediction method based on contrast learning is provided, and the overlapping sampling contrast learning loss function has the following calculation formula: Among them, indicates that the embedding vector does not include the false negative sample set, is the temperature parameter.

[0012] According to the present invention, a natural gas demand prediction method based on contrast learning is provided. S24 includes the following steps: S241: Mix the negative embedding vector into the positive embedding vector to obtain the enhanced positive embedding vector , and the calculation formula is: Among them, is the weight parameter; S242: Perform noise-enhanced contrast learning on the positive embedding vector, negative embedding vector, and enhanced positive embedding vector to obtain the noise-enhanced contrast learning loss function , and the calculation formula is: .

[0013] According to the present invention, a natural gas demand prediction method based on contrast learning is provided. S25 includes the following steps: S251: Train the decoder, and the calculation formula is, Among them, is the query matrix, is the key matrix, is the value matrix, is the weight matrix of the query matrix, is the weight matrix of the key matrix, is the weight matrix of the value matrix; S252: Calculate the attention scores of the decoder through the attention mechanism where, is the attention function, is the activation function, is the dimension of the key matrix, is the transpose of the matrix; S253: Denoise the attention scores and the positive embedding vectors using a multi-layer perceptron: where, is the denoised time period sample, is the multi-layer perceptron, is the layer normalization operation; S254: Perform noise filtering learning on the time period sample to obtain the Smooth L1 loss function , and the calculation formula is: where, is the hyperparameter of the preset Smooth L1 loss.

[0014] According to the present invention, a natural gas demand prediction method based on contrast learning is provided, and the formula of the overall objective loss function is: where, is the first parameter, is the second parameter, During training using the Adam optimizer, when is minimized, it is considered that the pre-trained model converges, and the pre-trained model is obtained and denoted as .

[0015] According to the present invention, a natural gas demand prediction method based on contrast learning is provided, and S4 includes the following steps: where, is the prediction result obtained by calculating the time period sample using the model constructed by the overall objective loss function, is the true result of the original time series data, is the root mean square error loss function, is the distance from the position ordinal number of the original time series data to the prediction starting point, It is a pre-trained model function. By adjusting the first parameter and the second parameter, is minimized. When the model converges, the natural gas demand prediction model based on contrastive learning is obtained.

[0016] The present invention also provides a natural gas demand prediction system based on contrastive learning, including: Time series processing module: Define the original time series data, preprocess the original time series data to obtain complete time series data; Loss function calculation module: Design and train the complete time series data for contrastive learning tasks to obtain an overlapping sampling contrastive learning loss function, a noise augmentation contrastive learning loss function, and a Smooth L1 loss function; According to the overlapping sampling contrastive learning loss function, the noise augmentation contrastive learning loss function, and the Smooth L1 loss function, obtain an overall objective loss function, and train according to the overall objective loss function to obtain a pre-trained model; Model fine-tuning module: Calculate the root mean square error loss, and adjust the pre-trained model to obtain a natural gas demand prediction model based on contrastive learning; Data calculation module: Predict the natural gas demand according to the natural gas demand prediction model based on contrastive learning to obtain the natural gas demand result.

[0017] One or more of the above technical solutions in the embodiments of the present invention have at least one of the following technical effects: A natural gas demand prediction method and system based on contrastive learning provided by the present invention, by combining three loss functions, namely an overlapping sampling contrastive learning loss function, a noise augmentation contrastive learning loss function, and a Smooth L1 loss function, adjusting the proportions of these three functions, and using the root mean square error for adjustment, achieves the following advantages: 1. Innovative pre-training scheme: The present invention proposes to combine contrastive learning with a noise filtering task, making the prediction task more robust to noise. Compared with previous time series predictions based on contrastive learning, combining the noise filtering task with the contrastive learning task can better enhance the robustness to the noise commonly present in the dataset, obtain better representations, and thus better predict the future natural gas demand of users.

[0018] 2. Adaptation to multi-user datasets: The present invention is aimed at datasets that are different from conventional time series public datasets and are single-variable multi-user datasets. It makes special adaptations to this type of dataset, specifies corresponding data partitioning strategies, and divides the test set according to dates, enabling it to be better applied in corresponding scenarios.

[0019] 3. Effective negative sample elimination strategy: The present invention proposes to eliminate negative samples in contrast learning based on two indicators, namely the industry information of users and sample similarity. While making more effective use of existing information, it avoids some samples that may be positive examples from being wrongly regarded as negative examples or positive examples and participating in the calculation, resulting in sub-optimal results, so as to obtain a better prediction result.

[0020] Additional aspects and advantages of the present invention will be given in part in the following description, become apparent in part from the following description, or be understood through the practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0022] Figure 1 It is a flowchart of a natural gas demand prediction method based on contrast learning provided by the present invention; Figure 2 It is a structural block diagram of a natural gas demand prediction device based on contrast learning provided by the present invention.

[0023] Reference numerals: 101, time series processing module; 102, loss function calculation module; 103, model fine-tuning module; 104, data calculation module. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0024] To make the objectives, technical solutions, and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention. The following embodiments are used to illustrate the present invention, but cannot be used to limit the scope of the present invention.

[0025] In the description of this specification, the descriptions referring to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the embodiments of the present invention. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0026] The following combines Figure 1 and Figure 2 to describe the present invention.

[0027] Embodiment As Figure 1 shown, the present invention provides a natural gas demand prediction method based on contrast learning: S1: Define the original time series data, preprocess the original time data series to obtain complete time series data; S2: Design and train a contrast learning task for the complete time series data to obtain an overlapping sampling contrast learning loss function, a noise augmentation contrast learning loss function, and a Smooth L1 loss function; S3: According to the overlapping sampling contrast learning loss function, the noise augmentation contrast learning loss function, and the Smooth L1 loss function, obtain an overall objective loss function, and train according to the overall objective loss function to obtain a pre-trained model; S4: Calculate the root mean square error loss, adjust the pre-trained model to obtain a natural gas demand prediction model based on contrast learning; S5: Predict the natural gas demand according to the natural gas demand prediction model based on contrast learning to obtain a natural gas demand result.

[0028] Specifically, step S1 includes the following steps: S11: Organize the collected time series data to obtain the original time series data with a length of , where is the data of the original time series data, is the data ordinal number of the original time series data, ; S12: Filter out the original time series data with a length less than the length threshold; Calculate the Z-score of the original time series data. The Z-score calculation formula is: Where, is the Z-score, is the average value of the original time series data, is the standard deviation of the original time series data; Preset the Z-score threshold and the Z-score ratio threshold, Calculate the proportion of the Z-score of the original time series data that is greater than the Z-score threshold : Where, is the number of Z-scores of a set of original time series data that are greater than the Z-score threshold; If is greater than the Z-score ratio threshold, the corresponding original time series data is removed. If is less than or equal to the Z-score ratio threshold, the corresponding original time series data is retained, to obtain the filtered original time series data; S13: Use the SAITS (Self-Attention-based Imputation for Time Series) model to fill in the missing values for the filtered original time series data to obtain the complete time series data.

[0029] Specifically, step S2 includes the following steps: S21: Sample the complete time series data at the same sampling interval and sampling size to obtain several initial time period samples of the same length, and generate multiple overlapping time period samples through the sliding window method. The initial time period samples and the overlapping time period samples are time period samples. The time period samples are encoded to generate embedding vectors Where, is the encoding function, is the learnable position embedding; Among the time period samples there is for the overlapping first sample and the second sample , the first sample and the second sample form a sampling sample , where is the overlapping logarithm; Randomly select from the sampling samples positive example samples , and the remaining sampling samples are negative example samples , where and are sample ordinals, , ; The first sample corresponds to the first embedding vector ; The second sample corresponds to the second embedding vector ; The positive example sample corresponds to the positive embedding vector ; The negative example sample corresponds to the negative embedding vector ; S22: Screen the embedding vectors for false negative samples to obtain a set of false negative samples : Calculate the cosine similarity between the positive embedding vector and the negative embedding vector: where is the cosine similarity of the embedding vectors, is the vector norm.

[0030] Calculate the first set of false negative embedding vectors and the second set of false negative embedding vectors : where is the set of the top cosine similarities with the largest ranking of the calculated cosine similarities of the embedding vectors, is the ranking threshold, is the preset ranking ratio hyperparameter, represents the industry corresponding to the positive time period sample or the negative time period sample, represents equality.

[0031] The set of false negative samples is the union of the first set of false negative embedding vectors and the second set of false negative embedding vectors ; 。

[0032] S23: Obtain the overlapping sampling contrast learning loss function by performing contrast learning on the first embedding vector, the second embedding vector, the positive embedding vector, and the negative embedding vector excluding the false negative sample set , and the calculation formula is: where indicates that the embedding vector does not contain false negative samples, is the temperature parameter.

[0033] S24: Perform noise-enhanced contrast on the positive embedding vector and the negative embedding vector to obtain a strengthened positive embedding vector, and perform noise-enhanced contrast learning on the positive embedding vector, the negative embedding vector, and the strengthened positive embedding vector to obtain the noise-enhanced contrast learning loss function . The specific steps are as follows: Mix a small number of negative time period samples into the positive embedding vector to obtain the strengthened positive embedding vector: where is the weight parameter; Perform noise-enhanced contrast learning on the positive embedding vector, the negative embedding vector, and the strengthened positive embedding vector to obtain the noise-enhanced contrast learning loss function : .

[0034] S25: Use the positive embedding vector, the second embedding vector, and the strengthened positive embedding vector to perform noise filtering learning on the time period samples to obtain the Smooth L1 loss function The specific steps are as follows: Train the decoder, and the calculation process is as follows: where is the query matrix, is the key matrix, is the value matrix, is the weight matrix of the query matrix, is the weight matrix of the key matrix, is the weight matrix of the value matrix; Calculate the attention score of the decoder through the attention mechanism: where is the attention function, is the activation function, is the dimension of the key matrix, is the matrix transpose.

[0035] Calculate the attention score of the decoder through the attention mechanism: where, is the attention function, is the activation function, is the dimension of the key matrix, is the matrix transpose.

[0036] Denoise the attention score and the positive embedding vector using a multi-layer perceptron: where, is the denoised time period sample, is the multi-layer perceptron, is the layer normalization operation.

[0037] For the time period sample Perform noise filtering learning to obtain the Smooth L1 loss function : where, is the hyperparameter of the preset Smooth L1 loss. In the embodiments of the present invention, .

[0038] S3: According to the overlapping sampling contrast learning loss function, the noise augmentation contrast learning loss function, and the Smooth L1 loss function, obtain the overall objective loss function . Among them, the formula of the overall objective loss function is the weighted sum of the overlapping sampling contrast learning loss function, the noise augmentation contrast learning loss function, and the Smooth L1 loss function. The formula is: where, is the first parameter, is the second parameter, Use the Adam optimizer for training. When is the smallest, it is regarded as the convergence of the pre-trained model, and the pre-trained model is obtained and denoted as .

[0039] S4: Calculate the root mean square error loss, adjust the overall objective loss function, and obtain the natural gas demand prediction model based on contrast learning; It includes the following steps: Wherein, is the prediction result obtained by calculating the sample of the time period using the model constructed with the overall objective loss function, is the true result of the original time series data, is the root mean square error loss function, is the distance from the position ordinal number of the original time series data to the prediction starting point, is the pre-trained model function; by adjusting the first parameter and the second parameter, is minimized, regarded as the model convergence, and the natural gas demand prediction model based on contrast learning is obtained .

[0040] S5: Predict the natural gas demand according to the natural gas demand prediction model based on contrast learning to obtain the natural gas demand result.

[0041] The natural gas demand result is: Wherein, is the natural gas demand result.

[0042] In the embodiment of the present invention, the input of the model is the original time series data , and the output is the function value of the overall loss function of the natural gas demand prediction model of contrast learning.

[0043] The effectiveness of the embodiment of the present invention is demonstrated below: The embodiment of the present invention conducts a verification experiment on the private dataset ENN of XinAo Gas Company. The experiment includes medium and long-term prediction tasks. For the medium and long-term prediction tasks, the prediction step lengths of this embodiment are set to 60, 90, 120, 150, and 180 days. Nine corresponding time series prediction models are compared in the medium and long-term prediction, and the prediction results are evaluated by two widely used metrics in time series prediction, namely MSE (mean-square error) and MAE (mean absolute error). The specific results are shown in Table 1: Table 1 Comparison of the results of the present invention and other methods in the medium and long-term prediction tasks

[0044] Among them, PITS (Patch Independence for Time Series), SimMTM (Simple pre-training framework for Masked Time-series Modeling), PatchTST (Patch TimeSeries Transformer), iTransformer (Inverted Transformer), TimesNet, DLinear (DLinear), Nonstationary, Pyraformer, FEDformer (Frequency Enhanced DecomposedTransformer), Autoformer, and Informer are all existing prediction methods.

[0045] Table 1 presents the performance of existing recommendation models and methods after using the present invention on various data sets. The experimental results show that the natural gas demand prediction model based on contrastive learning proposed by the present invention reduces the error between the prediction result and the actual value, achieving a better prediction effect.

[0046] The embodiment of the present invention also provides a fairness recommendation system for a candidate project pool from the perspective of projects, including: Time series processing module 101: Define the original time series data, preprocess the original time series data to obtain complete time series data; Loss function calculation module 102: Design and train a contrastive learning task for the complete time series data to obtain an overlapping sampling contrastive learning loss function, a noise-enhanced contrastive learning loss function, and a Smooth L1 loss function; According to the overlapping sampling contrastive learning loss function, the noise-enhanced contrastive learning loss function, and the Smooth L1 loss function, obtain an overall objective loss function, and train a pre-trained model according to the overall objective loss function; Model fine-tuning module 103: Calculate the root mean square error loss, and adjust the pre-trained model to obtain a natural gas demand prediction model based on contrastive learning; Data calculation module 104: Predict the natural gas demand according to the natural gas demand prediction model based on contrastive learning to obtain a natural gas demand result.

[0047] The advantages and positive effects of the invention mainly include the following aspects: 1. Innovative pre-training scheme: The present invention proposes to combine contrastive learning with a noise filtering task, making the prediction task more robust to noise. Compared with previous time series predictions based on contrastive learning, combining the noise filtering task with the contrastive learning task can better enhance the robustness to the noise commonly present in the dataset, obtain better representations, and thus better predict the user's future natural gas demand.

[0048] 2. Adaptation of multi-user dataset: Different from conventional time series public datasets, the dataset of the present invention is a univariate multi-user dataset. Special adaptation is made for this type of dataset, and a corresponding data partitioning strategy is specified. The test set is partitioned according to the date, enabling it to be better applied in the corresponding scenario.

[0049] 3. Effective negative sample elimination strategy: The present invention proposes to eliminate negative samples in contrastive learning based on two indicators: the user's industry information and sample similarity. While making more effective use of existing information, it avoids some samples that may be positive examples from being wrongly regarded as negative examples or participating in the calculation as positive examples, resulting in suboptimal results, and thus obtaining better prediction results.

[0050] 4. Excellent experimental results: The present invention conducts experiments on the real private natural gas usage dataset of ENN Group. The results show that the method of this embodiment performs better than existing end-to-end and pre-trained benchmark models in the natural gas demand prediction task. This indicates that the method proposed by the invention can effectively improve the accuracy of the natural gas demand prediction task.

[0051] In summary, the advantages and positive effects of the present invention include an innovative pre-training scheme, adaptation of multi-user dataset, effective negative sample elimination strategy, and excellent experimental results, etc., providing a new solution for the natural gas demand prediction task.

[0052] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

[0053] It should be noted that the embodiments of the present disclosure can be implemented by hardware, software, or a combination of software and hardware. The hardware part can be implemented using dedicated logic; the software part can be stored in a memory and executed by a suitable instruction execution system such as a microprocessor or dedicated designed hardware. Those skilled in the art can understand that the above-mentioned devices and methods can be implemented using computer-executable instructions and / or included in processor control code, for example, such code is provided on a programmable memory or a data carrier such as an optical or electronic signal carrier.

[0054] In addition, although the operations of the method of the present disclosure are described in a specific order in the drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. On the contrary, the order of execution of the steps depicted in the flowchart can be changed. Additionally or alternatively, some steps can be omitted, multiple steps can be combined into one step for execution, and / or one step can be decomposed into multiple steps for execution. It should also be noted that the features and functions of two or more devices according to the present disclosure can be embodied in one device. Conversely, the features and functions of one device described above can be further divided and embodied by multiple devices.

[0055] Although the present disclosure has been described with reference to several specific embodiments, it should be understood that the present disclosure is not limited to the specific embodiments disclosed. The present disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.

Claims

1. A natural gas demand forecasting method based on contrastive learning, characterized in that: The following steps are involved: S1: define original time series data, preprocess the original time series data to obtain complete time series data; S2: Perform contrastive learning task design training on the complete time series data to obtain overlapping sampling contrastive learning loss function, noise enhancement contrastive learning loss function and Smooth L1 loss function; S3: Obtain an overall target loss function according to the overlapped sampling contrast learning loss function, the noise enhancement contrast learning loss function and the Smooth L1loss loss function, and perform training according to the overall target loss function to obtain a pre-trained model; S4: calculating the root mean square error loss, adjusting the pre-training model, and obtaining a natural gas demand prediction model based on contrastive learning; S5: Predicting natural gas demand according to the natural gas demand prediction model based on contrastive learning to obtain a natural gas demand result.

2. A natural gas demand forecasting method based on contrastive learning according to claim 1, characterized in that: S1 includes the following steps: S11: Sort the collected time series data into a length of The original time series data , ,in, is the data of the original time series data, The data ordinal number of the original time series data ; S12: filter out the original time series data whose length is less than the length threshold; Calculate the Z score of the original time series data. The Z score calculation formula is: in, is the Z score, is the average value of the original time series data, is the standard deviation of the original time series data, Calculate the proportion of the original time series data whose Z score is greater than the Z score threshold : in, A set of raw time series data The number of Z scores greater than the Z score threshold; like Greater than the Z-score ratio threshold, The corresponding original time series data is removed. Less than or equal to the Z score ratio threshold, The corresponding original time series data is retained. Get the filtered original time series data; S13: Using the SAITS model to fill missing values ​​in the screened original time series data to obtain the complete time series data.

3. The natural gas demand forecasting method based on contrastive learning according to claim 1, characterized in that: S2 includes the following steps: S21: Sample the complete time series data according to the same sampling interval and sampling size to obtain a number of initial time period samples of the same length, and generate a plurality of overlapping time period samples by a sliding window method. The initial time period samples and the overlapping time period samples are time period samples. , the samples of the time period are Encoding, generating embedding vectors : in, for Encoding function, for learnable position embeddings; Sample of the time period Existence The first sample of the overlap and the second sample , the first sample and the second sample constitute a sampling sample ,in, is the number of overlapping pairs; From the sample Random draw The sampled samples are taken as positive samples , the remaining samples are taken as negative samples ,in, and is the sample ordinal number, , ; The first sample The corresponding first embedding vector is ; The second sample The corresponding second embedding vector is ; The positive example The corresponding positive embedding vector is ; The negative sample The corresponding negative embedding vector is ; S22: Screen the positive embedding vectors and negative embedding vectors for false negative samples to obtain a set of false negative samples ; S23: Obtain the overlapping sampling contrast learning loss function by performing contrast learning on the first embedding vector, the second embedding vector, the positive embedding vector, and the negative embedding vector from which the false negative sample set is removed. ; S24: performing noise enhancement contrast on the positive embedding vector and the negative embedding vector to obtain an enhanced positive embedding vector, and performing noise enhancement contrast learning on the positive embedding vector, the negative embedding vector and the enhanced positive embedding vector to obtain the noise enhancement contrast learning loss function ; S25: Using the second embedding vector, the positive embedding vector and the enhanced positive embedding vector, noise filtering learning is performed on the samples in the time period to obtain a Smooth L1 loss function .

4. A natural gas demand forecasting method based on contrastive learning according to claim 3, characterized in that: S22 includes the following steps: S221: Calculate the cosine similarity of the positive embedding vector and the negative embedding vector: in, is the cosine similarity of the embedding vector, Modulo a vector; S222: Obtaining a first false negative embedding vector set : in, The top ranked cosine similarity of the calculated embedding vector A set of cosine similarities, is the ranking threshold, is the preset ranking ratio hyperparameter; S223: Obtain a second false negative embedding vector set : in, represents the industry corresponding to the positive embedding vector or the negative embedding vector, Indicates the same; S224: Obtain the false negative sample set through the first false negative embedding vector set and the second false negative embedding vector set. : 。 5. A natural gas demand forecasting method based on contrastive learning according to claim 4, characterized in that: The overlapping sampling contrastive learning loss function The calculation formula is: in, Indicates that the embedding vector does not contain the false negative sample set, is the temperature parameter.

6. A natural gas demand forecasting method based on contrastive learning according to claim 5, characterized in that: S24 includes the following steps: S241: Mixing the negative embedding vector into the positive embedding vector to obtain the enhanced positive embedding vector : in, is the weight parameter; S242: Perform noise enhancement contrastive learning on the positive embedding vector, the negative embedding vector and the enhanced positive embedding vector to obtain a noise enhancement contrastive learning loss function The calculation formula is: 。 7. A natural gas demand forecasting method based on contrastive learning according to claim 6, characterized in that: S25 includes the following steps: S251: Training decoder: in, is the query matrix, is the key matrix, is the value matrix, is the weight matrix of the query matrix, is the weight matrix of the key matrix, is the weight matrix of the value matrix; S252: Calculate the attention score of the decoder through the attention mechanism: in, is the attention function, is the activation function, is the dimension of the key matrix, is the transpose of the matrix; S253: De-noising the attention score and the positive embedding vector using a multi-layer perceptron: in, is the time period sample after denoising, is a multi-layer perceptron, It is the layer normalization operation; S254: Sample for time period Perform noise filtering learning to obtain the Smooth L1 loss function : in, is the hyperparameter of the preset Smooth L1 loss.

8. A natural gas demand forecasting method based on contrastive learning according to claim 7, characterized in that: The overall objective loss function The formula is: in, is the first parameter, is the second parameter, Using the Adam optimizer for training, When it is the smallest, the pre-training model is considered to have converged, and the pre-training model is recorded as .

9. A natural gas demand forecasting method based on contrastive learning according to claim 8, characterized in that: S4 includes the following steps: in, is the prediction result obtained by calculating the samples of the time period by the model constructed using the overall objective loss function, is the true result of the original time series data, is the root mean square error loss function, is the distance from the position ordinal of the original time series data to the starting point of the prediction, is a pre-trained model function, by adjusting the first parameter and the second parameter so that The model is considered to have converged, and the natural gas demand forecasting model based on contrastive learning is obtained.

10. A natural gas demand forecasting system based on contrastive learning, used to execute the natural gas demand forecasting method based on contrastive learning as claimed in any one of claims 1 to 9, characterized in that: include: Time series processing module: defines original time series data, preprocesses the original time data series, and obtains complete time series data; Loss function calculation module: performing contrastive learning task design training on the complete time series data to obtain overlapping sampling contrastive learning loss function, noise enhancement contrastive learning loss function and Smooth L1 loss function; obtaining the overall target loss function according to the overlapping sampling contrastive learning loss function, noise enhancement contrastive learning loss function and Smooth L1 loss function, and performing training according to the overall target loss function to obtain a pre-training model; Model fine-tuning module: calculating the root mean square error loss, adjusting the pre-training model, and obtaining a natural gas demand forecasting model based on contrastive learning; Data calculation module: predicting the natural gas demand according to the natural gas demand prediction model based on contrastive learning to obtain the natural gas demand result.

Citation Information

Patent Citations

  • Physical examination auxiliary decision-making system based on false negative sample identification

    CN113611411A

  • Image target detection method, system and equipment under severe weather condition

    CN116311254A

  • City flow prediction method based on comparative learning

    CN117332886A

  • Pretraining-based fermentation product concentration prediction method

    CN117972425A

  • Multivariable time sequence classification method and system based on time-frequency mixed contrast learning

    CN118097306A