A natural gas consumption prediction method and system based on temperature interval

By employing temperature zoning difference coding and hyperparameter optimization, the problems of data noise and overfitting in the natural gas consumption prediction model were solved, improving prediction accuracy and interpretability, and achieving more accurate natural gas consumption prediction.

CN120181469BActive Publication Date: 2026-02-10CHONGQING ENERGY BIG DATA CENT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510249983.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-04
Publication Date
2026-02-10
Estimated Expiration
2045-03-04

Smart Images

  • Figure CN120181469B_ABST
    Figure CN120181469B_ABST
Patent Text Reader

Abstract

The application discloses a natural gas consumption prediction method and system based on temperature intervals, and the method comprises the following steps: collecting historical data and preprocessing the historical data; generating data sets under all data hyperparameter combinations by traversing the historical data, and converting temperature change data by using a temperature partition rule; generating prediction model instances under all model hyperparameter combinations by traversal; training, verifying and evaluating any prediction model instance according to any data set until cross-validation of all data hyperparameters and model hyperparameter combinations is completed; and sorting the cross-validation results to obtain an optimal prediction model or several prediction models in the front of the sorting. The application can use a temperature partition difference value encoder to convert a single difference value of two temperatures into multiple difference values in multiple partitions, that is, convert the temperature difference value from one dimension to multiple dimensions, so that the model can learn the correlation coefficient for the difference value of each partition, thereby improving the precision of the model.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data prediction, in particular to a natural gas consumption prediction method and system based on temperature intervals. BACKGROUND

[0002] In northern cities of China, natural gas is mainly relied on for heating in winter. The demand for natural gas is closely related to the air temperature, and the change in air temperature directly affects the natural gas consumption of residents. Ensuring the supply of natural gas is a matter of the people's livelihood, and as a city gas enterprise, it is crucial to accurately realize the planned scheduling of natural gas according to future weather conditions. When the demand exceeds the planned amount, advance procurement not only ensures supply, but also reduces gas purchase costs through market mechanisms; and when the demand is less than the planned amount, the enterprise can sell the surplus natural gas to other gas-using enterprises in advance, thereby reducing short-term losses. This flexible scheduling strategy needs a high-precision prediction model as support to ensure the scientificity and economy of enterprise decision-making under different scenarios.

[0003] In the prior art, the construction process of a natural gas consumption prediction model is usually as follows: first, historical natural gas consumption data and its influencing factor data (such as the heating period, air temperature, time, population change, etc.) in a certain time period are collected, and then these data are divided into a training set and a validation set, the training set is used to train the prediction model, and the validation set is used to verify the ability of the prediction model. In the above training set division process of the prediction model, since the natural gas consumption is affected by many factors such as regional economy, policy, population, temperature, etc., and as the model's ability is enhanced, more kinds of influencing factors are usually used as inputs of the training set, so as to improve the robustness of the prediction model and the ability to capture complex relationships.

[0004] However, the multi-factor model constructed by using the above training set still has many problems, such as: 1. Multi-source data may have missing, noise or inconsistency problems, increasing the difficulty of data cleaning and preprocessing; 2. The multi-factor model may overfit the accidental patterns in the training data, resulting in poor performance on new data; 3. The decision-making process of the multi-factor model (especially deep learning models) is complex, and it is difficult to explain the specific influence of each feature. SUMMARY

[0005] In view of the above problems of the prior art, the technical problem to be solved by the present application is to provide a natural gas consumption prediction method and system based on temperature intervals, which can use a temperature interval difference encoder to convert a single difference value of two temperatures into multiple difference values in multiple partitions, i.e. to convert the temperature difference value from one dimension to multiple dimensions, so that the model can learn the correlation coefficients for the difference value of each partition, thereby improving the accuracy of the model.

[0006] One technical solution adopted by this invention is to provide a method for predicting natural gas consumption based on a temperature range, the method comprising the following steps:

[0007] S1: Collect historical data of the target area within a preset time period, including natural gas consumption data, weather data, and indirect impact data, and preprocess the historical data;

[0008] S2: Define the model hyperparameter type and data hyperparameter type, use grid search to traverse historical data to generate datasets under all combinations of data hyperparameters, and use temperature partitioning rules to transcode the temperature change data in the dataset;

[0009] S3: Generate prediction model instances under all combinations of model hyperparameters by using grid search traversal;

[0010] S4: Train, validate, and evaluate the prediction model instance under any model hyperparameter combination based on the dataset under any data hyperparameter combination until the cross-validation of all data hyperparameter and model hyperparameter combinations is completed.

[0011] S5: Sort the cross-validation results to obtain the optimal prediction model or the top few prediction models, and predict the natural gas consumption of the target area based on the optimal prediction model or the top few prediction models.

[0012] Furthermore, the method also includes the following steps:

[0013] S6: Based on the evaluation results of the first few prediction models, calculate the corresponding weighting coefficients for each model, and then perform a weighted average of the prediction results of the first few prediction models according to the weighting coefficients to obtain the final prediction result.

[0014] Furthermore, the collected data is preprocessed, including the following sub-steps:

[0015] S11: Divide historical data into several historical datasets according to data type, and each historical dataset contains historical data of the same data type;

[0016] S12: Establish a univariate regression model for the temperature change dataset and the natural gas consumption dataset in the historical dataset, and correct the data in the temperature change dataset according to the univariate regression model.

[0017] Furthermore, the model hyperparameters include learning rate, regularization parameter, number of iterations, kernel function type, and activation function type; the data hyperparameters include data loading period, temperature partitioning rule, and backtracking days; the data loading period represents the time range of historical data loading, with a value of 2-15 years and a step size of 1 year; the temperature partitioning rule is used to determine the interval size of temperature partitions, with a value range of 2-10 degrees and a step size of 1 degree; the backtracking days represent the number of days before the prediction date that can affect the predicted value of the current prediction date, with a value range of 1-7 days and a step size of 1 day.

[0018] Furthermore, the transcoding of temperature change data in the dataset using temperature partitioning rules includes the following sub-steps:

[0019] S21: Determine the temperature partition set according to the temperature partition rules, and define a temperature difference array according to the temperature partitions. The size of the temperature difference array is the same as the size of the temperature partition set, and the initial value of all elements in the temperature difference array is 0.

[0020] S22: Traverse each partition of the temperature partition set to obtain the index and upper and lower limits of each partition;

[0021] S23: Convert the temperature change data into temperature partition difference values ​​for each partition in the temperature partition set according to the transcoding rules, and set the temperature partition difference values ​​into the corresponding elements in the temperature difference array according to the index of each partition.

[0022] Furthermore, the transcoding rules include:

[0023] S231: Define the temperature before and after the temperature change as the first temperature and the second temperature, respectively;

[0024] S232: Select any partition in the temperature partition set, and determine whether the first temperature or the second temperature is in that partition. If it is, the transcoded value of the first temperature or the second temperature in that partition is the initial value of the first temperature or the second temperature. If it is not, proceed to step S233.

[0025] S233: Determine whether the first temperature or the second temperature is less than the lower limit of the partition. If yes, then transcode the value of the first temperature or the second temperature in the partition to the lower limit of the partition - 1; if no, then transcode the value of the first temperature or the second temperature in the partition to the upper limit of the partition.

[0026] S234: The difference between the transcoding value of the second temperature and the first temperature is taken as the temperature partition difference between the first temperature and the second temperature in this partition.

[0027] Furthermore, step S4 includes the following sub-steps:

[0028] S41: Divide the dataset under each combination of data hyperparameters into several subsets. For each dataset under each combination of data hyperparameters, use one subset as the validation set in turn and the remaining subsets as the training set.

[0029] S42: Train a prediction model instance under any combination of model hyperparameters using the training set, validate the prediction model instance using the validation set, and calculate the prediction accuracy or F1 value of the prediction model instance.

[0030] S43: Repeat steps S41-S42 until cross-validation of all data hyperparameters and model hyperparameter combinations is completed.

[0031] Furthermore, the specific calculation process for calculating the corresponding weighting coefficients based on the evaluation results of the previous prediction models is as follows:

[0032]

[0033] Among them, u k P represents the weighting coefficient of the k-th prediction model. k represents the prediction bias rate of the k-th prediction model, and m represents the number of prediction models.

[0034] To solve the above-mentioned technical problems, the second technical solution adopted by the present invention is: to provide a natural gas consumption prediction system based on a temperature range, comprising:

[0035] The data acquisition module is used to collect historical data of the target area within a preset time period, including natural gas consumption data, weather data, and indirect impact data, and to preprocess the historical data.

[0036] The hyperparameter definition module is used to define the model hyperparameter type and the data hyperparameter type. It uses grid search to traverse historical data to generate a dataset under all combinations of data hyperparameters, and uses temperature partitioning rules to transcode the temperature change data in the dataset.

[0037] The model instance building module is used to generate predictive model instances for all combinations of model hyperparameters by using grid search traversal;

[0038] The cross-validation module is used to train, validate, and evaluate prediction model instances under any combination of model hyperparameters based on a dataset with any combination of data hyperparameters, until cross-validation of all combinations of data hyperparameters and model hyperparameters is completed.

[0039] The prediction module is used to sort the cross-validation results to obtain the optimal prediction model or the top few prediction models, and to predict the natural gas consumption of the target area based on the optimal prediction model or the top few prediction models.

[0040] Furthermore, the system also includes:

[0041] The weighted prediction module is used to calculate the corresponding weighting coefficients for each of the previous prediction models based on their evaluation results, and to perform a weighted average of the prediction results of the previous prediction models according to the weighting coefficients to obtain the final prediction result.

[0042] The present invention provides a method and system for predicting natural gas consumption based on temperature ranges, which has at least the following beneficial effects: 1. The present invention can utilize a temperature zone difference encoder to convert a single difference between two temperatures into multiple differences in multiple zones, that is, to convert the temperature difference from one dimension to multiple dimensions, so that the model can learn the correlation coefficient for the difference in each zone, thereby improving the accuracy of the model; 2. The present invention sets data hyperparameters and model hyperparameters, and through cross-validation of the combination of data hyperparameters and model hyperparameters, it can find the optimal data hyperparameters and model hyperparameters, thereby improving the accuracy of model prediction at both the data and model levels; 3. The present invention utilizes model fusion, and obtains the final prediction result by weighted averaging of the prediction results of the top-ranked models, thereby further improving the accuracy of prediction. Attached Figure Description

[0043] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0044] Figure 1 This is a flowchart of one embodiment of a natural gas consumption prediction method based on temperature range according to the present invention.

[0045] Figure 2 for Figure 1 The sub-flowchart of step S1.

[0046] Figure 3 for Figure 1 The sub-flowchart of step S2.

[0047] Figure 4 for Figure 3 The sub-flowchart of step S23.

[0048] Figure 5 for Figure 1 The sub-flowchart of step S4.

[0049] Figure 6 This is a structural block diagram of one embodiment of the natural gas consumption prediction system of the present invention. Detailed Implementation

[0050] The invention will now be further described with reference to the accompanying drawings.

[0051] Please see Figure 1 This is a flowchart illustrating one embodiment of a natural gas consumption prediction method based on a temperature range according to the present invention. This embodiment may specifically include the following steps:

[0052] S1: Collect historical data of the target area within a preset time period, including natural gas consumption data, weather data, and indirect impact data, and preprocess the historical data.

[0053] Specifically, this embodiment collects historical data of the target region within a preset time period and constructs a prediction model based on this historical data to predict the natural gas consumption of the target region. The historical data includes natural gas consumption data, weather data that has the most direct impact on natural gas consumption (temperature changes, weather conditions, wind direction and force, air humidity, etc.), and indirect impact data (holidays, heating season policies). Since the historical data often comes from multiple sources, it is necessary to preprocess the historical data to optimize outliers, ensure data accuracy, and thus improve the accuracy of the prediction model. Furthermore, the historical data collected in this embodiment is data from the target region for the past 15 years.

[0054] Please see Figure 2 The process of preprocessing the collected data includes the following sub-steps:

[0055] S11: Divide historical data into several historical datasets according to data type, and each historical dataset contains historical data of the same data type;

[0056] Specifically, this implementation scheme employs the Z-Score method for preprocessing historical data. This method can mark outliers within similar data sets. Since the aforementioned historical data often originates from multiple sources and mostly contains time stamps, it is necessary to divide it into several historical datasets based on data source or data type before preprocessing. Each historical dataset contains historical data of the same type, facilitating outlier marking within each dataset using the Z-Score method. It is worth noting that because the aforementioned historical data mostly contains time stamps, exhibiting clear time-series characteristics, the moving average smoothing replacement method can be used to process outliers detected by the Z-Score method.

[0057] S12: Establish a univariate regression model for the temperature change dataset and the natural gas consumption dataset in the historical dataset, and correct the data in the temperature change dataset according to the univariate regression model.

[0058] Specifically, since temperature change data has a major impact on natural gas consumption, this embodiment only handles outliers in the temperature change data. The method involves collecting the highest and lowest temperature data for each day from the temperature dataset, setting a preset temperature change anomaly threshold, and comparing this threshold with the temperature change data. If the absolute value of the difference exceeds the threshold, the temperature change data needs correction. The temperature dataset originates from multiple data sources; that is, for the target area, temperature data is collected from multiple observation sources. Therefore, the temperature data from one observation source can be used as the master data, and the temperature data from the other sources as auxiliary verification data. The difference between the master data and the auxiliary verification data for the highest or lowest temperature of a specific day in the target area is calculated, and this difference is compared with the temperature anomaly threshold to correct the temperature change data. For example, to illustrate the above temperature change anomaly handling method: the preset temperature change anomaly threshold is 5 degrees Celsius. The difference between the high and low temperatures for each day is obtained. When the absolute difference exceeds 5 degrees Celsius, temperature change data correction is required. Based on the human experience that gas volume changes by N cubic meters for every 1 degree Celsius change in temperature, the correction method adopts a regression model: using the high / low temperature of the 10 days before the abnormal temperature change and the difference between the natural gas consumption and the previous day, a univariate regression model is established (y = ax + b, where y is the difference in natural gas consumption and x is the temperature change value). Then, the temperature change is corrected based on this model, and the temperature difference that is closest to the model prediction value is selected.

[0059] In some implementations, historical data other than temperature variation data can be standardized by calculating the mean and standard deviation of any historical dataset, and then calculating a standard score for each data point in that historical dataset based on the mean and standard deviation.

[0060]

[0061] Among them, X i Represents the i-th historical dataset. Let μ represent the nth data point in the historical dataset, μ represent the mean of the historical dataset, and σ represent the standard deviation of the historical dataset. Let z represent the j-th data point in this historical dataset. j This represents the standard score of the j-th data point in the historical dataset;

[0062] Specifically, the above describes the detailed process of the Z-Score method, which identifies outliers in each historical dataset, facilitating subsequent replacements.

[0063] All data that meet the preset standard score threshold are marked as outliers, and the outliers are handled using the moving smooth replacement method.

[0064] Specifically, in this embodiment, the moving average smoothing replacement method described above is used to handle outliers. This replacement method is suitable for time series data or structured data with local correlation. Its core idea is to replace the outlier with local features (such as mean, median, etc.) of the data surrounding it to maintain the continuity and smoothness of the data. In this embodiment, the replacement process is illustrated through a scenario example, without going into detail about the specific replacement process of the method. For example, when predicting the daily natural gas consumption of a city, if a certain historical data segment is detected by the Z-Score method as [100, 120, 110, 130, 500, 125, 115, 140], and 500 is found to be an outlier, the moving average smoothing replacement method is used to take the average of the two data values ​​before and after the outlier (i.e., 110, 130, 125, 115) and replace the outlier to obtain [100, 120, 110, 130, 120, 125, 115, 140].

[0065] S2: Define the model hyperparameter type and data hyperparameter type, use grid search to traverse historical data to generate datasets under all combinations of data hyperparameters, and use temperature partitioning rules to transcode the temperature change data in the dataset.

[0066] Specifically, training a prediction model typically involves grid search and cross-training validation of its hyperparameters. However, natural gas consumption is influenced by regional economic, policy, and population factors, resulting in significant differences between recent and distant years, as well as between different months. Examples include the impact of coal-to-gas conversion policies on natural gas consumption and the influence of heating and non-heating season temperatures on consumption. Therefore, directly inputting all data into the model not only fails to improve prediction accuracy but may also interfere with it. Thus, the selection of hyperparameters is crucial. This implementation plan employs a cross-training validation framework based on both data and model dimensions.

[0067] In some implementations, the model hyperparameters include learning rate, regularization parameter, number of iterations, kernel function type, and activation function type; the data hyperparameters include data loading period, temperature partitioning rule, and backtracking days; the data loading period represents the time range of historical data loading, with a value of 2-15 years and a step size of 1 year; the temperature partitioning rule is used to determine the interval size of temperature partitions, with a value range of 2-10 degrees and a step size of 1 degree; the backtracking days represent the number of days before the prediction date that can affect the predicted value of the current prediction date, with a value range of 1-7 days and a step size of 1 day.

[0068] Specifically, in this embodiment, model hyperparameters, as external configurations of the prediction model, can be selected according to the actual type of prediction model used. For example, the learning rate determines the step size for updating model parameters, affecting the stability and convergence speed of model training; regularization parameters control model complexity and prevent overfitting; the number of iterations affects the number of training iterations—a small number of iterations may lead to underfitting, while an excessive number of iterations may lead to overfitting. If an SVR model is selected, the kernel function type can also be used as a model hyperparameter. Similarly, if a neural network model is selected, the neural network structure, such as the number of hidden layers and the number of neurons per layer, can be used as model hyperparameters. In addition, activation function type and loss function type can also be used as model hyperparameters. In short, the selection of model hyperparameters can be adaptively chosen according to the actual type of prediction model to be used.

[0069] In addition to model hyperparameters, since the historical data used in this embodiment includes multi-source data, data hyperparameters are also introduced to find data types that are beneficial to improving model performance. Based on the defined data hyperparameter types, training and validation data under all combinations of data hyperparameters can be generated. Data hyperparameter types include range-based and enumeration-based. Range-based refers to traversing sequentially from the starting number to the ending number according to the step size, while enumeration-based refers to selecting and executing parameters one by one from the enumeration list. The range-related hyperparameters include: Data loading period (determining how many years of data from the preceding prediction target should be used for model training, leading to better model performance; its value ranges from 2 to 15 years with a step size of 1 year); Temperature zoning rules (determining the interval between temperature zones; its value ranges from 2 to 10 degrees Celsius with a step size of 1 degree Celsius); and Backtracking days (because temperature has a cumulative effect, temperature changes over the previous N days will affect today's natural gas consumption; simultaneously, the natural gas consumption over the previous N days forms the basis for today's consumption forecast, implicitly including information such as current population, number of gas meters, number of heating boilers, and industrial and commercial gas consumption; therefore, choosing an appropriate backtracking day has a significant impact on model performance). This parameter determines the backtracking days, with a value range of 1 to 7 days and a step size of 1 day. For enumerated data hyperparameters, this could include data loading time. Because the correlation between natural gas consumption and temperature differs significantly between the heating season, non-heating season, and the heating season transition period, a segmented forecasting approach is used for the entire year. This means different forecasting models are applied to different time periods: the heating season (October 21st – April 6th of the following year), the non-heating season (April 21st – October 2nd), and the heating season transition period (April 7th – April 20th, October 3rd – October 20th). Therefore, during data loading, historical data can be loaded according to date segments. For example, if the heating season in a certain region is from October 15th to April 15th of the following year, then when training the heating season model, only data from October 15th to April 15th of the following year from historical years will be loaded. Regarding the enumeration parameters for including and excluding types, not all features added to the training data will improve model performance. Therefore, we designed enumeration parameters for including and excluding types, and the score obtained by the model training evaluator determines whether this feature needs to be included. These features include wind force, wind direction, air humidity, weekdays, number of days of holidays, date, month, year, weekday, heating season markers, etc.

[0070] Please see Figure 3 Step S2 may include the following sub-steps:

[0071] S21: Determine the temperature partition set according to the temperature partition rules, and define a temperature difference array according to the temperature partitions. The size of the temperature difference array is the same as the size of the temperature partition set, and the initial value of all elements in the temperature difference array is 0.

[0072] S22: Traverse each partition of the temperature partition set to obtain the index and upper and lower limits of each partition;

[0073] S23: Convert the temperature change data into temperature partition difference values ​​for each partition in the temperature partition set according to the transcoding rules, and set the temperature partition difference values ​​into the corresponding elements in the temperature difference array according to the index of each partition.

[0074] Specifically, natural gas consumption is strongly correlated with temperature changes. During the heating season, a 1-degree Celsius decrease in temperature typically leads to an increase in consumption of N cubic meters. However, due to factors such as perceived temperature and limitations imposed by external environmental equipment, the correlation between consumption and temperature changes varies significantly across different temperature ranges. For example, when the temperature reaches -10 degrees Celsius, all heating boilers in a certain region are operating at full capacity, and the growth rate of natural gas consumption slows down significantly. In other words, the correlation coefficient between temperature changes and natural gas consumption differs across different temperature ranges. Therefore, to address this characteristic, this embodiment designs a temperature zone difference encoder. This encoder converts a single difference between two temperatures into multiple differences across multiple zones, transforming the temperature difference from one-dimensional to multi-dimensional. This allows the model to learn the correlation coefficient for the difference in each zone separately, thereby improving the model's accuracy.

[0075] In addition to the above, to convert a single difference between two temperatures into multiple differences across multiple zones, it is necessary to determine the temperature zone set and define the temperature difference array. The temperature zone set can be defined as an unequally divided set based on business characteristics (clothing weather index, indoor air quality standards, regional heating management regulations, etc.); or it can be defined as an equally divided set based on the start and end temperatures and the number of zones. For example, a zone set defined according to the equally divided rule parameters (start and end temperatures of -10 degrees and 30 degrees, 6 zones) would be less than or equal to -10 degrees, -9 to 0 degrees, 1 to 10 degrees, 11 to 20 degrees, 21 to 30 degrees, and greater than or equal to 31 degrees. The temperature difference array has the same size as the temperature zone set, and all elements in the temperature difference array are initialized to 0.

[0076] In some implementations, please refer to Figure 4 Step S23 may include the following sub-steps: The transcoding rules include:

[0077] S231: Define the temperature before and after the temperature change as the first temperature and the second temperature, respectively;

[0078] Specifically, in this embodiment, the temperature encoder uses a transcoding rule to transcode a single difference between two temperatures into multiple differences across multiple partitions. This transcoding rule is essentially an algorithm that transcodes two temperatures into values ​​across multiple partitions, thereby obtaining the difference between the two temperatures within that partition. The specific process involves first defining the temperatures before and after the temperature change as the first temperature and the second temperature, respectively. For example, the temperatures of a specific day and the previous day in the temperature change data can be used as the first temperature and the second temperature, respectively.

[0079] S232: Select any partition in the temperature partition set, and determine whether the first temperature or the second temperature is in that partition. If it is, the transcoded value of the first temperature or the second temperature in that partition is the initial value of the first temperature or the second temperature. If it is not, proceed to step S233.

[0080] S233: Determine whether the first temperature or the second temperature is less than the lower limit of the partition. If yes, then transcode the value of the first temperature or the second temperature in the partition to the lower limit of the partition - 1; if no, then transcode the value of the first temperature or the second temperature in the partition to the upper limit of the partition.

[0081] S234: The difference between the transcoding value of the second temperature and the first temperature is taken as the temperature partition difference between the first temperature and the second temperature in this partition.

[0082] After obtaining the first temperature, the second temperature, and the upper and lower limits of the partition, the transcoding values ​​of the first temperature and the second temperature within the partition can be determined. Specifically, the transcoding value can be determined by judging whether the first temperature or the second temperature is within the range of the selected partition. Specifically, if the first temperature or the second temperature is within the range of this partition (i.e., the value of the first temperature or the second temperature is within the upper and lower limits of this partition), then the transcoded value of the first temperature or the second temperature in this partition is the first temperature or the second temperature itself. If the first temperature or the second temperature is not within the range of this partition, then it is necessary to further determine the relationship between the first temperature or the second temperature and the upper and lower limits of this partition, that is, to determine whether the first temperature or the second temperature is less than the lower limit of this partition. If it is less, then the value of the first temperature or the second temperature is transcoded to the lower limit value of this partition - 1. Conversely (i.e., the first temperature or the second temperature exceeds the upper limit of this partition), then the value of the first temperature or the second temperature is transcoded to the upper limit value of this partition. Finally, the transcoded value of the second temperature is subtracted from the transcoded value of the first temperature, and the resulting difference is used as the difference between the first temperature and the second temperature in this partition. Using the current partition index value, the temperature partition difference calculated in the previous step is set into the temperature difference array. Based on the above transcoding rules, the calculation process of temperature zone difference is illustrated with an example. Please refer to Table 1 - Temperature Zone Difference Table. Assuming a set of temperature zones with 7 zones is defined (less than or equal to 4 degrees, 5-9 degrees, 10-14 degrees, 15-19 degrees, 20-24 degrees, 25-29 degrees, and greater than or equal to 30 degrees), the temperature zone difference between 10 and 30 degrees, -5 and 7 degrees, and 28 and 35 degrees in each zone can be calculated according to the above transcoding rules.

[0083] Table 1 - Temperature Zone Difference Table

[0084] first temperature second temperature ≤4 5-9 10-14 15-19 20-24 25-29 ≥30 10 30 0 0 4 5 5 5 1 -5 7 9 3 0 0 0 0 0 28 35 0 0 0 0 0 1 6

[0085] S3: Generate prediction model instances under all combinations of model hyperparameters by using grid search traversal.

[0086] Specifically, based on the defined model hyperparameter types, model instances are generated for all combinations of model hyperparameters. Model hyperparameter types include range-based and enumeration-based types, similar to data hyperparameter types.

[0087] Range-type parameters require defining start and end values ​​and step size, such as learning rate and regularization parameters.

[0088] Enumerated parameters define an enumeration list, such as defining the kernel function type of the SVR model.

[0089] S4: Train, validate, and evaluate the prediction model instance under any combination of model hyperparameters based on the dataset under any combination of data hyperparameters, until the cross-validation of all combinations of data hyperparameters and model hyperparameters is completed.

[0090] Specifically, during a training evaluation, the training and validation data, along with the hyperparameters, for this cross-validation are first obtained. Then, a prediction model instance is created, and its hyperparameters are obtained. Finally, the prediction model instance is trained and validated using the training and validation data, and the performance score under this combination of data and model hyperparameters is recorded. After completing cross-validation of all combinations of data and model hyperparameters, the optimal data and model hyperparameters are obtained.

[0091] Please see Figure 5 Step S4 may include the following sub-steps:

[0092] S41: Divide the dataset under each combination of data hyperparameters into several subsets. For each dataset under each combination of data hyperparameters, use one subset as the validation set in turn and the remaining subsets as the training set.

[0093] S42: Train a prediction model instance under any combination of model hyperparameters using the training set, validate the prediction model instance using the validation set, and calculate the prediction accuracy or F1 value of the prediction model instance.

[0094] S43: Repeat steps S41-S42 until cross-validation of all data hyperparameters and model hyperparameter combinations is completed.

[0095] Specifically, in this implementation, based on cross-validation, the datasets under all data hyperparameter combinations are used to train, validate, and evaluate prediction model instances under all model hyperparameter combinations. The specific process is as follows: First, the datasets under each data hyperparameter combination are divided into several subsets. For each dataset under a data hyperparameter combination, one subset is used in turn as the validation set, and the remaining subsets are used as the training set. Then, a prediction model instance under a model hyperparameter combination is selected, trained using the aforementioned training set, and validated using the aforementioned validation set. The validation results are recorded and evaluated. This completes the training, validation, and evaluation of a prediction model instance under a model hyperparameter combination for one data hyperparameter combination. These two steps are repeated until the training, validation, and evaluation of prediction model instances under all model hyperparameter combinations for all data hyperparameter combinations are completed.

[0096] Taking the SVR model trained during the heating season as an example, the data hyperparameters are as follows: historical data are selected from the most recent 7 years, specifically from October 21st to April 1st of the following year. The daily high and low temperature differences compared to the previous day are converted and upgraded using temperature zoning (<=4, 5-9, 10-14, 15-19, 20-24, 25-29, >=30). The backtracking period for both air volume and temperature is 2 days. Other features used in training include month, weekday, date, wind speed, and whether it is a weekday. The model hyperparameters are: kernel function kernel=RBF, kernel coefficient gamma=0.001, penalty parameter=300, and insensitive loss parameter epsilon=0.06, normalized using standard deviation. The model trained using these hyperparameters was used to predict and validate data from 2019 to 2024, with bias rates of 2.6%, 2.4%, 2.3%, 2.9%, 3%, and 2%, respectively.

[0097] S5: Sort the cross-validation results to obtain the optimal prediction model or the top few prediction models, and predict the natural gas consumption of the target area based on the optimal prediction model or the top few prediction models.

[0098] Specifically, in this embodiment, the cross-validation results can be ranked, and the prediction model ranked first can be taken as the optimal prediction model. This optimal model is the best model under the combination of the data hyperparameters and model hyperparameters. Through this optimal model, the natural gas consumption of the target area can be predicted more accurately. In addition, in order to further improve the accuracy of the model prediction, the prediction results of the first few prediction models (in this embodiment, the first 3) can be weighted and averaged to obtain the final prediction result.

[0099] In some implementations, the method may further include the following steps:

[0100] S6: Based on the evaluation results of the first few prediction models, calculate the corresponding weighting coefficients for each model, and then perform a weighted average of the prediction results of the first few prediction models according to the weighting coefficients to obtain the final prediction result.

[0101] In some implementations, the specific calculation process for calculating the corresponding weighting coefficients based on the evaluation results of the preceding prediction models is as follows:

[0102]

[0103] Among them, u k P represents the weighting coefficient of the k-th prediction model. k represents the prediction bias rate of the k-th prediction model, and m represents the number of prediction models.

[0104] Specifically, through cross-validation of the data models in the preceding steps, the optimal hyperparameters for the three top-ranked prediction models (multiple linear regression, SVR, and Catboost) in this implementation method can be found. These three prediction models can then be integrated to obtain the final prediction model. This final prediction model actually utilizes the weighting coefficients of the three models to perform a weighted average of their respective prediction results, thus obtaining the final prediction result. These weighting coefficients can be calculated from the scores (bias rates) of each model obtained from the model training evaluator.

[0105] This invention employs a temperature-range-based natural gas consumption prediction method. It utilizes a temperature zone difference encoder to convert a single difference between two temperatures into multiple differences across multiple zones, effectively transforming the temperature difference from one-dimensional to multi-dimensional. This allows the model to learn correlation coefficients for each zone's difference, thereby improving model accuracy. Furthermore, this invention sets up data hyperparameters and model hyperparameters, and through cross-validation of the combination of these hyperparameters, it finds the optimal scoring data hyperparameters and model hyperparameters, thus improving the accuracy of model predictions at both the data and model levels. Finally, this invention utilizes model fusion, obtaining the final prediction result by weighted averaging of the prediction results from the top-ranked models, further enhancing prediction accuracy.

[0106] Please see Figure 6 This is a structural block diagram of an embodiment of the natural gas consumption prediction system based on temperature range according to the present invention. The natural gas consumption prediction system based on temperature range in this embodiment is used to implement the natural gas consumption prediction method based on temperature range described in the above embodiment. Specifically, the natural gas consumption prediction system based on temperature range in this embodiment includes a data acquisition module 100, a hyperparameter definition module 200, a model instance construction module 300, a cross-validation module 400, and a prediction module 500.

[0107] in:

[0108] The data acquisition module 100 is used to collect historical data of the target area within a preset time period, including natural gas consumption data, weather data and indirect impact data, and to preprocess the historical data.

[0109] The hyperparameter definition module 200 is used to define the model hyperparameter type and the data hyperparameter type. It uses grid search to traverse historical data to generate a dataset under all combinations of data hyperparameters, and uses temperature partitioning rules to transcode the temperature change data in the dataset.

[0110] Model instance building module 300 is used to generate predictive model instances under all combinations of model hyperparameters by using grid search traversal;

[0111] The cross-validation module 400 is used to train, validate, and evaluate the prediction model instance under any model hyperparameter combination based on the dataset under any data hyperparameter combination, until the cross-validation of all data hyperparameter and model hyperparameter combinations is completed.

[0112] The prediction module 500 is used to sort the cross-validation results to obtain the optimal prediction model or the top few prediction models, and to predict the natural gas consumption of the target area based on the optimal prediction model or the top few prediction models.

[0113] In some implementations, the system further includes:

[0114] The weighted prediction module 600 is used to calculate the corresponding weighting coefficients of the previous prediction models based on their evaluation results, and to perform a weighted average of the prediction results of the previous prediction models according to the weighting coefficients to obtain the final prediction result.

[0115] This invention provides a method for predicting natural gas consumption based on temperature ranges.

[0116] The above description merely illustrates preferred embodiments of the present invention and is quite specific and detailed; however, it should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the inventive concept, and these all fall within the scope of protection of the present invention. Therefore, the scope of protection of this invention should be determined by the appended claims.

Claims

1. A method for predicting natural gas consumption based on temperature range, characterized in that, The method includes the following steps: S1: Collect historical data of the target area within a preset time period, including natural gas consumption data, weather data, and indirect impact data, and preprocess the historical data; S2: Define the model hyperparameter type and data hyperparameter type, generate a dataset under all combinations of data hyperparameters by traversing the historical data using grid search, and transcode the temperature change data in the dataset using temperature partitioning rules; the data hyperparameters include, data loading year, temperature partitioning rules, and backtracking days; The process of transcoding the temperature change data in the dataset using temperature zoning rules includes the following sub-steps: S21: Determine the temperature partition set according to the temperature partition rules, and define a temperature difference array according to the temperature partitions. The size of the temperature difference array is the same as the size of the temperature partition set, and the initial value of all elements in the temperature difference array is 0. S22: Traverse each partition of the temperature partition set to obtain the index and upper and lower limits of each partition; S23: Convert the temperature change data into temperature partition difference values ​​for each partition in the temperature partition set according to the transcoding rules, and set the temperature partition difference values ​​into the corresponding elements in the temperature difference array according to the index of each partition. The transcoding rules include: S231: Define the temperature before and after the temperature change as the first temperature and the second temperature, respectively; S232: Select any partition in the temperature partition set, and determine whether the first temperature or the second temperature is in that partition. If it is, the transcoded value of the first temperature or the second temperature in that partition is the initial value of the first temperature or the second temperature. If it is not, proceed to step S233. S233: Determine whether the first temperature or the second temperature is less than the lower limit of the partition. If yes, then transcode the value of the first temperature or the second temperature in the partition to the lower limit of the partition - 1; if no, then transcode the value of the first temperature or the second temperature in the partition to the upper limit of the partition. S234: The difference between the transcoding value of the second temperature and the first temperature is taken as the temperature partition difference between the first temperature and the second temperature in this partition. S3: Generate prediction model instances under all combinations of model hyperparameters by using grid search traversal; S4: Train, validate, and evaluate the prediction model instance under any model hyperparameter combination based on the dataset under any data hyperparameter combination until the cross-validation of all data hyperparameter and model hyperparameter combinations is completed. S5: Sort the cross-validation results to obtain the optimal prediction model or the top few prediction models, and predict the natural gas consumption of the target area based on the optimal prediction model or the top few prediction models.

2. The method for predicting natural gas consumption based on a temperature range as described in claim 1, characterized in that, The method also includes the following steps: S6: Based on the evaluation results of the first few prediction models, calculate the corresponding weighting coefficients for each model, and then perform a weighted average of the prediction results of the first few prediction models according to the weighting coefficients to obtain the final prediction result.

3. The method for predicting natural gas consumption based on a temperature range as described in claim 1, characterized in that, The process of preprocessing the collected data includes the following sub-steps: S11: Divide historical data into several historical datasets according to data type, and each historical dataset contains historical data of the same data type; S12: Establish a univariate regression model for the temperature change dataset and the natural gas consumption dataset in the historical dataset, and correct the data in the temperature change data according to the univariate regression model.

4. The method for predicting natural gas consumption based on a temperature range as described in claim 1, characterized in that, The model hyperparameters include learning rate, regularization parameter, number of iterations, kernel function type, and activation function type; the data loading period represents the time range of historical data loading, with a value of 2-15 years and a step size of 1 year; the temperature zoning rule is used to determine the interval size of temperature zoning, with a value range of 2-10 degrees and a step size of 1 degree; the backtracking days represent the number of days before the prediction date that can affect the predicted value of the current prediction date, with a value range of 1-7 days and a step size of 1 day.

5. The method for predicting natural gas consumption based on a temperature range as described in claim 1, characterized in that, Step S4 includes the following sub-steps: S41: Divide the dataset under each combination of data hyperparameters into several subsets. For each dataset under each combination of data hyperparameters, use one subset as the validation set in turn and the remaining subsets as the training set. S42: Train a prediction model instance under any combination of model hyperparameters using the training set, validate the prediction model instance using the validation set, and calculate the prediction accuracy or F1 value of the prediction model instance. S43: Repeat steps S41-S42 until cross-validation of all data hyperparameters and model hyperparameter combinations is completed.

6. The method for predicting natural gas consumption based on a temperature range as described in claim 2, characterized in that, The specific calculation process for calculating the weighting coefficients corresponding to each of the previous prediction models based on their evaluation results is as follows: ; in, This represents the weighting coefficient of the k-th prediction model. represents the prediction bias rate of the k-th prediction model, and m represents the number of prediction models.

7. A natural gas consumption prediction system based on temperature range, characterized in that, include: The data acquisition module is used to collect historical data of the target area within a preset time period, including natural gas consumption data, weather data, and indirect impact data, and to preprocess the historical data. The hyperparameter definition module is used to define the model hyperparameter type and the data hyperparameter type. It uses grid search to traverse historical data to generate a dataset under all combinations of data hyperparameters, and uses temperature partitioning rules to transcode the temperature change data in the dataset. The data hyperparameters include the data loading period (years), temperature zoning rules, and backtracking days. The process of transcoding the temperature change data in the dataset using temperature zoning rules includes the following sub-steps: S21: Determine the temperature partition set according to the temperature partition rules, and define a temperature difference array according to the temperature partitions. The size of the temperature difference array is the same as the size of the temperature partition set, and the initial value of all elements in the temperature difference array is 0. S22: Traverse each partition of the temperature partition set to obtain the index and upper and lower limits of each partition; S23: Convert the temperature change data into temperature partition difference values ​​for each partition in the temperature partition set according to the transcoding rules, and set the temperature partition difference values ​​into the corresponding elements in the temperature difference array according to the index of each partition. The transcoding rules include: S231: Define the temperature before and after the temperature change as the first temperature and the second temperature, respectively; S232: Select any partition in the temperature partition set, and determine whether the first temperature or the second temperature is in that partition. If it is, the transcoded value of the first temperature or the second temperature in that partition is the initial value of the first temperature or the second temperature. If it is not, proceed to step S233. S233: Determine whether the first temperature or the second temperature is less than the lower limit of the partition. If yes, then transcode the value of the first temperature or the second temperature in the partition to the lower limit of the partition - 1; if no, then transcode the value of the first temperature or the second temperature in the partition to the upper limit of the partition. S234: The difference between the transcoding value of the second temperature and the first temperature is taken as the temperature partition difference between the first temperature and the second temperature in this partition. The model instance building module is used to generate predictive model instances for all combinations of model hyperparameters by using grid search traversal; The cross-validation module is used to train, validate, and evaluate prediction model instances under any combination of model hyperparameters based on a dataset with any combination of data hyperparameters, until cross-validation of all combinations of data hyperparameters and model hyperparameters is completed. The prediction module is used to sort the cross-validation results to obtain the optimal prediction model or the top few prediction models, and to predict the natural gas consumption of the target area based on the optimal prediction model or the top few prediction models.

8. The natural gas consumption prediction system based on temperature range as described in claim 7, characterized in that, The system also includes: The weighted prediction module is used to calculate the corresponding weighting coefficients for each of the previous prediction models based on their evaluation results, and to perform a weighted average of the prediction results of the previous prediction models according to the weighting coefficients to obtain the final prediction result.

Citation Information

Patent Citations

  • Short-term Load Forecasting Method Based on TCN and IPSO-LSSVM Combined Model

    AU2020104000A4

  • Smart grid classification and fuzzy neural network based natural gas load prediction method

    CN104123591A