Gas consumption prediction method and device, electronic equipment and storage medium

By performing timing analysis and feature extraction on the historical data of gas volume for gas, combined with GRU and Transformer models, high-precision prediction of gas volume for gas volume is achieved, solving the problems of low prediction accuracy and efficiency in the existing technology, and improving the accuracy and efficiency of gas volume prediction.

CN120494159APending Publication Date: 2025-08-15BEIJING YAHUA WULIAN TECH DEV CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510530313.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

The prior art has low accuracy and efficiency in gas usage prediction, making it difficult to meet the complex and changeable gas usage scenarios.

Method used

By obtaining the historical data of gas consumption in the target area, performing timing analysis and feature extraction, combining the gating cycle unit GRU and Transformer model, local and global feature data are predicted, and weight generation is generated using self-attention mechanism and time-dimensional convolutional gating to achieve high-precision prediction of gas consumption.

Benefits of technology

It improves the accuracy and efficiency of gas volume prediction, reduces the prediction error and computational complexity of model training, and enhances the generalization ability and robustness of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120494159A_ABST
    Figure CN120494159A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to the technical field of database management and natural language processing, and discloses a gas consumption prediction method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining historical data related to the gas consumption in a database corresponding to a target area; performing time sequence analysis on the historical data to obtain initial gas consumption characteristic data; performing feature extraction on the initial gas consumption feature data to obtain local gas consumption feature data and global gas consumption feature data; and based on the local gas consumption characteristic data and the global gas consumption characteristic data, obtaining a gas consumption prediction value of the target area. By applying the technical scheme of the invention, the efficiency and accuracy of predicting the gas consumption of the fuel gas can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of data processing technology, and specifically to a method, device, electronic device, and storage medium for predicting gas consumption. Background Art

[0002] Related technologies often rely on manual analysis of historical data or simple statistical models when predicting gas usage. Consequently, when faced with complex and ever-changing gas usage scenarios, the prediction accuracy and efficiency often fail to meet actual needs. Summary of the Invention

[0003] In view of the above problems, embodiments of the present invention provide a method, device, electronic device and storage medium for predicting gas usage, which are used to solve the problems of low accuracy and efficiency in gas usage prediction in related technologies.

[0004] According to one aspect of an embodiment of the present invention, a method for predicting gas usage is provided. The method includes: obtaining historical data related to gas usage from a database corresponding to a target area; performing time series analysis on the historical data to obtain initial gas usage characteristic data; performing feature extraction on the initial gas usage characteristic data to obtain local gas usage characteristic data and global gas usage characteristic data; and obtaining a predicted gas usage value for the target area based on the local gas usage characteristic data and the global gas usage characteristic data. This process can improve the efficiency and accuracy of gas usage prediction.

[0005] In an optional embodiment, the historical data is subjected to time series analysis to obtain initial gas usage characteristic data, including:

[0006] Perform feature expansion on each gas usage feature in the historical data to obtain a first gas usage feature;

[0007] Performing feature dimensionality reduction processing on the first gas usage feature to obtain a second gas usage feature;

[0008] Performing time series analysis on the second gas usage characteristics based on the target time window to obtain gas usage segment data;

[0009] The gas usage characteristic data of the gas usage segment are sampled to obtain the gas usage characteristic data of the target area at each sampling time to form the initial gas usage characteristic data.

[0010] In an optional embodiment, forward feature extraction and reverse feature extraction are performed on the initial gas usage feature data to obtain corresponding forward extraction features and reverse extraction features;

[0011] The forward extracted features and the reverse extracted features are spliced to obtain the local gas usage feature data;

[0012] Each data position of the local gas usage characteristic data is encoded to obtain the global gas usage characteristic data.

[0013] In an optional embodiment, encoding each data position of the local gas usage characteristic data to obtain the global gas usage characteristic data includes:

[0014] Encode each data position of the local gas consumption characteristic data based on the encoding layer to obtain a position encoding matrix;

[0015] Perform encoding fusion on the position coding matrix and the sinusoidal position coding matrix to obtain a fused coding matrix;

[0016] Based on the self-attention mechanism, global features of the fusion coding matrix are extracted to obtain global gas usage feature data.

[0017] In an optional embodiment, obtaining a predicted value of gas consumption in a target area based on local gas consumption characteristic data and global gas consumption characteristic data includes:

[0018] Align the dimensions of the local gas usage characteristic data with the global gas usage characteristic data to obtain a local gas usage characteristic matrix and a global gas usage characteristic matrix;

[0019] Based on the time dimension convolution gating, the local feature weights corresponding to the local gas usage feature matrix and the global feature weights corresponding to the global gas usage feature matrix are obtained;

[0020] Based on the local feature weights, global feature weights, local gas consumption feature matrix and global gas consumption feature matrix, the gas consumption prediction value of the target area is obtained.

[0021] In an optional embodiment, based on the local feature weights, the global feature weights, the local gas usage feature matrix, and the global gas usage feature matrix, a gas usage prediction value for the target area is obtained, including:

[0022] Based on the product of the global feature weight and the global gas consumption feature matrix, a global adjustment feature matrix is obtained;

[0023] Based on the product of the local feature weight and the local gas usage feature matrix, a local adjustment feature matrix is obtained;

[0024] Fusing the global adjustment feature matrix with the local adjustment feature matrix to obtain a fused feature matrix;

[0025] The fused feature matrix is concatenated with the local gas consumption feature data and then input into the fully connected layer to obtain the predicted value of gas consumption.

[0026] In an optional embodiment, after obtaining the predicted value of gas consumption in the target area based on the local gas consumption characteristic data and the global gas consumption characteristic data, the method further includes:

[0027] Calculate the residual between the predicted gas consumption and the actual gas consumption;

[0028] Adjust local gas consumption characteristic data based on the residual.

[0029] According to another embodiment of the present invention, a gas usage prediction device is provided, comprising: a data acquisition module for acquiring historical data related to gas usage from a database corresponding to a target area; a time series analysis module for performing time series analysis on the historical data to obtain initial gas usage characteristic data; a feature extraction module for performing feature extraction on the initial gas usage characteristic data to obtain local gas usage characteristic data and global gas usage characteristic data; and a gas usage prediction module for obtaining a predicted gas usage value for the target area based on the local gas usage characteristic data and the global gas usage characteristic data. These modules can improve the efficiency and accuracy of gas usage prediction.

[0030] According to another aspect of an embodiment of the present invention, an electronic device is provided, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform the operation of the aforementioned gas consumption prediction method.

[0031] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the storage medium stores at least one executable instruction, and the executable instruction enables an electronic device / apparatus to perform the operation of the aforementioned gas consumption prediction method.

[0032] According to another aspect of an embodiment of the present invention, a computer program product is provided, comprising computer instructions for causing a computer to execute the operations of the gas consumption prediction method of the first aspect or any corresponding embodiment thereof.

[0033] The above description is only an overview of the technical solutions of the embodiments of the present invention. In order to more clearly understand the technical means of the embodiments of the present invention, they can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiments of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present invention. In addition, the same reference symbols are used to represent the same components throughout the drawings. In the drawings:

[0035] Figure 1 A schematic diagram of a flow chart of a method for predicting gas consumption provided by the present invention is shown;

[0036] Figure 2 A schematic structural diagram of a gas consumption prediction device provided by the present invention is shown;

[0037] Figure 3 A schematic structural diagram of an electronic device provided by the present invention is shown. DETAILED DESCRIPTION

[0038] To make the purpose, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of the present invention.

[0039] Figure 1 FIG1 shows a flow chart of a first embodiment of a method for predicting gas consumption according to the present invention. Figure 1 As shown, the method includes the following steps:

[0040] Step 110: Obtain historical data related to gas consumption in a database corresponding to the target area.

[0041] As mentioned above, obtaining historical gas usage data from the target area's database provides a data foundation for subsequent time series analysis. This historical gas usage data typically includes, but is not limited to, historical gas usage, installed meters, temperature, humidity, weather, time stamps, clock times, user types, holiday information, and gas equipment types. This data can be obtained from the gas company's database or other relevant data sources.

[0042] In an optional implementation, after obtaining historical data related to gas usage from the database corresponding to the target area, this historical data can also be preprocessed, including data cleaning, data deduplication, missing value processing, and outlier processing, to ensure the accuracy and reliability of the historical data. This preprocessing of historical data can improve the accuracy and efficiency of subsequent time series analysis and feature extraction.

[0043] Step 120: Perform time series analysis on the historical data to obtain initial gas usage characteristic data.

[0044] As mentioned above, by performing time series analysis on historical data, the initial gas consumption characteristic data is obtained, which can provide a basis for subsequent feature extraction and gas consumption prediction.

[0045] In some optional embodiments, when performing time series analysis on historical data to obtain initial gas usage characteristic data, the gas usage characteristics in the historical data can be first expanded to obtain a first gas usage characteristic; the first gas usage characteristic can then be subjected to feature dimensionality reduction processing to obtain a second gas usage characteristic; the second gas usage characteristic can then be subjected to time series analysis based on a target time window to obtain gas usage segment data; and finally, gas usage feature sampling can be performed on the gas usage segment data to obtain gas usage characteristic data of the target area at each sampling moment to form initial gas usage characteristic data.

[0046] In an optional embodiment, when performing time series analysis on historical data, the size of the target time window can be set according to actual needs. For example, the target time window can be set to one month, one quarter, or one year, etc., so as to perform time series analysis on historical data at different time scales. By performing time series analysis on historical data, the gas consumption characteristic data of the target area in different time periods can be obtained, thereby gaining a more comprehensive understanding of the gas consumption situation in the target area. In addition, feature expansion can increase the number and diversity of features by deriving and transforming the original features to improve the generalization ability of the model; feature dimensionality reduction can reduce the dimension of the feature space through methods such as principal component analysis and linear discriminant analysis, thereby reducing computational complexity and the risk of overfitting.

[0047] Furthermore, when performing time series analysis on historical data to obtain initial gas usage characteristic data, time series analysis can be based on time series models such as ARIMA models and LSTM models to model and analyze historical data to extract time series characteristics related to gas usage. The results of time series analysis can be used as initial gas usage characteristic data, providing a basis for subsequent feature extraction and prediction.

[0048] For example, the target gas usage features of historical data, such as 15 gas usage features, are expanded to 50 features after feature engineering, and then reduced to 10 features through principal component analysis (PCA). Next, gas usage segment data is generated using a sliding time window with a window size of W = 1, and each small segment has SEQ_IN = 60 and SEQ_OUT = 30. Finally, feature sampling is performed on the gas segment data to obtain initial gas usage feature data. The data format of the initial gas usage feature data is [SEQ_LEN, BATCH_SIZE, INPUT_DIM], where SEQ_LEN is the sequence length, set to 60; BATCH_SIZE is the batch size, set to 32; and INPUT_DIM is the data feature dimension, set to 10.

[0049] Step 130 : extracting features from the initial gas usage characteristic data to obtain local gas usage characteristic data and global gas usage characteristic data.

[0050] Local gas usage data primarily reflects the target area's gas usage characteristics within a specific time period, while global gas usage data reflects the target area's gas usage characteristics over the entire historical period. Extracting both local and global gas usage data provides richer and more comprehensive feature information for subsequent gas usage forecasts.

[0051] In some optional embodiments, when feature extraction is performed on the initial gas usage characteristic data to obtain local gas usage characteristic data and global gas usage characteristic data, forward feature extraction and reverse feature extraction can be performed on the initial gas usage characteristic data to obtain corresponding forward extracted features and reverse extracted features; the forward extracted features and the reverse extracted features are feature spliced to obtain local gas usage characteristic data; and each data position of the local gas usage characteristic data is encoded to obtain global gas usage characteristic data. Among them, forward feature extraction focuses on trends and cyclical changes in historical data, while reverse feature extraction focuses on fluctuations and abnormal changes in data. By feature splicing the forward extracted features and the reverse extracted features, local gas usage characteristic data containing more information can be obtained.

[0052] Specifically, the initial gas usage feature data can be extracted based on the target number of forward gated recurrent units in the bidirectional gated recurrent unit GRU, such as 256, to obtain the corresponding forward extracted features. The initial gas usage feature data can be extracted based on the target number of backward gated recurrent units in the bidirectional gated recurrent unit GRU, such as 256, to obtain the corresponding reverse extracted features. The forward extracted features and the reverse extracted features are then concatenated to obtain a dimension of 2h. gru The fusion features (h gru The number of single-layer hidden units of the bidirectional gated recurrent unit GRU is set to 256, which means that the final output is 512-dimensional local gas usage feature data.

[0053] In specific implementation, the following method can be used to extract the features of the initial gas usage characteristic data and obtain the local gas usage characteristic data:

[0054] class BiGRU(nn.Module):

[0055] def_init__(self, input_size=10, hidden_size=64, output_steps=30):

[0056] super()._init__()

[0057] #Bidirectional gated recurrent unit GRU settings.

[0058] self.gru=nn.GRU(

[0059] input_size=input_size,

[0060] hidden_size=hidden_size,

[0061] bidirectional=True, #key parameter.

[0062] batch_first=True )

[0064] #Output layer (considering the dimension after bidirectional splicing).

[0065] self.fc=nn.Linear(2*hidden_size,output_steps)

[0066] def forward(self,x):

[0067] #x shape: (batch, seq_Len, features).

[0068] gru_out, -= self.gru(x) # Output shape: (batch, seq_len, 2*hidden).

[0069] #Take the bidirectional features of the last time step (sampling point).

[0070] forward_last=gru_out[:,-1,iself.hidden_size]

[0071] backward_last=gru_out[:,0,self.hidden_size:]

[0072] combined=torch.cat([forward_last,backward_last],dim=1)

[0073] return self.fc(combined)#(batch,output_steps)

[0074] In another optional implementation, an attention mechanism can be employed to enhance feature extraction from the initial gas usage feature data. This mechanism enables the model to automatically focus on more important information when processing input data, thereby improving the accuracy and efficiency of feature extraction. Specifically, an attention layer can be introduced into the feature extraction module. By applying attention-weighted processing to the initial gas usage feature data, weighted feature data is generated, and subsequent feature extraction and prediction are then performed based on this weighted feature data.

[0075] In some optional embodiments, when encoding each data position of the local gas usage characteristic data to obtain the global gas usage characteristic data, each data position of the local gas usage characteristic data can be encoded based on the encoding layer to obtain a position encoding matrix; the position encoding matrix and the sinusoidal position encoding matrix are encoded and fused to obtain a fused encoding matrix; and global features are extracted from the fused encoding matrix based on the self-attention mechanism to obtain the global gas usage characteristic data.

[0076] Specifically, the 512-dimensional local gas usage feature data output by the gated recurrent unit (GRU) is input into the encoding layer of the deep learning model Transformer with an attention mechanism to encode each data position of the local gas usage feature data to obtain a position encoding matrix; the position encoding matrix is fused with the sinusoidal position encoding matrix to obtain a fused encoding matrix; a multi-head self-attention mechanism is set up, and the encoder part is used to train the fused encoding matrix, thereby realizing global feature extraction of the fused encoding matrix and obtaining the global gas usage feature data.

[0077] In specific implementation, when extracting features from the initial gas usage characteristic data and obtaining global gas usage characteristic data, the following method can be used:

[0078] ##Feature person added position encoding.

[0079] class PositionalEncoding(nn.Module):

[0080] def_init__(self,d_model,max_len=5000):

[0081] super(PositionalEncoding,self).__init__()

[0082] #Create a sinusoidal position encoding matrix.

[0083] pe=torch.zeros(max_len,d_model)

[0084] position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)

[0085] div_term = torch.exp(torch.arange(0, d_model, 2).float() * (-math.log(10000.0) / d_model))

[0086] pe[:, 0::2] = torch.sin(position * div_term)

[0087] pe[:, 1::2] = torch.cos(position * div_term)

[0088] pe = pe.unsqueeze(0).transpose(0, 1)

[0089] self.register_buffer('pe', pe)

[0090] def forward(self, x):

[0091] # Add the positional encoding to the word embedding.

[0092] return x + self.pe[:x.size(0), :]

[0093] class MODEL_GRU_Trans(nn.Module):

[0094] def __init__(self, gru_dim, trans_dim, fused_dim):

[0095] super().__init__()

[0096] self.gru = nn.GRU(input_size = 1, hidden_size = gru_dim, num_layers = 1, batch_first = False)

[0097] self.pos_encoder = PositionalEncoding(d_model = trans_dim)

[0098] encoder_layer=nn.TransformerEncoderLayer(d_model=trans_dim,nhead=8)

[0099] self.msf=MultiscaleFusion(gru_dim=gru_dim, trans_dim=trans_dim, fused_dim=fused_dim)

[0100] self.linear=nn.Linear(in_features=fused_dim,out_features=SEQ_OUT)

[0101] Step 140: Obtain a predicted value of gas consumption in the target area based on the local gas consumption characteristic data and the global gas consumption characteristic data.

[0102] As described above, by deriving a predicted gas usage value for the target area based on local and global gas usage characteristic data, we can more comprehensively utilize information from historical data and improve the accuracy and reliability of the prediction. In specific implementations, the local and global gas usage characteristic data can be concatenated to obtain fused feature data. This fused feature data is then modeled and predicted using deep learning models, such as long short-term memory (LSTM) networks, gated recurrent units (GRU) networks, or deep learning transformers based on attention mechanisms, to obtain a predicted gas usage value for the target area. The selection and parameter settings of the deep learning model can be adjusted and optimized based on actual needs to achieve the best prediction results.

[0103] In some optional embodiments, when obtaining the predicted value of gas consumption in the target area based on local gas consumption characteristic data and global gas consumption characteristic data, the local gas consumption characteristic data and the global gas consumption characteristic data can be dimensionally aligned to obtain a local gas consumption characteristic matrix and a global gas consumption characteristic matrix; based on time dimension convolution gating, the local feature weights corresponding to the local gas consumption characteristic matrix and the global feature weights corresponding to the global gas consumption characteristic matrix are obtained; based on the local feature weights, the global feature weights, the local gas consumption characteristic matrix and the global gas consumption characteristic matrix, the predicted value of gas consumption in the target area is obtained.

[0104] In some optional embodiments, when obtaining the gas consumption prediction value of the target area based on the local feature weights, the global feature weights, the local gas consumption feature matrix and the global gas consumption feature matrix, a global adjustment feature matrix can be obtained based on the product of the global feature weights and the global gas consumption feature matrix; a local adjustment feature matrix can be obtained based on the product of the local feature weights and the local gas consumption feature matrix; the global adjustment feature matrix and the local adjustment feature matrix are fused to obtain a fused feature matrix; the fused feature matrix is concatenated with the local gas consumption feature data and input into the fully connected layer to obtain the gas consumption prediction value.

[0105] Specifically, the local gas usage feature data output by the gated recurrent unit (GRU) is dimensionally aligned with the global gas usage feature data output by the encoding layer of the deep learning model Transformer with an attention mechanism to obtain a local gas usage feature matrix and a global gas usage feature matrix. Convolution gating is performed based on the time dimension, such as performing a 1D convolution on the local gas usage feature matrix to obtain the local feature weights corresponding to the local gas usage feature matrix, and performing a 1D convolution on the global gas usage feature matrix to obtain the global feature weights corresponding to the global gas usage feature matrix. The global adjustment feature matrix is obtained by multiplying the global feature weights with the global gas usage feature matrix. The local adjustment feature matrix is obtained by multiplying the local feature weights with the local gas usage feature matrix. The global adjustment feature matrix and the local adjustment feature matrix are fused to obtain a fused feature matrix. The fused feature matrix is concatenated with the local gas usage feature data and input into the fully connected layer to obtain the predicted gas consumption value.

[0106] In specific implementation, based on the local gas usage characteristic data and the global gas usage characteristic data, the following methods can be used to obtain the gas usage forecast value of the target area:

[0107] #Dimension alignment layer.

[0108] self.gru_proj=nn.Linear(gru_dim,fused_dim)

[0109] self.trans_proj=nn.Linear(trans_dim,fused_dim)

[0110] #Convolution gating in time dimension.

[0111] self.conv_gate=nn.Sequential(

[0112] nn.convid(

[0113] in_channels=2*fused_dim,

[0114] out_channels=2*fused_dim,

[0115] kernel_size=3,

[0116] padding=dilation_rate, #keep the time series length unchanged.

[0117] dilation=dilation_rate,

[0118] groups=2*fused_dim# Depthwise separable convolution reduces the number of parameters while maintaining the ability to extract spatiotemporal features. The computational complexity is only 1 / D of the standard convolution (D is the number of channels).

[0119] nn.BatchNorm1d(2*fused_dim),

[0120] nn.GELU()

[0121] #Weight generator.

[0122] self.weight_gen = nn.convid(

[0123] 2*fused_dim,

[0124] 2, #Generate two weight maps (gru weight and trans weight).

[0125] kernel_size=1

[0126] #Dimension alignment.

[0127] f_gru=self.gru_proj(f_gru)#[B,T,D]

[0128] f_trans=self.trans_proj(f_trans)#[B,T,D]

[0129] #Feature concatenation (along feature dimension).

[0130] concat_feat=torch.cat([f_gru,f_trans],dim=-1)#[B,T,2D]

[0131] #Convert to the dimensions [B, C, T] required for convolution.

[0132] conv_input=concat_feat.permute(0,2,1)#[B,2D,T]

[0133] #Convolution gate processing.

[0134] gate_feat=self.conv_gate(conv_input)#[B,2D,T]

[0135] #Generate spatial attention weights.

[0136] weights=self.weight_gen(gate_feat)#[B,2,T]

[0137] weights=F.softmax(weights, dim=1) #Do softmax along the channel dimension.

[0138] #Separate weights.

[0139] gru_weight=weights[:,0,:].unsqueeze(-1)#[B,T,1]

[0140] trans_weight=weights[:,1,:].unsqueeze(-1)#[B,T,1]

[0141] #WeightedFusionTaiwan.

[0142] fused_feat=(f_gru*gru_weight)+(f_trans*trans_weight)

[0143] #Residual connection prevents the fusion process from destroying the strong local features captured by the bidirectional gated recurrent unit GRU, which can improve the model convergence speed by about 30%.

[0144] final_feat=fused_feat+f_gru#Retain the original feature distribution of the bidirectional gated recurrent unit GRU.

[0145] As mentioned above, the weight is calculated independently at each sampling moment to adapt to the dynamic changes of the sequence. The spatial attention weight distribution is shown in Table 1, and the gas consumption prediction value is shown in Table 2.

[0146] Table 1 Spatial attention weight distribution

[0147]

[0148] Table 2 Gas consumption forecast

[0149]

[0150] It can be seen that the gas consumption prediction accuracy MAE of this embodiment is reduced by 12.7% (from 14.2m 3 / h dropped to 12.4m 3 / h), the number of epochs required for convergence was reduced by 18% (from 550 epochs to 450 epochs), and the peak memory usage was reduced by 23% (due to the use of depthwise separable convolution).

[0151] In some optional implementations, after obtaining a predicted gas usage value for the target area based on local and global gas usage data, the residual between the predicted gas usage value and actual gas usage can be calculated. The local gas usage data can then be adjusted based on this residual to further refine the model's predictive capabilities, making the predictions more closely aligned with actual gas usage. Specifically, the residual can be introduced into the model's forward propagation process as additional input information to guide the model's more refined predictions, gradually correcting its prediction bias and improving prediction accuracy.

[0152] Furthermore, to further enhance the model's generalization and robustness, data augmentation techniques can be employed to expand and transform local and global gas usage feature data to increase the diversity and richness of training samples. These techniques, such as noise addition, time series shifting, and scaling, can be used individually or in combination to achieve optimal data augmentation. During implementation, model hyperparameters can be optimized and adjusted based on actual needs, including the number of GRU and Transformer layers, number of hidden units, learning rate, and batch size, to ensure optimal prediction performance for specific application scenarios.

[0153] The gas consumption prediction method of the embodiment of the present invention achieves high-precision prediction of gas consumption by combining the advantages of the gated recurrent unit GRU and the Transformer model. Among them, the GRU model can capture the time dependency in the sequence data, while the Transformer model captures the global features through the self-attention mechanism. The combination of the two can comprehensively improve the prediction performance. That is, the present invention adopts a multi-scale fusion strategy to effectively fuse the local feature data output by the GRU with the global feature data output by the Transformer. Through the steps of dimension alignment, time dimension convolution gating, and weight generation, dynamic weighting of local and global features is achieved, thereby obtaining more accurate prediction results. In addition, the present invention further improves the convergence speed and stability of the model through residual connections, achieves high-precision prediction of gas consumption, and provides strong technical support for intelligent management and scheduling of the gas industry.

[0154] Figure 2 FIG. 1 shows a schematic diagram of the structure of an embodiment of a gas consumption prediction device according to the present invention. Figure 2 As shown, the device includes:

[0155] The data acquisition module 210 is used to obtain historical data related to gas consumption in the database corresponding to the target area;

[0156] The time series analysis module 220 is used to perform time series analysis on historical data to obtain initial gas usage characteristic data;

[0157] A feature extraction module 230 is used to extract features from the initial gas usage feature data to obtain local gas usage feature data and global gas usage feature data;

[0158] The gas consumption prediction module 240 is used to obtain a predicted value of gas consumption in a target area based on the local gas consumption characteristic data and the global gas consumption characteristic data.

[0159] In an optional implementation, the timing analysis module 220 includes:

[0160] A feature expansion submodule is used to expand the gas usage features in the historical data to obtain the first gas usage features;

[0161] a feature dimensionality reduction submodule, configured to perform feature dimensionality reduction processing on the first gas usage feature to obtain a second gas usage feature;

[0162] A time series analysis submodule, configured to perform time series analysis on the second gas usage feature based on a target time window to obtain gas usage segment data;

[0163] The feature sampling submodule is used to sample the gas usage characteristics of the gas usage segment data, obtain the gas usage characteristic data of the target area at each sampling time, and form the initial gas usage characteristic data.

[0164] In an optional embodiment, the feature extraction module 230 includes:

[0165] The special frame extraction submodule is used to perform forward feature extraction and reverse feature extraction on the initial gas usage feature data to obtain corresponding forward extraction features and reverse extraction features;

[0166] The feature splicing submodule is used to perform feature splicing on the forward extracted features and the reverse extracted features to obtain local gas usage feature data;

[0167] The position encoding submodule is used to encode each data position of the local gas consumption characteristic data to obtain the global gas consumption characteristic data.

[0168] In an optional embodiment, the position encoding submodule includes:

[0169] A position coding unit, configured to encode each data position of the local gas consumption characteristic data based on the coding layer to obtain a position coding matrix;

[0170] A coding fusion unit, configured to perform coding fusion on the position coding matrix and the sinusoidal position coding matrix to obtain a fused coding matrix;

[0171] The feature extraction unit is used to extract global features of the fusion coding matrix based on the self-attention mechanism to obtain global gas usage feature data.

[0172] In an optional embodiment, the gas consumption prediction module 240 includes:

[0173] A dimension alignment submodule is used to align the dimensions of the local gas usage feature data with the global gas usage feature data to obtain a local gas usage feature matrix and a global gas usage feature matrix;

[0174] The weight acquisition submodule is used to obtain the local feature weights corresponding to the local gas usage feature matrix and the global feature weights corresponding to the global gas usage feature matrix based on time dimension convolution gating;

[0175] The gas consumption prediction submodule is used to obtain the gas consumption prediction value of the target area based on the local feature weight, the global feature weight, the local gas consumption feature matrix and the global gas consumption feature matrix.

[0176] In an optional embodiment, the gas consumption prediction submodule includes:

[0177] A global matrix acquisition unit, configured to obtain a global adjustment feature matrix based on the product of a global feature weight and a global gas usage feature matrix;

[0178] A local matrix acquisition unit, configured to obtain a local adjustment feature matrix based on the product of the local feature weight and the local gas usage feature matrix;

[0179] A matrix feature fusion unit is used to fuse the global adjustment feature matrix with the local adjustment feature matrix to obtain a fused feature matrix;

[0180] The gas consumption prediction unit is used to concatenate the fusion feature matrix with the local gas consumption feature data and input them into the fully connected layer to obtain the gas consumption prediction value.

[0181] In some optional implementations, the gas usage prediction module 240 is further configured to calculate a residual between the predicted gas usage and the actual gas usage; and adjust the local gas usage characteristic data based on the residual.

[0182] The further functional description of each of the above modules and units is the same as that of the above corresponding method embodiments and will not be repeated here.

[0183] See also Figure 3 , Figure 3 is a structural diagram of an electronic device provided by an optional embodiment of the present invention, such as Figure 3As shown, the electronic device includes: one or more processors 310, a memory 320, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components utilize different buses to communicate with each other and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of a GUI on an external input / output device (such as a display device coupled to an interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 3 A processor 310 is taken as an example.

[0184] Processor 310 may be a central processing unit, a network processor, or a combination thereof. Processor 310 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic, or any combination thereof.

[0185] The memory 320 stores instructions that can be executed by at least one processor 310, so as to enable at least one processor 310 to execute the method shown in the above embodiment.

[0186] The memory 320 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created based on the use of an electronic device that displays a small program landing page, etc. In addition, the memory 320 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 320 may optionally include a memory remotely located relative to the processor 310, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a server cluster, a mobile communication network, and a combination thereof.

[0187] The memory 320 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid-state drive; the memory 320 may also include a combination of the above types of memory.

[0188] The electronic device further includes a communication interface 330 for the electronic device to communicate with other devices or a communication network.

[0189] An embodiment of the present invention also provides a computer-readable storage medium, which stores at least one executable instruction. When the executable instruction runs on an electronic device / gas consumption prediction device, the electronic device / gas consumption prediction device executes the gas consumption prediction method in any of the above method embodiments.

[0190] An embodiment of the present invention further provides a computer program product, comprising computer instructions, which are used to enable a computer to execute the gas consumption prediction method of the first aspect or any corresponding embodiment thereof.

[0191] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system or other device. In addition, the embodiments of the present invention are not directed to any particular programming language.

[0192] In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the present invention may be practiced without these specific details. Similarly, in order to streamline the present invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of embodiments of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. The claims that follow the detailed description are hereby expressly incorporated into that detailed description, with each claim itself serving as a separate embodiment of the present invention.

[0193] Those skilled in the art will appreciate that the modules in the devices of the embodiments can be adaptively changed and installed in one or more devices different from the embodiments. The modules, units, or components in the embodiments can be combined into one module, unit, or component, and furthermore, they can be divided into multiple submodules, subunits, or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive.

[0194] It should be noted that the above embodiments illustrate rather than limit the invention, and that alternative embodiments may be devised by a person skilled in the art without departing from the scope of the appended claims. In the claims, any reference signs placed between brackets should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising several different elements and by means of appropriately programmed computers. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names. The steps in the above embodiments should not be understood as limiting the order of execution unless otherwise specified.

Claims

1. A method for predicting gas consumption, characterized in that: The method comprises: Obtain historical data related to gas consumption in the database corresponding to the target area; Performing time series analysis on the historical data to obtain initial gas usage characteristic data; Performing feature extraction on the initial gas usage characteristic data to obtain local gas usage characteristic data and global gas usage characteristic data; Based on the local gas usage characteristic data and the global gas usage characteristic data, a predicted value of gas usage in the target area is obtained.

2. The method according to claim 1, characterized in that The time series analysis of the historical data to obtain initial gas usage characteristic data includes: Performing feature expansion on each gas usage feature in the historical data to obtain a first gas usage feature; performing feature dimensionality reduction processing on the first gas usage feature to obtain a second gas usage feature; Performing a time series analysis on the second gas usage characteristic based on a target time window to obtain gas usage segment data; Gas usage characteristic sampling is performed on the gas usage segment data to obtain gas usage characteristic data of the target area at each sampling moment to form initial gas usage characteristic data.

3. The method according to claim 1, characterized in that The feature extraction of the initial gas usage characteristic data to obtain local gas usage characteristic data and global gas usage characteristic data includes: Performing forward feature extraction and reverse feature extraction on the initial gas usage feature data to obtain corresponding forward extraction features and reverse extraction features; Performing feature splicing on the forward extracted features and the reverse extracted features to obtain the local gas usage feature data; Each data position of the local gas usage characteristic data is encoded to obtain the global gas usage characteristic data.

4. The method according to claim 3, characterized in that The encoding of each data position of the local gas usage characteristic data to obtain the global gas usage characteristic data includes: Encoding each data position of the local gas usage characteristic data based on the encoding layer to obtain a position encoding matrix; Performing encoding fusion on the position coding matrix and the sinusoidal position coding matrix to obtain a fused coding matrix; Global feature extraction is performed on the fusion coding matrix based on a self-attention mechanism to obtain the global gas usage feature data.

5. The method according to claim 1, wherein The step of obtaining a predicted value of gas consumption in the target area based on the local gas consumption characteristic data and the global gas consumption characteristic data includes: Dimensionally aligning the local gas usage characteristic data with the global gas usage characteristic data to obtain a local gas usage characteristic matrix and a global gas usage characteristic matrix; Based on time dimension convolution gating, obtaining local feature weights corresponding to the local gas usage feature matrix and global feature weights corresponding to the global gas usage feature matrix; A predicted value of gas consumption in the target area is obtained based on the local feature weight, the global feature weight, the local gas consumption feature matrix, and the global gas consumption feature matrix.

6. The method according to claim 5, characterized in that The obtaining of the predicted value of gas consumption in the target area based on the local feature weight, the global feature weight, the local gas consumption feature matrix, and the global gas consumption feature matrix includes: Obtaining a global adjustment feature matrix based on the product of the global feature weight and the global gas usage feature matrix; Obtaining a local adjustment feature matrix based on the product of the local feature weight and the local gas usage feature matrix; Fusing the global adjustment feature matrix with the local adjustment feature matrix to obtain a fused feature matrix; The fused feature matrix is concatenated with the local gas consumption feature data and then input into a fully connected layer to obtain a predicted value of gas consumption.

7. The method according to claim 1, characterized in that After obtaining the predicted value of gas consumption in the target area based on the local gas consumption characteristic data and the global gas consumption characteristic data, the method further includes: Calculating the residual between the predicted gas consumption and the actual gas consumption; The local gas usage characteristic data is adjusted based on the residual.

8. A gas consumption prediction device, characterized in that: The device comprises: A data acquisition module, used to obtain historical data related to gas consumption in the database corresponding to the target area; A time series analysis module, configured to perform time series analysis on the historical data to obtain initial gas usage characteristic data; a feature extraction module, configured to extract features from the initial gas usage feature data to obtain local gas usage feature data and global gas usage feature data; The gas consumption prediction module is used to obtain a predicted value of the gas consumption in the target area based on the local gas consumption characteristic data and the global gas consumption characteristic data.

9. An electronic device, characterized in that: include: A processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform the operation of the gas consumption prediction method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The storage medium stores at least one executable instruction. When the executable instruction is executed on the electronic device, the electronic device executes the operation of the gas consumption prediction method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Equipment gas consumption data determination method, electronic equipment and storage medium

    CN121388553A