Fuel gas use prediction method and device based on intelligent fuel gas, medium and equipment
By constructing a prediction model that comprehensively considers gas usage data, environmental data and time series data, the problem of insufficient prediction accuracy in the prior art is solved, and higher prediction accuracy and more effective gas resource management are achieved.
Patent Information
- Application Number
- CN202411656027.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-03-28
AI Technical Summary
Existing gas usage prediction methods rely on historical data and fail to effectively consider environmental factors and other external influencing factors, resulting in insufficient prediction accuracy, especially in the face of non-periodic changes or emergencies.
A gas usage prediction method based on smart gas is adopted to build a gas usage prediction model by collecting and preprocessing gas usage data, environmental data and time series data. The model introduces a time series module, a feature extraction module, a cross-modal attention mechanism and a multimodal fusion module to comprehensively process historical gas usage data, environmental data and time series data to improve prediction accuracy.
Significantly improve the accuracy of gas use forecasts, allowing forecast results to better adapt to non-periodic changes and emergencies, thereby helping users and suppliers manage gas resources more effectively, reducing waste, reducing operating costs and ensuring adequate supply.
Smart Images

Figure CN119719617A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart gas, and specifically to gas usage prediction methods, devices, media and equipment based on smart gas. Background Art
[0002] Existing gas usage forecasting methods usually rely on historical usage data, but rarely consider environmental factors and other external factors such as temperature, humidity, and holidays. Traditional forecasting methods only rely on trend analysis of historical data to make forecasts, which can reflect users' gas usage habits to a certain extent, but their forecast accuracy may be affected when faced with non-periodic changes or emergencies. Summary of the invention
[0003] The main purpose of this application is to provide a gas usage prediction method, device, medium and equipment based on smart gas. This application aims to solve the problem of insufficient prediction accuracy of existing gas prediction methods.
[0004] To achieve the above objectives, this application provides the following technical solutions:
[0005] A gas usage prediction method based on smart gas, the method comprising: collecting gas usage data, environmental data and time series data of a user to be predicted within a certain period of time; preprocessing the gas usage data, environmental data and time series data; building a gas usage prediction model, and training the gas usage prediction model; introducing a time series module and a feature extraction module into the gas usage prediction model to process historical gas usage data and environmental data and time series data respectively; inputting the preprocessed gas usage data, environmental data and time series data into the trained gas usage prediction model and outputting predicted gas usage to predict the gas usage of the user to be predicted.
[0006] Optionally, the gas usage data, environmental data and time series data are preprocessed, including: data cleaning the gas usage data, environmental data and time series data; filling missing values in the cleaned gas usage data, environmental data and time series data; and denoising the gas usage data, environmental data and time series data after missing values are filled.
[0007] Optionally, the gas usage prediction model includes: a time series module, used to capture short-term fluctuations and long-term trends in the historical gas data, and highlight data in key time periods; a feature extraction module, used to extract and filter out features most relevant to gas usage prediction from the environmental data and time series data; a cross-modal attention mechanism, used to dynamically assign weights to the data in the key time period and the features most relevant to gas usage prediction; a multimodal fusion module, used to perform multimodal fusion on the data in the key time period after weight assignment and the data most relevant to gas usage prediction to obtain fused features.
[0008] Optionally, the time series module includes: a bidirectional long short-term memory network, used to capture short-term fluctuations and long-term trends in historical gas usage data; and a hierarchical attention mechanism, used to identify data in key time periods in the short-term fluctuations and long-term trends.
[0009] Optionally, the feature extraction module includes: a feature extraction network, used to extract local features of the environmental data; a Transformer, used to capture global dependencies in the time series data; and an adaptive feature selection mechanism, used to identify features most relevant to gas usage prediction from the local features of the environmental data extracted by the feature extraction network and the time series data.
[0010] Optionally, the gas usage prediction model is trained through the following steps: collecting historical gas usage data, historical environmental data and historical time series data, and obtaining a gas usage data set after preprocessing the historical gas usage data, historical environmental data and historical time series data; dividing the gas usage data set into a training set and a validation set in proportion; setting training parameters, and training the gas usage prediction model through the training set until the maximum number of training times is reached; verifying the model with the validation set, and during the verification process, using accuracy, recall rate and F1 score as evaluation indicators to evaluate the performance of the model, and when each indicator reaches the preset value, the model verification passes; otherwise, adjusting the training parameters or expanding the training samples to re-train the model until the model verification passes.
[0011] In addition, the present application also provides a gas usage prediction device based on smart gas, which includes: a collection module, used to collect the gas usage data, environmental data and time series data of the user to be predicted within a certain period of time; a preprocessing module, used to preprocess the gas usage data, environmental data and time series data; a model construction and training module, used to construct a gas usage prediction model and train the gas usage prediction model; a prediction module, used to input the preprocessed gas usage data, environmental data and time series data into the trained gas usage prediction model and output the predicted gas usage, so as to predict the gas usage of the user to be predicted.
[0012] Optionally, the preprocessing module includes: a data cleaning submodule, used to clean the gas usage data, environmental data and time series data; a missing value filling submodule, used to fill missing values in the cleaned gas usage data, environmental data and time series data; a time series processing submodule, used to perform time series processing on the gas usage data and environmental data after the missing values are filled; and a denoising submodule, used to perform denoising on the gas usage data, environmental data and time series data after the missing values are filled.
[0013] In addition, the present application also provides a storage medium, which includes instructions, and when the instructions are executed on a computer, the computer executes the method as described in any of the preceding items.
[0014] In addition, the present application also provides an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the methods described above when executing the program.
[0015] Compared with the prior art, this application has the following technical effects:
[0016] The present application constructs a gas usage prediction model, which can significantly improve the accuracy of gas usage prediction by integrating a time series module, a feature extraction module, a cross-modal attention mechanism, and a multimodal fusion module, so that the prediction results can better adapt to non-periodic changes and emergencies, thereby helping users and suppliers to manage gas resources more effectively. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a flowchart of a gas usage prediction method based on smart gas provided by an embodiment of the present application;
[0018] Figure 2 is a schematic diagram of a network structure of a gas usage prediction model provided by another embodiment of the present application;
[0019] Figure 3 is a schematic diagram of the structure of a feature extraction network provided by another embodiment of the present application;
[0020] Figure 4 is a schematic diagram of the structure of a residual module provided in another embodiment of the present application;
[0021] Figure 5 is a structural diagram of a multi-task learning module provided by another embodiment of the present application;
[0022] Figure 6 is a structural schematic diagram of a gas usage prediction device based on smart gas provided in another embodiment of the present application;
[0023] Figure 7 is a schematic diagram of the structure of a storage medium provided by another embodiment of the present application;
[0024] Figure 8 It is a structural schematic diagram of an electronic device provided in another embodiment of the present application. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0026] It should be noted that all directional indications in the embodiments of the present application (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0027] In this application, unless otherwise clearly specified and limited, the terms "connection", "fixation", etc. should be understood in a broad sense. For example, "fixation" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0028] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the meaning of "and / or" appearing in the full text includes three parallel schemes. Taking "A and / or B" as an example, it includes scheme A, or scheme B, or a scheme that satisfies both A and B. In addition, the technical solutions between the various embodiments can be combined with each other, but it must be based on the ability of ordinary technicians in the field to implement. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0029] Figure 1 FIG. 1 is a flow chart of a method for predicting gas usage based on smart gas according to an embodiment of the present application. Figure 1 As shown, the method includes:
[0030] S100: Collecting gas usage data, environmental data and time series data of the user to be predicted within a certain period of time, where the certain period of time is, for example, within the current month or week, and the gas usage data includes user ID, gas usage amount and usage time, and the environmental data includes temperature and humidity, and also includes external factors affecting gas usage, such as holiday information and other time series data;
[0031] S200: Preprocessing the gas usage data, environmental data and time series data;
[0032] S300: constructing a gas usage prediction model, and training the gas usage prediction model;
[0033] S400: Input the pre-processed gas usage data, environmental data and time series data into the trained gas usage prediction model and output the predicted gas usage to predict the gas usage of the user to be predicted.
[0034] This application can improve the prediction accuracy of gas usage by comprehensively considering gas usage data, environmental data, and time series data, and using machine learning models for processing, thereby solving the problem of inaccurate prediction caused by traditional methods that only rely on historical trends and ignore other influencing factors. Accurate predictions can help gas suppliers better plan gas inventory levels and reasonably arrange transportation and distribution plans, thereby reducing waste, reducing operating costs and ensuring adequate supply. In addition, it can help users prepare before the peak of gas consumption to avoid supply shortages.
[0035] In another exemplary embodiment, in step S200, preprocessing the gas usage data and the environmental data includes:
[0036] S201: performing data cleaning on the gas usage data, environmental data and time series data;
[0037] In this step, data cleaning includes removing duplicate records, correcting and deleting erroneous data entries, processing outliers (e.g., extreme values outside the normal range), etc.
[0038] S202: Filling missing values in the cleaned gas usage data, environmental data and time series data;
[0039] In this step, after data cleaning, some data may have missing values, so appropriate methods need to be used to fill these missing values. The filling strategy can be determined based on data characteristics and business logic. For example, the mean, median, or mode can be used to fill numerical data; for categorical data, the most frequent category can be used. In addition, if there is time series information in the data, time series interpolation can be used to estimate missing values.
[0040] S203: De-noising the gas usage data, environmental data and time series data after missing values are filled.
[0041] In this step, methods including but not limited to smoothing filtering, moving average, median filtering, etc. may be used to perform noise reduction processing on the gas usage data and environmental data to help improve the generalization ability of the gas usage prediction model.
[0042] In another exemplary embodiment, Figure 2 As shown, the gas usage prediction model includes a time series module, a feature extraction module, a cross-modal attention mechanism and a multimodal fusion module.
[0043] In this embodiment, the time series module includes a bidirectional long short-term memory network (Bi-LSTM) and a hierarchical attention mechanism, wherein the bidirectional long short-term memory network (Bi-LSTM) can simultaneously learn the characteristics of gas usage changes over time in historical gas usage data from both the front-to-backward and the back-to-forward directions, thereby capturing short-term fluctuations and long-term trends in the user's historical gas usage data, wherein short-term fluctuations usually involve changes in gas usage in a relatively short period of time (such as a few hours or a few days), specifically related to specific events such as an increase in home heating demand due to a sudden drop in temperature, or an increase in cooking activities caused by a special holiday. The long-term trend reflects the trend of gas usage gradually developing over time, which may be caused by seasonal changes, such as gas usage in winter is generally higher than in summer, or due to slow changes in user living habits. By learning from both the front-to-backward and the back-to-forward directions, the bidirectional long short-term memory network (Bi-LSTM) can integrate short-term fluctuations and long-term trends, thereby more accurately understanding the behavioral characteristics of gas usage and making predictions about future usage based on this. For example, in the cold season, if a one-time temperature drop is detected, the Bi-LSTM network will not only take into account this short-term fluctuation, but also combine the long-term trend to evaluate whether the user will continue to increase gas usage in the next period of time.
[0044] The output of the bidirectional long short-term memory network (Bi-LSTM) is then passed to the hierarchical attention mechanism, which is used to enhance important time step data, that is, the hierarchical attention mechanism will help the gas usage prediction model identify which time periods have more valuable data for prediction and give these data higher weights. In this way, important time step data will be more significantly taken into account in the prediction process, thereby improving the accuracy of the overall prediction. Among them, the time step data refers to the data at each time point sampled at a certain time interval in the time series data. For gas usage prediction, the time step data can be the gas usage recorded once every hour, day or month. For example, if the user's gas usage is recorded once a day, then each time step represents a day's data. By analyzing these time step data, the hierarchical attention mechanism can identify which time points are particularly important for future gas usage predictions and give these key time points higher weights. In this way, when the gas usage prediction model predicts future gas usage, the information of those time points that are considered more important will be given more attention. For example, suppose there was an unusually cold period in the past few months, which led to a significant increase in users' gas usage during that period. In this case, the data during this period (i.e., the corresponding time steps) may be considered as particularly important information by the hierarchical attention mechanism because they can well reflect the impact of temperature changes on gas usage. Therefore, the hierarchical attention mechanism will assign a higher weight to the gas usage data during this cold period, so that the gas usage prediction model can better consider the impact of factors such as sudden temperature drops on gas usage when making future predictions.
[0045] Specifically, the output of the bidirectional long short-term memory network (Bi-LSTM) is expressed as:
[0046]
[0047] in, represents the output of the forward LSTM layer, Represents the output of the backward LSTM layer.
[0048] The hierarchical attention mechanism is expressed as:
[0049]
[0050] e t =V T tanh(W a [h t ;c])
[0051] Among them, a t represents the attention weight at time point t, et represents the attention energy at time point t, e t' represents the attention energy at time point t', V represents the learnable vector in the hierarchical attention mechanism, T represents the transpose of V, and W a represents the weight matrix in the attention mechanism, h t represents the Bi-LSTM hidden state, c represents the context vector, and h t and a t Multiply and sum to get the value.
[0052] The hierarchical attention mechanism can dynamically and adaptively determine the importance of data at different time steps, so that the gas usage prediction model can focus more on the data that is most critical to the current task when processing sequence data.
[0053] The feature extraction module includes a feature extraction network, a Transformer, and an adaptive feature selection mechanism, wherein the feature extraction network is used to extract local features of the environmental data. The Transformer is used to process time series data such as holiday information to capture global dependencies in these data. For example, family members may spend more time at home during holidays, resulting in increased gas usage. The Transformer can automatically identify these dependencies through a self-attention mechanism and incorporate them into the final prediction model. The adaptive feature selection mechanism is responsible for identifying the features most relevant to gas usage prediction from the local features in the environmental data extracted by the feature extraction network and the time series data, such as but not limited to historical gas usage (the user's past gas usage is the basis for predicting future usage, because the user's behavior pattern often has a certain continuity), ambient temperature (temperature changes directly affect the demand for gas, especially in seasons with high heating or cooling demand), time information (including specific time periods (such as morning and evening peaks), days of the week, months, etc., which are important factors affecting gas usage), user behavior patterns (user behavior patterns in different time periods, such as cooking time, bathing time, etc., these habits may change with the seasons or personal preferences) and weekday and non-workday patterns (the gas usage patterns on weekdays and non-workdays may be quite different, especially household users may have more cooking or hot water needs during holidays), thereby helping to reduce redundant information and ensure that the gas usage prediction model only focuses on the features that contribute most to the prediction results, thereby improving the accuracy of the prediction.
[0054] The output of the feature extraction module is expressed as follows:
[0055] z=σ(W z [f CNN ;f Trans ]+bz )
[0056] Among them, z represents the feature selection vector, σ represents the sigmoid activation function, and W z represents the weight matrix in the feature extraction module, f CNN represents the output of the feature extraction network, f Trans represents the output of Transformer, b z Represents the bias term in the feature extraction module.
[0057] The cross-modal attention mechanism is set after the time series module and the feature extraction network, and is used to further dynamically select the features most relevant to the gas usage prediction model from the features extracted by the time series module and the feature extraction network. The cross-modal attention mechanism assigns different weights to data of different modalities to ensure that the gas usage prediction model can focus more on features that are closely related to gas usage, thereby improving the accuracy of the prediction. The cross-modal attention mechanism dynamically adjusts the influence of different features to ensure that the gas usage prediction model is more flexible and effective in processing multimodal information, thereby improving the prediction accuracy of the gas usage prediction model.
[0058] The cross-modal attention mechanism is expressed as follows:
[0059]
[0060] g t =u T tanh(V g [h t ;f ext ])
[0061] Among them, β represents the cross-modal attention weight, and the attention energy g of each modality is calculated through the Softmax function. t After normalization, g t represents the cross-modal attention energy at time point t, g m represents the attention energy value in the mth modality, u represents the learnable vector in the cross-modal attention mechanism, V g Represents the weight matrix in the cross-modal attention mechanism.
[0062] The multimodal fusion module uses a gating mechanism to control the transmission of information from different modalities to ensure that the gas usage prediction model can flexibly fuse multiple features, wherein the gating mechanism determines which features should be retained and which should be ignored by adjusting the switch state of the information flow. In the gas usage prediction model, the gating mechanism can help the gas usage prediction model adjust the influence of each information source according to the actual situation when fusing data from different sources (i.e., data processed by the time series module and the feature extraction module). In this way, the gas usage prediction model can more intelligently process and integrate various factors that affect gas usage. For example, if the change in ambient temperature over a period of time has a greater impact on gas usage than the impact of holiday information, the gating mechanism will adjust the weight accordingly, so that the ambient temperature data occupies a larger proportion in the prediction process. Vice versa, if holiday information has a greater impact on gas usage, the gating mechanism will correspondingly reduce the weight of ambient temperature data and increase the impact of holiday information. Specifically, the gating mechanism in the multimodal fusion module is expressed as follows:
[0063] y=g·(h t +f ext )+(1-g)·y prev
[0064] Among them, y represents the final fusion output, h t represents the hidden state of Bi-LSTM at time point t, f ext represents the external feature variable, g represents the gate vector, which is calculated by an MLP network that receives h t and f ext As input, and through the sigmoid activation function, y prev Represents the prediction result of the previous step.
[0065] In summary, the present application introduces a gating mechanism and controls the transmission of information of different modalities, thereby ensuring the flexibility and effectiveness of the gas usage prediction model when integrating multiple information sources, thereby improving the prediction accuracy of the gas usage prediction model.
[0066] It should be noted that the present application introduces a time series module and a feature extraction module, and processes historical gas usage data, environmental data and time series data respectively. This comprehensive processing method enables the gas usage prediction model to have a more comprehensive and in-depth understanding of the various factors affecting gas usage, thereby improving the accuracy of the prediction.
[0067] like Figure 3As shown, the feature extraction network includes an input layer, a mixed-scale convolution module, an adaptive receptive field module, a residual learning module, an attention mechanism, a feature pyramid network (FPN), a multi-task learning module and a dynamic convolution kernel module connected in sequence.
[0068] Among them, the mixed-scale convolution module contains multiple parallel convolution kernels of different sizes (such as 3×3, 5×5, 7×7), which process the input data in parallel. Each size of convolution kernel is responsible for capturing local features in environmental data such as humidity and temperature from different angles. For example, the 3×3 convolution kernel can capture fine-grained changes in environmental data, such as rapid fluctuations in temperature and humidity in a short period of time; the 5×5 convolution kernel can capture the trend changes of temperature or humidity over a period of time, such as the changing law of temperature difference between morning and evening in a day; the 7×7 convolution kernel can capture more extensive contextual information, such as climate patterns within a week or longer. The feature maps processed by each convolution kernel will be spliced together to form a multi-scale feature representation, which can capture the information in the input data more comprehensively. In addition, the mixed-scale convolution module also contains a 1×1 convolution kernel, which works in parallel with the aforementioned 3×3 convolution kernel, 5×5 convolution kernel and 7×7 convolution kernel to reduce the dimension of the input data in the channel dimension, thereby reducing the cost of subsequent calculations. Although the 1×1 convolution kernel has no spatial receptive field (unlike 3×3, 5×5 and other convolution kernels that have expansion in the horizontal and vertical directions), it can be linearly combined between channels, playing a role similar to a bottleneck layer, reducing the number of input channels, thereby reducing the number of parameters and computational complexity, while retaining the effectiveness of the information.
[0069] The adaptive receptive field module is used to dynamically adjust the receptive field size, which includes a small sub-network, which includes an input layer, a prediction layer and an output layer connected in sequence, wherein the input layer is used to receive the original environmental data as input, and calculate the statistical information of the input data, such as the mean, variance, etc., which are used to subsequently predict the convolution kernel size; the prediction layer predicts the convolution kernel size required for each pixel based on the statistical information of the input data through one or more layers of neural networks (for example, the prediction layer can be composed of one or three fully connected layers connected in sequence, and a ReLU activation function is set at the end of the fully connected layer); the output layer is used to output the predicted convolution kernel size information, which will guide the adaptive receptive field module to perform convolution operations on the input data. In the application scenario of gas usage prediction described in the present application, the adaptive receptive field module captures the features in the input data that are closely related to gas usage by dynamically adjusting the convolution kernel size. For example, rapid fluctuations in temperature in a short period of time may require a smaller receptive field to capture, while changes in climate patterns over a long period of time may require a larger receptive field to obtain.
[0070] like Figure 4 As shown, the residual learning module includes an input layer, a 3×3 convolution layer, a batch normalization layer, a 3×3 convolution layer, a batch normalization layer and a ReLU activation function connected in sequence, and between two 3×3 convolution layers, the original input received by the input layer is transmitted to the output end of the residual learning through a jump connection, and the feature map after convolution processing by the two 3×3 convolution layers is added to the input transmitted by the jump connection and then passed through the ReLU activation function to finally obtain the output of the residual learning module. By using the residual learning module, on the one hand, the gas usage prediction model can learn the residual mapping instead of the original mapping, which helps to alleviate the gradient vanishing problem in the deep network; on the other hand, it makes the gas usage prediction model more stable and accurate when processing complex and long-period historical gas usage data, so as to improve the accuracy of gas usage prediction.
[0071] The attention mechanism module is located after the residual learning module. The attention mechanism emphasizes those important areas or features that are closely related to gas usage by assigning different weights to different parts of the input data, so that the gas usage prediction model can focus more on those important factors that affect gas usage (for example, including the gas usage during peak hours, the attention mechanism can identify the data of these time periods and assign higher weights, so that the gas usage prediction model pays more attention to the usage patterns of these time periods during the prediction process; for example, it also includes gas usage patterns. There are differences in gas usage patterns on weekdays and weekends. For example, family members spend more time at home on weekends, which may lead to increased gas usage. The attention mechanism can identify this difference and assign different weights during the prediction process), thereby improving the accuracy of the prediction of the gas usage prediction model. In addition, the attention mechanism can provide more transparency for the decision-making process of the gas usage prediction model by generating a visualized attention weight distribution, which helps to understand how the gas usage prediction model makes predictions and can be used to diagnose whether the gas usage prediction model correctly focuses on the key factors affecting gas usage.
[0072] The feature pyramid network (FPN) can enhance the gas usage prediction model's ability to represent features of different scales by fusing feature maps of different levels in a top-down manner, so that the gas usage prediction model can simultaneously capture subtle changes in a short period of time (for example, a sharp change in temperature in a short period of time may affect gas usage) and macro trends in a long period of time (for example, seasonal changes will also affect the overall usage trend). By fusing features of different scales, the feature pyramid network (FPN) helps to improve the generalization ability of the gas usage prediction model, so that the gas usage prediction model can not only identify gas usage patterns under different environmental conditions, but also make reasonable predictions in new environments.
[0073] Furthermore, the feature extraction network can handle multiple related tasks, such as classification and regression, by introducing a multi-task learning module. These tasks share the basic feature extraction layer, but at the end they have different branches corresponding to different tasks. Figure 5 As shown, the multi-task learning module includes an input layer, a shared feature extraction layer, a first task branch (classification task) and a second task branch (regression task) connected in sequence, wherein the first task branch is used to identify the pattern of working days and non-working days, specifically including 3 fully connected layers and a Softmax layer connected in sequence; the second task branch is used to predict the specific gas usage, specifically including 3 fully connected layers and a linear layer connected in sequence, the first task branch obtains features from the shared feature extraction layer, and processes them through 3 fully connected layers (the 3 fully connected layers are only exemplary and can be adjusted according to actual conditions), and finally outputs the classification result of working days through a Softmax layer; the second task branch obtains features from the shared feature extraction layer, and processes them through 3 fully connected layers (the 3 fully connected layers are only exemplary and can be adjusted according to actual conditions), and finally outputs the specific gas usage through a linear layer. Among them, the first task branch (classification task) uses a cross entropy loss function, which is expressed as follows:
[0074]
[0075] Where N represents the total number of samples, y i represents the true label (0 or 1) of the i-th sample, It represents the probability that the model predicts that the i-th sample belongs to category 1.
[0076] The second task branch (regression task) uses the mean square error loss function, which is expressed as follows:
[0077]
[0078] Among them, δ represents the threshold, which is used to distinguish when to use the mean square error and when to use the absolute error, y represents the true value of the sample, Represents the model's predicted value for the sample.
[0079] The total loss function composed of the cross entropy loss function and the mean square error loss function is expressed as:
[0080] L total =α·L CE +(1-α)·L MSE
[0081] Among them, α is a coefficient between 0 and 1, which is used to balance the contribution between classification tasks and regression tasks. When α is close to 1, the model pays more attention to classification tasks; when α is close to 0, the model pays more attention to regression tasks; when α is equal to 0.5, classification and regression tasks are equally important.
[0082] The total loss function shown above takes into account the performance of both classification and regression tasks. By setting weights appropriately, the gas usage prediction model can achieve the best balance when performing multiple related tasks, that is, while ensuring classification accuracy, it also ensures accurate prediction of gas usage. Such a design helps capture more potential factors that affect gas usage, such as the impact of holidays on gas usage and the specific usage changes.
[0083] The multi-task learning module completes specific tasks through different branches on the basis of sharing underlying features, thus avoiding repeated extraction of similar features, thereby reducing the consumption of computing resources and improving the computational efficiency of the gas usage prediction model. In addition, the multi-task learning module can capture more potential factors that affect gas usage by sharing information between different tasks. For example, the weekday classification task can help the gas usage prediction model understand the impact of holidays on gas usage, while the regression task focuses on specific usage predictions. The combination of the two can more accurately reflect the real-world gas usage.
[0084] The dynamic convolution kernel module includes an input layer, a feature processing layer (composed of 2 convolution layers), a convolution kernel generation layer, a dynamic convolution layer and an output layer connected in sequence. The input layer is used to receive the data output by the multi-task learning module, the feature processing layer is used to further process the input data and extract information for generating the dynamic convolution kernel; the convolution kernel generation layer generates a convolution kernel suitable for the current input feature based on the information extracted by the feature processing layer. The generation of the dynamic convolution kernel can be regarded as a mapping function:
[0085] K=g(X)
[0086] Among them, g represents the generation of the corresponding convolution kernel K based on the input feature map X.
[0087] The dynamic convolution layer uses the convolution kernel generated by the convolution kernel generation layer to perform convolution operations on the input data. The dynamic convolution layer can flexibly adjust the size and shape of the convolution kernel according to the characteristics of the input data to enhance the model's adaptability to the diversity of input data; the output layer is used to output the data processed by the dynamic convolution, which will be used for the final classification or regression task. The operation of the dynamic convolution layer can be represented by the following function:
[0088] Y=f(X,K)
[0089] Among them, X represents the input feature map, K represents the dynamic convolution kernel obtained by the convolution kernel generation layer, f represents the convolution operation, and Y represents the output feature map after the convolution operation.
[0090] The dynamic convolution kernel module can flexibly adjust the size and shape of the convolution kernel according to the characteristics of the input data, thereby enhancing the adaptability of the gas usage prediction model to the diversity of input data, so that the gas usage prediction model can better handle historical gas usage data with different time spans and different feature distributions, making the prediction more accurate. In addition, the dynamic convolution kernel module can generate the optimal convolution kernel according to the characteristics of the input data, that is, the dynamic convolution kernel module can improve the computational efficiency by reducing unnecessary calculations while maintaining high accuracy. In particular, for different time scale features in the gas usage data, the dynamic convolution kernel can effectively perform feature extraction without introducing additional computational burden.
[0091] Below, the present application describes the processing process of the gas usage prediction model proposed in the present application through a set of specific gas data collected from a certain user:
[0092] This application collects the following historical gas usage data and environmental data, where the historical gas usage data is:
[0093] User ID: Li
[0094] Historical gas usage: [120m 3 ,115m 3 ,122m 3 ,118m 3 ,125m 3 ,130m 3 ,128m 3 ,123m 3 ,121m 3 ,119m 3 ,124m 3 ,126m 3 ,127m 3 ,132m 3 ,131m 3 ,133m 3 ,134m 3 ,135m 3 ,136m 3 ,137m 3 ]
[0095] Use time: [2024-01-01, 2024-01-08, 2024-01-15, 2024-01-22, 2024-01-29, 2024-02-05, 2024-02-12, 2024-02-19, 2024-02-26, 2024-03-05, 2024-03-12, 2024-03-19, 2024-03-26, 2024-04-02, 2024-04-09, 2024-04-16, 2024-04-23, 2024-04-30, 2024-05-07, 2024-05-14]
[0096] The environmental data are:
[0097] Temperature: [10℃,8℃,12℃,11℃,9℃,13℃,14℃,15℃,16℃,17℃,18℃,19℃,20℃,21℃,22℃,23℃,24℃,25℃,26℃,27℃]
[0098] Humidity: [50%,55%,52%,51%,53%,54%,56%,57%,58%,59%,60%,61%,62%,63%,64%,65%,66%,67%,68%,69%]
[0099] Holiday information is:
[0100] [non-holiday, Spring Festival, non-holiday ...]
[0101] Inputting the above data into the gas usage prediction model proposed in this application, the following prediction results can be obtained:
[0102] Time point to be predicted: May 21, 2024 (the next time point)
[0103] Environmental data: temperature 28°C, humidity 70%
[0104] Holiday information: Non-holidays
[0105] Gas usage in the previous week: 137m 3
[0106] Environmental data for the previous week: temperature 27°C, humidity 69%
[0107] Based on the above information, the model predicts the following results:
[0108] Forecasted gas usage: 138m 3
[0109] It should be noted that for gas suppliers, by predicting users' future gas demand, on the one hand, they can more effectively plan inventory and allocate resources, which helps to avoid cost waste caused by excessive reserves or shortages caused by insufficient supply; on the other hand, understanding users' gas usage patterns can help identify energy-saving potential. For example, before the forecast shows a high demand period, users can be reminded to take energy-saving measures to smooth out demand peaks, thereby reducing the impact of peak loads on the gas supply system. For users, comparing actual consumption data with predicted values can help detect gas anomalies. If there is a large deviation between the two, it may be caused by leakage or other technical problems, so it is necessary to check gas facilities in a timely manner to detect problems early to reduce safety hazards.
[0110] Furthermore, the present application compares the gas usage prediction model with traditional methods such as simple moving average method, exponential smoothing method, linear regression, seasonal decomposition time series prediction method, and based on mean square error (MSE), root mean square error (RMSE), mean absolute error (MAE) and determination coefficient (R 2 ) were evaluated, and the comparison results are shown in Table 1:
[0111] Table 1
[0112]
[0113] As shown in Table 1, this method is not only closest to the actual value in terms of prediction accuracy, but also has lower mean square error (MSE), root mean square error (RMSE) and mean absolute error (MAE), and has a higher coefficient of determination (R 2 ). This means that this method can not only predict future gas usage more accurately, but also fit the data better, reflecting the inherent laws of gas usage. Therefore, this method has more advantages than traditional methods in terms of prediction accuracy.
[0114] In another exemplary embodiment, in step S300, the gas usage prediction model is trained by the following steps:
[0115] S301: Collect historical gas usage data, historical environmental data, and historical time series data, and obtain a gas usage data set after preprocessing the historical gas usage data, historical environmental data, and historical time series data;
[0116] S302: Divide the gas usage data set into a training set and a validation set in proportion, and the division ratio may be 7:3;
[0117] S303: setting training parameters, setting the training batch size to 32, setting the number of training rounds to 100, setting the learning rate to 0.001, and training the gas usage prediction model through the training set until the maximum number of training times is reached;
[0118] S304: Use the validation set to validate the model. During the validation process, use accuracy, recall and F1 score as evaluation indicators to evaluate the performance of the model. When each indicator reaches the preset value (for example, the accuracy reaches 85%, the recall reaches 80%, and the F1 score reaches 0.8), the model validation is passed; otherwise, adjust the training parameters (for example, adjust the number of training rounds to 150, adjust the learning rate to 0.005) or expand the training samples (for example, adjust the ratio of the training set to the validation set to 8:2) to retrain the model until the model validation is passed.
[0119] In another exemplary embodiment, Figure 6 As shown, the present application also provides a gas usage prediction device based on smart gas, and the device includes: an acquisition module 100, used to collect gas usage data, environmental data and time series data of the user to be predicted in a current period; a preprocessing module 200, used to preprocess the gas usage data, environmental data and time series data; a model building and training module 300, used to build a gas usage prediction model and train the gas usage prediction model; a prediction module 400, used to input the preprocessed gas usage data, environmental data and time series data into the trained gas usage prediction model and output the predicted gas usage, so as to predict the gas usage of the user to be predicted.
[0120] Based on the above embodiments, Figure 7 , for an explanation of the computer-readable storage medium of the exemplary embodiment of the present application, please refer to Figure 7 , the computer-readable storage medium shown is a CD 40, on which a computer program (i.e., a program product) is stored. When the computer program is executed by the processor, each step recorded in the above method implementation will be implemented, for example, collecting the gas usage data, environmental data, and time series data of the user to be predicted within a certain period of time; preprocessing the gas usage data, environmental data, and time series data; building a gas usage prediction model, and training the gas usage prediction model; the gas usage prediction model introduces a time series module and a feature extraction module to process the historical gas usage data and environmental data and time series data respectively; the preprocessed gas usage data, environmental data, and time series data are input into the trained gas usage prediction model and the predicted gas usage is output to predict the gas usage of the user to be predicted. The specific implementation method of each step is not repeated here.
[0121] It should be noted that the computer-readable storage medium includes but is not limited to phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical or magnetic storage media, which are not listed here one by one.
[0122] Based on the above embodiments, the present application also provides an electronic device, as shown below: Figure 8 An electronic device for downloading a file according to an exemplary embodiment of the present application is described.
[0123] Figure 8 A block diagram of an exemplary electronic device 50 suitable for implementing the embodiments of the present application is shown, and the electronic device 50 may be a computer system or a cloud server. Figure 8 The electronic device 50 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0124] like Figure 8 As shown, the electronic device 50 includes but is not limited to: one or more processors or processing units 501, a system memory 502, and a bus 503 connecting different system components (including the system memory 502 and the processing unit 501).
[0125] The electronic device 50 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 50, including volatile and non-volatile media, removable and non-removable media.
[0126] The system memory 502 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 5021 and / or cache memory 5022. The electronic device 50 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the ROM 5023 may be used to read and write non-removable, non-volatile magnetic media ( Figure 8 is not shown in the Figure 8As shown in FIG. 5 , a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) can be provided. In these cases, each drive can be connected to bus 503 via one or more data medium interfaces. System memory 502 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of each embodiment of the present application.
[0127] A program / utility 5025 having a set (at least one) of program modules 5024 may be stored, for example, in system memory 502, and such program modules 5024 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 5024 generally perform the functions and / or methods of the embodiments described herein.
[0128] The electronic device 50 may also communicate with one or more external devices 504 (e.g., a keyboard, a pointing device, a display, etc.). Such communication may be performed via an input / output (I / O) interface 505. Furthermore, the electronic device 50 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 506. Figure 8 As shown, the network adapter 506 communicates with other modules (such as the processing unit 501, etc.) of the electronic device 50 via the bus 503. It should be understood that although Figure 8 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 50 .
[0129] The processing unit 501 executes various functional applications and data processing by running the program stored in the system memory 502, for example, collecting the gas usage data, environmental data and time series data of the user to be predicted within a certain period of time; preprocessing the gas usage data, environmental data and time series data; building a gas usage prediction model and training the gas usage prediction model; the gas usage prediction model introduces a time series module and a feature extraction module to process the historical gas usage data, environmental data and time series data respectively; inputs the preprocessed gas usage data, environmental data and time series data into the trained gas usage prediction model and outputs the predicted gas usage to predict the gas usage of the user to be predicted. The specific implementation of each step is not repeated here. It should be noted that although several units / modules or sub-units / sub-modules of the file concurrent downloading device are mentioned in the above detailed description, this division is only exemplary and not mandatory. In fact, according to the embodiment of the present application, the features and functions of two or more units / modules described above can be concretized in one unit / module. On the contrary, the features and functions of one unit / module described above may be further divided into multiple units / modules to be embodied.
[0130] In the description of the present application, it should be noted that the terms "first", "second" and "third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0131] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0132] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0133] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0134] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0135] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that can be executed by a processor. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a cloud server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0136] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A gas usage prediction method based on smart gas, characterized in that: The method comprises: Collect gas usage data, environmental data and time series data of the user to be predicted within a certain period of time; Preprocessing the gas usage data, environmental data and time series data; Constructing a gas usage prediction model and training the gas usage prediction model; the gas usage prediction model introduces a time series module and a feature extraction module to process historical gas usage data, environmental data and time series data respectively; The pre-processed gas usage data, environmental data and time series data are input into the trained gas usage prediction model and the predicted gas usage is output to predict the gas usage of the user to be predicted.
2. The method for predicting gas usage based on smart gas according to claim 1, characterized in that: Preprocessing the gas usage data, environmental data and time series data includes: Performing data cleaning on the gas usage data, environmental data and time series data; Filling missing values in the cleaned gas usage data, environmental data and time series data; The gas usage data, environmental data and time series data after missing value filling are subjected to noise reduction.
3. The method for predicting gas usage based on smart gas according to claim 1, characterized in that: The gas usage prediction model includes: A time series module is used to capture short-term fluctuations and long-term trends in the historical gas data and highlight data in key time periods; A feature extraction module, for extracting and filtering the most relevant features for gas usage prediction from the environmental data and time series data; A cross-modal attention mechanism for dynamically assigning weights to the data of the key time period and the features most relevant to the prediction of gas usage; The multimodal fusion module is used to perform multimodal fusion on the data of the key time period after weight allocation and the data most relevant to the gas usage prediction to obtain fusion features.
4. The method for predicting gas usage based on smart gas according to claim 3, characterized in that: The time series module includes: Bidirectional long short-term memory network to capture short-term fluctuations and long-term trends in historical gas usage data; A hierarchical attention mechanism is used to identify data in key time periods in the short-term fluctuations and long-term trends.
5. The method for predicting gas usage based on smart gas according to claim 3, characterized in that: The feature extraction module comprises: A feature extraction network, used to extract local features of the environmental data; Transformer, used to capture global dependencies in the time series data; An adaptive feature selection mechanism is used to identify the features most relevant to gas usage prediction from the local features of the environmental data extracted by the feature extraction network and the time series data.
6. The method for predicting gas usage based on smart gas according to claim 1, characterized in that: The gas usage prediction model is trained by the following steps: Collecting historical gas usage data, historical environmental data and historical time series data, and obtaining a gas usage data set after preprocessing the historical gas usage data, historical environmental data and historical time series data; Dividing the gas usage dataset into a training set and a validation set in proportion; Setting training parameters, and training the gas usage prediction model through the training set until a maximum number of training times is reached; The model is verified using the validation set. During the verification process, accuracy, recall and F1 score are used as evaluation indicators to evaluate the model performance. When all indicators reach the preset values, the model is verified. Otherwise, the training parameters are adjusted or the training samples are expanded to retrain the model until the model is verified.
7. A gas usage prediction device based on smart gas, characterized in that: The device comprises: The collection module is used to collect the gas usage data, environmental data and time series data of the user to be predicted within a certain period of time; A preprocessing module, used for preprocessing the gas usage data, environmental data and time series data; A model building and training module is used to build a gas usage prediction model and train the gas usage prediction model; the gas usage prediction model introduces a time series module and a feature extraction module to process historical gas usage data, environmental data and time series data respectively; The prediction module is used to input the pre-processed gas usage data, environmental data and time series data into the trained gas usage prediction model and output the predicted gas usage to predict the gas usage of the user to be predicted.
8. The gas usage prediction device according to claim 7, characterized in that: The preprocessing module comprises: A data cleaning submodule, used for cleaning the gas usage data, environmental data and time series data; A missing value filling submodule is used to fill missing values in the cleaned gas usage data, environmental data and time series data; A time series processing submodule, used for performing time series processing on the gas usage data and environmental data after missing values are filled; The denoising submodule is used to denoise the gas usage data, environmental data and time series data after the missing values are filled.
9. A storage medium, characterized in that: The method comprises instructions, which, when executed on a computer, enable the computer to execute the method according to any one of claims 1 to 6.
10. An electronic device, characterized in that: The electronic device comprises: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Fault detection method and system based on intelligent electric meter
CN121500226A