Machine learning based gas consumption prediction method
By constructing a gas consumption prediction model based on machine learning and combining user behavior and environmental analysis, the problem of insufficient dynamic adaptability in traditional methods has been solved, achieving more accurate gas consumption prediction and energy-saving suggestions, and improving the level of intelligence in energy management.
Patent Information
- Application Number
- CN202411750811.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2044-12-02
AI Technical Summary
Existing gas consumption prediction methods lack the ability to dynamically adapt to user behavior and environmental changes, and are difficult to handle nonlinear data, resulting in limitations in the accuracy and reliability of prediction results.
A machine learning-based approach was adopted to collect gas usage data through a wireless sensor network. By combining user behavior analysis, environmental parameter analysis, and time series analysis, an autoregressive integral moving average model was constructed. The model parameters were optimized using a Bayesian optimization method, and the model was updated using an adaptive learning algorithm to adapt to dynamic changes.
It significantly improves the accuracy and reliability of gas consumption forecasting, can dynamically adapt to changes in user behavior and the environment, provides accurate data support, and enhances the intelligence level of energy management and user satisfaction.
Smart Images

Figure CN119848653B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of energy management and forecasting technology, and in particular to a gas consumption forecasting method based on machine learning. Background Technology
[0002] In modern society, with the acceleration of urbanization and the improvement of residents' living standards, natural gas, as a major energy source, is increasingly widely used in homes and industries. The efficient use and energy management of natural gas has become an important issue. Traditional natural gas consumption forecasting methods mainly rely on historical consumption data and usually use simple linear regression or time series analysis methods for forecasting. Although these methods can provide basic consumption forecasts to a certain extent, they usually ignore the diversity of user behavior and the influence of environmental factors, such as seasonal changes, temperature and humidity, which leads to limitations in the accuracy and reliability of the forecast results.
[0003] The main problem facing current gas consumption prediction technology is the lack of dynamic adaptability to specific user behaviors and environmental changes. For example, users' gas usage habits may change due to seasonal changes, weather conditions, or personal habits. These changes are often difficult to capture accurately in existing prediction models. In addition, existing methods perform poorly when processing nonlinear data and cannot effectively cope with sudden or large-scale changes in gas usage. This limits the effectiveness and efficiency of prediction systems in practical applications.
[0004] Therefore, it is particularly urgent and necessary to develop a gas consumption prediction method that can comprehensively consider user behavior, environmental factors and their dynamic changes. Summary of the Invention
[0005] To achieve the above objectives, this invention provides a gas consumption prediction method based on machine learning.
[0006] A machine learning-based gas consumption prediction method includes the following steps:
[0007] S1: Collect gas usage data via wireless sensor network, including gas flow rate, usage time, and environmental parameters;
[0008] S2: Based on the data collected in S1, user behavior analysis algorithms are used to identify users' gas usage habits;
[0009] S3: Analyze the environmental parameter data in S1 to assess the impact of seasonal changes and weather conditions on gas consumption;
[0010] S4: Combining the analysis results of S2 and S3, a gas consumption prediction model is constructed using time series analysis techniques;
[0011] S5: The parameters of the gas consumption prediction model are optimized using the Bayesian optimization method to adapt to the nonlinearity and dynamic changes in gas consumption.
[0012] S6: Use the optimized model in S5 to make short-term and medium-term predictions of gas consumption;
[0013] S7: Based on actual consumption data and prediction results, use adaptive learning algorithms to update the parameters of user behavior analysis and environmental impact assessment;
[0014] S8: Generates a comprehensive report including gas consumption forecasts and energy-saving recommendations, and provides the report to users and gas suppliers through a two-way communication mechanism.
[0015] Optionally, S1 specifically includes:
[0016] S11: Configure a wireless sensor network, including a flow sensor, a time recorder, and an environmental sensor; wherein, the flow sensor is used to measure the real-time flow of gas; the time recorder is used to record the specific time period of gas use; and the environmental sensor is used to capture environmental parameters, including temperature, humidity, and air pressure.
[0017] S12: The flow sensor is deployed at the inlet of the gas pipeline and uses ultrasonic measurement technology to capture the flow data of the gas.
[0018] S13: The time recorder works synchronously with the flow sensor to record the start and end times of each gas usage, ensuring the accuracy of the time stamp for each data point;
[0019] S14: Environmental sensors are deployed in areas where users live or use gas. The environmental sensors include temperature sensors, humidity sensors, and air pressure sensors. The temperature sensors use thermocouples or thermistors to measure ambient temperature data. The humidity sensors use capacitive or resistive sensors to measure air humidity data. The air pressure sensors measure atmospheric pressure data through the piezoelectric effect.
[0020] S15: The data collected in S12, S13 and S14 are sent to the central data processing unit via the wireless transmission module.
[0021] S16: The central data processing unit receives data from each sensor and performs preliminary data synchronization and outlier detection.
[0022] Optionally, S2 specifically includes:
[0023] S21: Receives data collected from S1, including gas flow rate, usage time, and environmental parameters;
[0024] S22: Perform time series analysis on the received data to identify peak and off-peak periods of gas usage, as well as periodic patterns of gas usage;
[0025] S23: Gas usage data is classified using the K-means clustering algorithm, and users are divided into different groups according to their gas usage patterns, specifically cooking time and hot water usage time and frequency;
[0026] S24: Within each group, an association rule learning algorithm is applied to analyze cooking time preferences and hot water usage habits, identifying users' gas usage patterns under different time periods and environmental conditions; specifically, the Apr i or i algorithm is used to mine frequent itemsets and association rules, with the following formula:
[0027] Where A represents a certain behavior pattern of gas usage;
[0028] Here, B represents another behavioral pattern associated with A.
[0029] Optionally, S3 specifically includes:
[0030] S31: Receives environmental parameter data from S1, including ambient temperature, ambient humidity, and atmospheric pressure; and standardizes the environmental parameter data to eliminate the influence between different units.
[0031] S32: Perform correlation analysis between the standardized environmental parameter data and gas consumption data, and calculate the Pearson correlation coefficient between each environmental parameter and gas consumption.
[0032] S33: Divide the year into four seasons and analyze the average gas consumption in each season. The formula is: Among them, F season,k N represents the average gas consumption in the k-th season. k Let t represent the number of data points within the season, where t∈season,k represents all time points belonging to the k-th season;
[0033] S34: Combining the analysis results of S32 and S33, assess the impact of environmental parameters and seasonal variations on gas consumption, and generate an impact assessment report. The report includes the correlation between each environmental parameter and gas consumption, as well as the average gas consumption in each season.
[0034] Optionally, S4 specifically includes:
[0035] S41: Receive user gas usage habit data from S2 and environmental parameter and seasonal change impact data from S3; and integrate the user gas usage habit data and environmental parameter data into a time series to form a comprehensive dataset D, which includes gas flow, usage time, standardized environmental parameters and seasonal factors;
[0036] S42: Perform stationarity testing on the comprehensive dataset D, specifically using the unit root test to verify the stationarity of the time series data;
[0037] S43: If the data is not stationary, it can be transformed into a stationary sequence through differencing. The differencing formula is: Y t ′=Y t -Y t-1 , where ΔF t F represents the differential gas consumption. t and F t-1 These represent the gas consumption at times t and t-1, respectively.
[0038] S44: An autoregressive integral moving average model, i.e., a gas consumption prediction model, is constructed using a stationary series Y′ combined with standardized environmental parameters E′ and seasonal factors S. The expression is as follows:
[0039]
[0040] Where, ΔF t The difference in gas consumption over time t; For constant terms; θ represents the coefficient of the autoregressive term, indicating the weight of the i-th lag term; j E represents the coefficient of the moving average term, indicating the weight of the j-th error term; k,t ′ represents the k-th standardized environmental parameter at time t; S l,t Let β be the l-th seasonal variable at time t; k γ represents the regression coefficient of environmental parameters. l The regression coefficient for seasonal factors; ∈ t is the error term; p is the autoregression order; q is the moving average order.
[0041] Optionally, S5 specifically includes:
[0042] S51: Define the objective function of the gas consumption prediction model, specifically using the mean squared error as the evaluation index. The objective function is: Where N is the number of data points; F t The actual amount of gas used at time t; For time t, the predicted gas consumption;
[0043] S52: Select the set of parameters to be optimized for the gas consumption prediction model, including the coefficients of the autoregressive term. Moving average coefficient θ j The regression coefficient β of environmental parameters k Regression coefficient γ of seasonal factors l ;
[0044] S53: Optimize the objective function using the Bayesian optimization method;
[0045] S54: Update the set of parameters to be optimized in the gas consumption prediction model based on the optimal parameter combination obtained by Bayesian optimization.
[0046] Optionally, S53 specifically includes:
[0047] S531: Construct a surrogate model to approximate the distribution of the objective function in the parameter space. The expression of the surrogate model is: y = f(x) + ∈, where y is the objective function value; x is the parameter vector, including θ j ,β k and γ l f(x) is the true objective function; ∈ represents the error term, which follows a normal distribution.
[0048] S532: Based on the surrogate model, the next sampling point is selected using the expected improvement criterion. The formula for calculating the expected improvement is: EI(x)=E[max(0,f)(x) ] + )-f(x * )|D], where x + For the next sampling point; x * D represents the current optimal point; D represents the historical sampling dataset.
[0049] S533: Calculate at sampling point x + The objective function value at the sampling point is used to update the proxy model, and the new sampling point and its objective function value are added to the historical sampling dataset.
[0050] S534: Repeat S532 and S533 above until the preset stopping conditions are met, including the maximum number of iterations or the convergence of the objective function value.
[0051] Optionally, S6 specifically includes:
[0052] S61: Obtain the optimized parameters of the autoregressive integral moving average model;
[0053] S62: Define the input data for the gas consumption prediction model, including historical gas consumption data, environmental parameters and seasonal factors, and ensure that the dataset covers at least one year of data to reflect consumption patterns in different seasons;
[0054] S63: Apply the optimized model to predict short-term and medium-term gas consumption;
[0055] S64: Use the sliding window method to update the model's input data. As new data is added, the historical data in the window is continuously updated to maintain the model's timeliness and accuracy.
[0056] Optionally, S7 specifically includes:
[0057] S71: Collect actual gas consumption data and predicted consumption data, including short-term and medium-term forecast results from S6 and actual gas consumption for the corresponding time period;
[0058] S72: Calculate the error between actual consumption data and prediction results, using the mean absolute percentage error as the error evaluation index. The formula is: Where N is the number of data points; F t The actual amount of gas used at time t; For time t, the predicted gas consumption;
[0059] S73: Based on the calculated error value, determine whether the prediction model needs to be updated. Specifically, if the error exceeds a preset threshold, the model update will be triggered.
[0060] S74: The parameters for user behavior analysis and environmental impact assessment are updated using an adaptive learning algorithm. Specific steps include:
[0061] S741: Initialize the parameters of the adaptive learning algorithm, including the learning rate η and momentum μ, which are used to control the step size and speed of parameter updates;
[0062] S742: Update user behavior analysis parameters using gradient descent. The update formula for gradient descent is: Where, θ i,t Let be the i-th user behavior parameter at time t; L be the loss function; η be the learning rate; and μ be the momentum.
[0063] S743: Update the parameters of the environmental impact assessment using the same gradient descent method;
[0064] S75: Re-input the updated user behavior analysis parameters and environmental impact assessment parameters into the prediction model to conduct the next round of gas consumption prediction;
[0065] S76: Repeat the process from S71 to S75 periodically to ensure that the predictive model can dynamically adapt to changes in user behavior and the environment.
[0066] Optionally, S8 specifically includes:
[0067] S81: Collect and organize the gas consumption forecast results from S6, including short-term and medium-term gas usage forecast data;
[0068] S82: Analyze the prediction results, combine user behavior analysis data and environmental impact assessment data, and generate energy-saving recommendations, including specific measures to optimize gas usage time, improve equipment efficiency, and reduce waste;
[0069] S83: Compile a comprehensive report, including gas consumption forecast results, energy-saving recommendations, user behavior analysis, and environmental impact assessment;
[0070] S84: Provide comprehensive reports to users and gas suppliers through a two-way communication mechanism, specifically including the following steps:
[0071] S841: Generate unique access credentials for each user and gas supplier;
[0072] S842: Upload the comprehensive report to a secure cloud server via the Internet, allowing users and gas suppliers to log in and view the report using access credentials;
[0073] S843: Provides a feedback function, allowing users and gas suppliers to provide comments and suggestions on the report content through an online platform;
[0074] S844: Regularly update reports, incorporating the latest gas consumption data and user feedback to continuously improve and optimize report content and energy-saving recommendations.
[0075] The beneficial effects of this invention are:
[0076] This invention significantly improves the accuracy and reliability of predictions by integrating user behavior analysis with the influence of environmental parameters. Traditional methods often fail to fully consider the diversity of individual user behavior and the real-time impact of environmental changes, such as temperature, humidity, and seasonal variations. However, this invention uses advanced data analysis techniques, such as the Autoregressive Integrated Moving Average (ARI MA) model and Bayesian optimization, to dynamically adapt to changes in these factors. This method enables gas consumption prediction to not only reflect historical trends but also adapt to possible future changes, thereby providing more accurate data support for gas suppliers and users and helping them to plan gas usage and energy-saving measures more effectively.
[0077] This invention provides forecast results and energy-saving suggestions through a two-way communication mechanism, further enhancing the interaction and communication between users and suppliers. This mechanism not only ensures the transparency and timely updates of information, but also allows users to provide feedback based on their actual consumption, enabling the forecast model to be continuously optimized and adjusted. This continuous feedback and update cycle ensures the long-term effectiveness and adaptability of the forecast system in actual operation, greatly improving the level of intelligence in energy management and user satisfaction, while also promoting the rational use of energy resources and the realization of energy conservation and emission reduction. Attached Figure Description
[0078] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only for this invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0079] Figure 1 This is a schematic diagram of the gas consumption prediction method according to an embodiment of the present invention;
[0080] Figure 2 This is a schematic diagram illustrating the process of constructing a gas consumption prediction model according to an embodiment of the present invention. Detailed Implementation
[0081] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. It should also be noted that, to make the embodiments more comprehensive, the following embodiments are the best and preferred embodiments, and those skilled in the art can use other alternative methods to implement some well-known technologies; moreover, the accompanying drawings are only for more specific description of the embodiments and are not intended to specifically limit the present invention.
[0082] It should be noted that the use of terms such as "an embodiment," "an embodiment," "an exemplary embodiment," and "some embodiments" in the specification indicates that the described embodiment may include a specific feature, structure, or characteristic, but not every embodiment necessarily includes that specific feature, structure, or characteristic. Furthermore, when a specific feature, structure, or characteristic is described in connection with an embodiment, implementing such a feature, structure, or characteristic in conjunction with other embodiments (whether explicitly described or not) should be within the knowledge of those skilled in the art.
[0083] Generally, terms can be understood at least partly from their use in context. For example, depending at least partly on the context, the term "one or more" as used herein can be used to describe any feature, structure, or characteristic in a singular sense, or a combination of features, structures, or characteristics in a plural sense. Additionally, the term "based on" can be understood not necessarily to convey an exclusive set of factors, but rather, alternatively, depending at least partly on the context, to allow for the presence of other factors that are not necessarily explicitly described.
[0084] like Figures 1-2 As shown, the gas consumption prediction method based on machine learning includes the following steps:
[0085] S1: Collect gas usage data via wireless sensor network, including gas flow rate, usage time, and environmental parameters (such as temperature and humidity);
[0086] S2: Based on the data collected in S1, user behavior analysis algorithms are used to identify users' gas usage habits;
[0087] S3: Analyze the environmental parameter data in S1 to assess the impact of seasonal changes and weather conditions on gas consumption;
[0088] S4: Combining the analysis results of S2 and S3, a gas consumption prediction model is constructed using time series analysis techniques;
[0089] S5: The parameters of the gas consumption prediction model are optimized using the Bayesian optimization method to adapt to the nonlinearity and dynamic changes in gas consumption.
[0090] S6: Use the optimized model in S5 to make short-term and medium-term predictions of gas consumption;
[0091] S7: Based on actual consumption data and prediction results, use adaptive learning algorithms to update the parameters of user behavior analysis and environmental impact assessment to improve prediction accuracy and system adaptability;
[0092] S8: Generates a comprehensive report including gas consumption forecasts and energy-saving recommendations, and provides the report to users and gas suppliers through a two-way communication mechanism.
[0093] The specific data collected in S1 related to gas usage includes:
[0094] S11: Configure a wireless sensor network, including a flow sensor, a time recorder, and an environmental sensor; wherein, the flow sensor is used to measure the real-time flow of gas; the time recorder is used to record the specific time period of gas use; and the environmental sensor is used to capture environmental parameters, including temperature, humidity, and air pressure.
[0095] S12: The flow sensor is deployed at the inlet of the gas pipeline and uses ultrasonic measurement technology to accurately capture the gas flow data; this ultrasonic measurement technology calculates the gas flow rate based on the time difference of the signal propagation by transmitting and receiving ultrasonic signals.
[0096] S13: The time recorder works synchronously with the flow sensor to record the start and end times of each gas usage, ensuring the accuracy of the time stamp for each data point;
[0097] S14: Environmental sensors are deployed in areas where users live or use gas. Environmental sensors include temperature sensors, humidity sensors, and air pressure sensors. Temperature sensors use thermocouples or thermistors to measure ambient temperature data. Humidity sensors use capacitive or resistive sensors to measure air humidity data. Air pressure sensors measure atmospheric pressure data through the piezoelectric effect.
[0098] S15: The data collected in S12, S13 and S14 is sent to the central data processing unit via the wireless transmission module; the wireless transmission module uses low-power Bluetooth or Wi-Fi technology to ensure the real-time performance of the data and the energy efficiency of the transmission.
[0099] S16: The central data processing unit receives data from various sensors and performs preliminary data synchronization and outlier detection, providing a clean and integrated dataset for subsequent data preprocessing and analysis;
[0100] By combining the above steps, the accuracy and reliability of gas consumption data collection are improved. This method makes gas consumption prediction more accurate, which helps to optimize gas use and save energy. At the same time, through real-time data transmission and efficient data processing, the system's response speed and user satisfaction are greatly improved.
[0101] S2 specifically includes:
[0102] S21: Receives data collected from S1, including gas flow rate, usage time, and environmental parameters;
[0103] S22: Perform time series analysis on the received data to identify peak and off-peak periods of gas usage, as well as periodic patterns in gas usage; specifically, use the autocorrelation function (ACF) to identify periodic patterns in gas usage, the formula is: Where τ is the lag period, N is the number of data points, and F t μ represents the amount of gas used at time t. F and σ F These are the mean and standard deviation of gas consumption, respectively.
[0104] S23: Gas usage data is classified using the K-means clustering algorithm, dividing users into different groups based on their gas usage patterns, specifically cooking time and the time and frequency of hot water use; the objective function of the K-means clustering algorithm is: Where k is the number of clusters, C i For the i-th cluster, μ i Let F be the mean of the i-th cluster, and F be the value belonging to C. i Gas usage data points;
[0105] S24: Within each group, an association rule learning algorithm is applied to analyze cooking time preferences and hot water usage habits, identifying users' gas usage patterns under different time periods and environmental conditions; specifically, the Apriliori algorithm is used to mine frequent itemsets and association rules, with the following formula:
[0106] Where A represents a certain behavior pattern of gas usage;
[0107] Here, B represents another behavioral pattern associated with A. By describing the steps and technologies used in user behavior analysis, the identification of users' gas usage habits becomes more accurate. This method not only improves the accuracy of predictions but also dynamically adjusts the prediction model based on changes in user behavior, thereby optimizing gas usage efficiency and energy-saving effects.
[0108] S3 specifically includes:
[0109] S31: Receives environmental parameter data from S1, including ambient temperature, ambient humidity, and atmospheric pressure; and standardizes the environmental parameter data to eliminate the influence between different units, ensuring that the mean of each parameter is zero and the standard deviation is one, using the following formula: Among them, E i,t This represents the i-th environmental parameter at time t. and These represent environmental parameters E respectively. i The mean and standard deviation;
[0110] S32: Perform correlation analysis between the standardized environmental parameter data and gas consumption data, and calculate the Pearson correlation coefficient between each environmental parameter and gas consumption. The formula is:
[0111] in, This represents the correlation coefficient between the i-th environmental parameter and gas consumption, where N is the number of data points. and These represent the average values of standardized environmental parameters and gas consumption, respectively.
[0112] S33: Divide the year into four seasons (spring, summer, autumn, and winter), and analyze the average gas consumption for each season. The formula is as follows: Among them, F season,k N represents the average gas consumption in the k-th season. k Let t represent the number of data points within the season, where t∈season,k represents all time points belonging to the k-th season;
[0113] S34: Combining the analysis results of S32 and S33, assess the impact of environmental parameters and seasonal variations on gas consumption, and generate an impact assessment report. The report includes the correlation between each environmental parameter and gas consumption, as well as the average gas consumption in each season. Through the standardization processing, correlation analysis, seasonal variation modeling, and comprehensive evaluation of the environmental parameter data described above, the impact of seasonal variations and weather conditions on gas consumption is systematically analyzed. This method can provide reliable basic data for subsequent gas consumption forecasting, thereby improving the accuracy of forecasts and optimizing gas use and energy-saving effects.
[0114] The specific steps involved in constructing a gas consumption prediction model in S4 are:
[0115] S41: Receive user gas usage habit data from S2 and environmental parameter and seasonal change impact data from S3; and integrate the user gas usage habit data and environmental parameter data into a time series to form a comprehensive dataset D, which includes gas flow, usage time, standardized environmental parameters and seasonal factors;
[0116] S42: Perform a stationarity test on the comprehensive dataset D, specifically using the unit root test (ADF test) to verify the stationarity of the time series data. The formula is as follows: Where, ΔF t This represents the difference in gas consumption at time t; α is the constant term; β is the time trend term; γ is the lag coefficient; δ is the difference coefficient; ∈ t For error term; t is time; k is the difference order;
[0117] S43: If the data is not stationary, it can be transformed into a stationary sequence through differencing. The differencing formula is: Y t ′=Y t -Y t-1 , where ΔF t F represents the differential gas consumption. t and F t-1 These represent the gas consumption at times t and t-1, respectively.
[0118] S44: An autoregressive integral moving average (ARI MA) model, i.e., a gas consumption prediction model, is constructed using a stationary series Y′ combined with standardized environmental parameters E′ and seasonal factors S. The expression is as follows:
[0119]
[0120] Where, ΔF t The difference in gas consumption over time t; For constant terms; θ represents the coefficient of the autoregressive term, indicating the weight of the i-th lag term; j E represents the coefficient of the moving average term, indicating the weight of the j-th error term; k,t ′ is the k-th standardized environmental parameter (E) at time t. 1,t ′ represents temperature, E 2,t ′ represents humidity, E 3,t (where ' is atmospheric pressure); S l,t Let S be the l-th seasonal variable at time t. 1,t For spring, S 2,t For the season of the bamboo shoots, S 3,t For autumn, S 4,t For winter, the value is 0 or 1); β k γ represents the regression coefficient of environmental parameters. l The regression coefficient for seasonal factors; ∈ t q represents the error term; p is the autoregression order; q is the moving average order.
[0121] The above method details each step from data integration, stationarity detection, and differential processing to the construction of the ARIMA model. It systematically builds a gas consumption prediction model that can comprehensively consider user habits, environmental parameters, and seasonal factors, which helps to improve the overall performance and user satisfaction of the gas consumption prediction system.
[0122] The parameters for optimizing the gas consumption prediction model in S5 specifically include:
[0123] S51: Define the objective function of the gas consumption prediction model, specifically using the mean squared error (MSE) as the evaluation metric. The objective function is: Where N is the number of data points; F t The actual amount of gas used at time t; For time t, the predicted gas consumption;
[0124] S52: Select the set of parameters to be optimized for the gas consumption prediction model, including the coefficients of the autoregressive term. Moving average coefficient θ j The regression coefficient β of environmental parameters k Regression coefficient γ of seasonal factors l And set the initial values and search range of the parameters to be optimized, where, The range of values is [0,1]; θ jThe value range is [0,1]; β k The value range is [-1, 1]; γ l This indicates that the range of values is [-1, 1].
[0125] S53: Optimize the objective function using the Bayesian optimization method;
[0126] S54: Update the set of parameters to be optimized in the gas consumption prediction model based on the optimal parameter combination obtained by Bayesian optimization.
[0127] S53 specifically includes:
[0128] S531: Construct a surrogate model (e.g., a Gaussian process regression model) to approximate the distribution of the objective function in the parameter space. The expression of the surrogate model is: y = f(x) + ∈, where y is the objective function value (MSE); x is the parameter vector, including θ j ,β k and γ l f(x) is the true objective function; ∈ represents the error term, which follows a normal distribution.
[0129] S532: Based on the surrogate model, the expected improvement (EI) criterion is used to select the next sampling point. The formula for calculating the expected improvement is: EI(x) = E[max(0,f)(x)] + )-f(x * )|D], where x + For the next sampling point; x * D represents the current optimal point; D represents the historical sampling dataset.
[0130] S533: Calculate at sampling point x + The objective function value at the sampling point is used to update the proxy model, and the new sampling point and its objective function value are added to the historical sampling dataset.
[0131] S534: Repeat S532 and S533 above until the preset stopping conditions are met, including the maximum number of iterations or the convergence of the objective function value; Through the above steps, the nonlinear and dynamic changes in gas consumption are systematically solved. The Bayesian optimization method uses an efficient surrogate model and expected improvement criterion to make the parameter optimization process more intelligent and accurate, thereby improving the accuracy and stability of the prediction model and optimizing the gas usage efficiency and energy saving effect.
[0132] S6 specifically includes:
[0133] S61: Obtain the optimized parameters of the autoregressive integral moving average model, including the coefficients of the autoregressive term. Moving average coefficient (θ) j ), regression coefficients of environmental parameters (β)k The regression coefficients of seasonal factors (γ) l );
[0134] S62: Define the input data for the gas consumption prediction model, including historical gas consumption data, environmental parameters and seasonal factors, and ensure that the dataset covers at least one year of data to reflect consumption patterns in different seasons;
[0135] S63: Apply the optimized model to predict short- and medium-term gas consumption. The specific prediction formula is as follows:
[0136]
[0137] Among them, F pred,t+ h represents the predicted gas consumption at time t+h; F t-i This represents the actual gas consumption at time ti; ∈ t-j The error term is represented by historical error data from the model; E k,t ′ represents the standardized environmental parameter for time t; S l,t t represents the seasonality of time t; h represents the time step of the forecast, with short-term forecasts covering the next 1-3 months and medium-term forecasts covering the next 3-12 months;
[0138] S64: Use the sliding window method to update the model's input data. As new data is added, the historical data in the window is continuously updated to maintain the model's timeliness and accuracy.
[0139] S7 specifically includes:
[0140] S71: Collect actual gas consumption data and predicted consumption data, including short-term and medium-term forecast results from S6 and actual gas consumption for the corresponding time period;
[0141] S72: Calculate the error between the actual consumption data and the predicted results, using the Mean Absolute Percentage Error (MAPE) as the error evaluation index. The formula is: Where N is the number of data points; F t The actual amount of gas used at time t; For time t, the predicted gas consumption;
[0142] S73: Based on the calculated error value, determine whether the prediction model needs to be updated. Specifically, if the error exceeds a preset threshold, the model update will be triggered.
[0143] S74: The parameters for user behavior analysis and environmental impact assessment are updated using an adaptive learning algorithm. Specific steps include:
[0144] S741: Initialize the parameters of the adaptive learning algorithm, including the learning rate η and momentum μ, which are used to control the step size and speed of parameter updates;
[0145] S742: Update user behavior analysis parameters (such as time and frequency parameters in gas usage habits) using gradient descent. The update formula for gradient descent is: Where, θ i,t Let be the i-th user behavior parameter at time t; L be the loss function, usually MAPE; η be the learning rate; and μ be the momentum.
[0146] S743: Update the parameters of the environmental impact assessment (such as the regression coefficients of temperature, humidity, and atmospheric pressure) using the same gradient descent method. The update formula is as follows: Where, β k,t Let be the regression coefficient of the k-th environmental parameter at time t; other symbols are defined as above.
[0147] S75: Re-input the updated user behavior analysis parameters and environmental impact assessment parameters into the prediction model to conduct the next round of gas consumption prediction;
[0148] S76: Periodically repeat the process from S71 to S75 to ensure that the prediction model can dynamically adapt to changes in user behavior and environment, thereby improving prediction accuracy;
[0149] By combining the above steps, the dynamic adaptation problem of the prediction model is systematically solved. By periodically evaluating the error between the actual consumption data and the prediction results, and using an adaptive learning algorithm to update the parameters, the model can respond to changes in user behavior and environment in a timely manner, thereby improving the accuracy and stability of the prediction.
[0150] S8 specifically includes:
[0151] S81: Collect and organize the gas consumption forecast results from S6, including short-term and medium-term gas usage forecast data;
[0152] S82: Analyze the prediction results, combine user behavior analysis data and environmental impact assessment data, and generate energy-saving recommendations, including specific measures to optimize gas usage time, improve equipment efficiency, and reduce waste;
[0153] S83: Compile a comprehensive report, including gas consumption forecast results, energy-saving recommendations, user behavior analysis, and environmental impact assessment. The gas consumption forecast results will present short- and medium-term gas consumption projections, along with charts and graphs of the forecast data. The energy-saving recommendations will provide personalized energy-saving measures based on the analysis results. The user behavior analysis will outline users' gas usage habits and patterns. The environmental impact assessment will explain the impact of environmental parameters and seasonal variations on gas consumption.
[0154] S84: Provide comprehensive reports to users and gas suppliers through a two-way communication mechanism, specifically including the following steps:
[0155] S841: Generate unique access credentials for each user and gas supplier to ensure the security and privacy of reports;
[0156] S842: Upload the comprehensive report to a secure cloud server via the Internet, allowing users and gas suppliers to log in and view the report using access credentials;
[0157] S843: Provides a feedback function, allowing users and gas suppliers to provide opinions and suggestions on the report content through an online platform. The two-way communication mechanism ensures that feedback can be delivered to the report generation system in a timely manner for improvement.
[0158] S844: Regularly update reports, combining the latest gas consumption data and user feedback to continuously improve and optimize report content and energy-saving suggestions, and notify users and gas suppliers to view updates through the same two-way communication mechanism; through the above steps, the information transmission and feedback issues are systematically resolved. The two-way communication mechanism not only ensures the timely delivery of reports and privacy security, but also provides a channel for user feedback, enabling the report content to be continuously improved and optimized, thereby improving the efficiency of gas use and user satisfaction.
[0159] This invention encompasses any substitutions, modifications, equivalent methods, and solutions made within the spirit and scope of this invention. To provide the public with a thorough understanding of this invention, specific details are described in detail in the following preferred embodiments; however, those skilled in the art will fully understand the invention even without these details. Furthermore, to avoid unnecessary misunderstanding of the essence of this invention, well-known methods, processes, procedures, components, and circuits are not described in detail.
[0160] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A gas consumption prediction method based on machine learning, characterized in that, Includes the following steps: S1: Collect gas usage data via wireless sensor network, including gas flow rate, usage time, and environmental parameters; S2: Based on the data collected in S1, user behavior analysis algorithms are used to identify users' gas usage habits; S2 specifically includes: S21: Receives data collected from S1, including gas flow rate, usage time, and environmental parameters; S22: Perform time series analysis on the received data to identify peak and off-peak periods of gas usage, as well as periodic patterns of gas usage; S23: Gas usage data is classified using the K-means clustering algorithm, and users are divided into different groups according to their gas usage patterns, specifically cooking time and hot water usage time and frequency; S24: Within each group, an association rule learning algorithm is applied to analyze cooking time preferences and hot water usage habits, identifying users' gas usage patterns under different time periods and environmental conditions; specifically, the Apriori algorithm is used to mine frequent itemsets and association rules, with the following formula: ,in, This indicates a certain behavioral pattern in gas usage; ,in, Indicates and Another related behavioral pattern; S3: Analyze the environmental parameter data in S1 to assess the impact of seasonal changes and weather conditions on gas consumption; S4: Combining the analysis results of S2 and S3, a gas consumption prediction model is constructed using time series analysis techniques; S5: The parameters of the gas consumption prediction model are optimized using the Bayesian optimization method to adapt to the nonlinearity and dynamic changes in gas consumption. S6: Use the optimized model in S5 to make short-term and medium-term predictions of gas consumption; S7: Based on actual consumption data and prediction results, use adaptive learning algorithms to update the parameters of user behavior analysis and environmental impact assessment; S8: Generates a comprehensive report including gas consumption forecasts and energy-saving recommendations, and provides the report to users and gas suppliers through a two-way communication mechanism.
2. The gas consumption prediction method based on machine learning according to claim 1, characterized in that, S1 specifically includes: S11: Configure a wireless sensor network, including a flow sensor, a time recorder, and an environmental sensor; wherein, the flow sensor is used to measure the real-time flow of gas; the time recorder is used to record the specific time period of gas use; and the environmental sensor is used to capture environmental parameters, including temperature, humidity, and air pressure. S12: The flow sensor is deployed at the inlet of the gas pipeline and uses ultrasonic measurement technology to capture the flow data of the gas. S13: The time recorder works synchronously with the flow sensor to record the start and end times of each gas usage, ensuring the accuracy of the time stamp for each data point; S14: Environmental sensors are deployed in areas where users live or use gas. The environmental sensors include temperature sensors, humidity sensors, and air pressure sensors. The temperature sensors use thermocouples or thermistors to measure ambient temperature data. The humidity sensors use capacitive or resistive sensors to measure air humidity data. The air pressure sensors measure atmospheric pressure data through the piezoelectric effect. S15: The data collected in S12, S13 and S14 are sent to the central data processing unit via the wireless transmission module. S16: The central data processing unit receives data from each sensor and performs preliminary data synchronization and outlier detection.
3. The gas consumption prediction method based on machine learning according to claim 1, characterized in that, S3 specifically includes: S31: Receives environmental parameter data from S1, including ambient temperature, ambient humidity, and atmospheric pressure; and standardizes the environmental parameter data to eliminate the influence between different units. S32: Perform correlation analysis between the standardized environmental parameter data and gas consumption data, and calculate the Pearson correlation coefficient between each environmental parameter and gas consumption. S33: Divide the year into four seasons and analyze the average gas consumption in each season. The formula is: ,in, Indicates the first Average gas consumption per season This represents the number of data points within that season. Indicates belonging to the first All points in time for each season; S34: Combining the analysis results of S32 and S33, assess the impact of environmental parameters and seasonal variations on gas consumption, and generate an impact assessment report. The report includes the correlation between each environmental parameter and gas consumption, as well as the average gas consumption in each season.
4. The gas consumption prediction method based on machine learning according to claim 1, characterized in that, S4 specifically includes: S41: Receive user gas usage habit data from S2 and environmental parameter and seasonal variation impact data from S3; integrate the user gas usage habit data and environmental parameter data into a time series dataset to form a comprehensive dataset. This includes gas flow rate, usage time, standardized environmental parameters, and seasonal factors; S42: For the comprehensive dataset Stationarity testing is performed, specifically using the unit root test to verify the stationarity of time series data; S43: If the data is not stationary, it can be transformed into a stationary sequence through differencing. The differencing formula is: ,in, This represents the gas consumption after differentiation. and They represent time respectively and Gas consumption; S44: Using stationary sequences in conjunction with normalized environmental parameters and seasonal factors Construct an autoregressive integral moving average model, i.e., a gas consumption prediction model, with the following expression: ,in, Indicates time The difference in gas consumption; For constant terms; Let be the coefficient of the autoregressive term, representing the th . The weight of each lagged term; The coefficient of the moving average term represents the th... The weights of each error term; For time The A standardized environmental parameter; For time The One seasonal variable; These are the regression coefficients for environmental parameters; The regression coefficients for seasonal factors; This is the error term; The order of autoregression; This represents the order of the moving average.
5. The gas consumption prediction method based on machine learning according to claim 4, characterized in that, S5 specifically includes: S51: Define the objective function of the gas consumption prediction model, specifically using the mean squared error as the evaluation index. The objective function is: ,in, This represents the number of data points. For time The actual gas consumption; For time Predicted gas consumption; S52: Select the set of parameters to be optimized for the gas consumption prediction model, including the coefficients of the autoregressive term. Moving average coefficient Regression coefficients of environmental parameters Regression coefficients with seasonal factors ; S53: Optimize the objective function using the Bayesian optimization method; S54: Update the set of parameters to be optimized in the gas consumption prediction model based on the optimal parameter combination obtained by Bayesian optimization.
6. The gas consumption prediction method based on machine learning according to claim 5, characterized in that, S53 specifically includes: S531: Construct the proxy model, the expression is: ,in, The objective function value; For parameter vectors; The true objective function; The error term follows a normal distribution. S532: Based on the surrogate model, the next sampling point is selected using the expected improvement criterion. The formula for calculating the expected improvement is: ,in, For the next sampling point; The current optimal point; For historical sampling datasets; S533: Calculate at the sampling point The objective function value at the sampling point is used to update the proxy model, and the new sampling point and its objective function value are added to the historical sampling dataset. S534: Repeat S532 and S533 above until the preset stopping conditions are met, including the maximum number of iterations or the convergence of the objective function value.
7. The gas consumption prediction method based on machine learning according to claim 1, characterized in that, S6 specifically includes: S61: Obtain the optimized parameters of the autoregressive integral moving average model; S62: Define the input data for the gas consumption prediction model, including historical gas consumption data, environmental parameters and seasonal factors, and ensure that the dataset covers at least one year of data to reflect consumption patterns in different seasons; S63: Apply the optimized model to predict short-term and medium-term gas consumption; S64: Use the sliding window method to update the model's input data. As new data is added, the historical data in the window is continuously updated to maintain the model's timeliness and accuracy.
8. The gas consumption prediction method based on machine learning according to claim 1, characterized in that, Specifically, S7 includes: S71: Collect actual gas consumption data and predicted consumption data, including short-term and medium-term forecast results from S6 and actual gas consumption for the corresponding time period; S72: Calculate the error between actual consumption data and prediction results, using the mean absolute percentage error as the error evaluation index. The formula is: ,in, This represents the number of data points. For time The actual gas consumption; For time Predicted gas consumption; S73: Based on the calculated error value, determine whether the prediction model needs to be updated. Specifically, if the error exceeds a preset threshold, the model update will be triggered. S74: The parameters for user behavior analysis and environmental impact assessment are updated using an adaptive learning algorithm. Specific steps include: S741: Initialize the parameters of the adaptive learning algorithm, including the learning rate. and momentum This is used to control the step size and speed of parameter updates; S742: Update user behavior analysis parameters using gradient descent. The update formula for gradient descent is: ,in, For time The User behavior parameters; The loss function; The learning rate; Momentum; S743: Update the parameters of the environmental impact assessment using the same gradient descent method; S75: Re-input the updated user behavior analysis parameters and environmental impact assessment parameters into the prediction model to conduct the next round of gas consumption prediction; S76: Repeat the process from S71 to S75 periodically to ensure that the predictive model can dynamically adapt to changes in user behavior and the environment.
9. The gas consumption prediction method based on machine learning according to claim 1, characterized in that, S8 specifically includes: S81: Collect and organize the gas consumption forecast results from S6, including short-term and medium-term gas usage forecast data; S82: Analyze the prediction results, combine user behavior analysis data and environmental impact assessment data, and generate energy-saving recommendations, including specific measures to optimize gas usage time, improve equipment efficiency, and reduce waste; S83: Compile a comprehensive report, including gas consumption forecast results, energy-saving recommendations, user behavior analysis, and environmental impact assessment; S84: Provide comprehensive reports to users and gas suppliers through a two-way communication mechanism, specifically including the following steps: S841: Generate unique access credentials for each user and gas supplier; S842: Upload the comprehensive report to a secure cloud server via the Internet, allowing users and gas suppliers to log in and view the report using access credentials; S843: Provides a feedback function, allowing users and gas suppliers to provide comments and suggestions on the report content through an online platform; S844: Regularly update reports, incorporating the latest gas consumption data and user feedback to continuously improve and optimize report content and energy-saving recommendations.
Citation Information
Patent Citations
Fuel gas short-term load prediction method based on long short-term memory neural network
CN115471008A
Fuel gas transmission loss prediction method for intelligent fuel gas and Internet of Things system
CN115796408A