Gas classification load prediction method based on LGBM-FOA-TFT

By combining LGBM, FOA and TFT models, the problem of single prediction cycle and user type in gas load prediction is solved, and more efficient and accurate gas load prediction is achieved.

CN119862983APending Publication Date: 2025-04-22ZHENGZHOU UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411817487.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-04-22

AI Technical Summary

Technical Problem

The existing gas load prediction methods have the problem of single prediction period and user type, which leads to low learning efficiency of model, sensitive to initial weights, and difficult to adapt to changes in different user types and prediction periods.

Method used

The gas classification load prediction method based on LGBM-FOA-TFT is adopted to predict weekly loads through LGBM, FOA optimizes the hyperparameters of the TFT model, and combines the gray correlation analysis method to perform daily load prediction to achieve adaptation to different user types and prediction cycles.

Benefits of technology

It improves the accuracy and robustness of gas load prediction, reduces the risk of overfitting the model, enhances the adaptability to different user types and prediction cycles, and solves the shortcomings of traditional methods in gas load prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119862983A_ABST
    Figure CN119862983A_ABST
Patent Text Reader

Abstract

A fuel gas classification load prediction method based on LGBM-FOA-TFT provides weekly load prediction on the basis of daily load prediction, and the weekly load prediction is obtained through LGBM feature importance analysis and through grey correlation degree analysis and influence factor combination. Urban and resident daily load data are easily influenced by weather conditions, wind power, air quality, holiday grades and weekly load data, on this basis, an LGBM-FOA-TFT model is provided, LGBM prediction results are used as new influence factors to be added into TFT rolling prediction, FOA is used for optimization, and therefore the prediction accuracy is improved. And predicting different periods of different users under different influence factors, and verifying the accuracy and validity. The result shows that the absolute percentage errors of the LGBM-FOA-TFT model in rolling day prediction of city data and resident data are 3.96% and 5.56% respectively, and the LGBM-FOA-TFT model is superior to a single TFT model in the aspects of root mean square error and mean absolute error.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a gas classification load prediction method based on LGBM-FOA-TFT. Background Art

[0002] The stable operation and effective planning of energy systems are crucial to the normal life of society and the sustainable development of the economy. In modern society, people's demand for energy is growing, and the internal environment and external development of gas are undergoing tremendous changes. As a clean and efficient form of energy, gas has become an important part of the energy structure. Its unique advantage is that it reduces environmental pollution during energy conversion and utilization and provides a reliable energy supply.

[0003] Gas is widely used in many fields, including industry, commerce and residents. In the industrial field, gas is used to drive production processes, supply heat energy and as a raw material for chemical production. In the commercial field, gas is widely used in the energy supply of some commercial facilities such as building heating. In residents' lives, gas is a common energy source used for cooking, heating and hot water.

[0004] However, with the development of the global economy and the increase in population, the demand for gas energy is also increasing. This growth has increased the burden on the energy system to a certain extent, and has put forward higher requirements for the stability and sustainability of energy supply. In order to better meet these needs, gas load forecasting has become a vital task. It can provide accurate data support for the planning and management of the energy system, help optimize resource allocation, improve energy utilization efficiency, and thus ensure the normal operation of society and sustainable economic development. In this context, the research and application of advanced forecasting models and algorithms has become an urgent need to solve energy challenges.

[0005] In the past, research on gas load forecasting mainly focused on single models, such as regression analysis, gray model, artificial neural network, etc. However, these single models have limited prediction accuracy and poor robustness. In recent years, with the development of intelligent algorithms, researchers have begun to try to use combined models to improve prediction performance, such as combining ARIMA and LSTM through the difference method; or using gray correlation analysis to analyze influencing factors and establish a Bernoulli gray model based on the linearized particle swarm optimization algorithm; combining optimization models with forecasting models; using three-parameter exponential smoothing to predict monthly loads; optimizing GRU neural networks based on the IPSO algorithm to improve prediction accuracy; using the block gradient boosting model with PCA features and sensitivity analysis features: ANN-CG-PCA model for prediction; using incremental random forest regression algorithms to reduce training time and improve prediction accuracy, using wavelet transform and enhanced Deep-RNN models to predict mixed hourly natural gas demand, and using genetic algorithms to optimize BP neural networks, etc. However, since gas load exhibits unstable and nonlinear characteristics, which makes it a volatile time series that is difficult to describe with a linear model, the existing combined forecasting methods still face some challenges when dealing with gas load forecasting problems, such as low model learning efficiency, sensitivity to initial weights, single user type, and single forecast period. Summary of the invention

[0006] The technical problem to be solved by the present invention is: to provide a gas classification load forecasting method based on LGBM-FOA-TFT in view of the problem of single natural gas forecasting cycle and single user type.

[0007] In order to solve the above technical problems, the present invention adopts the following technical solutions:

[0008] A gas classification load forecasting method based on LGBM-FOA-TFT comprises the following steps:

[0009] Step 1: LGBM weekly load forecasting: First, the data set is divided into urban data and resident data, and the LGBM model is used to perform feature importance analysis to determine the correlation between each influencing factor and the load result; according to the correlation results, different influencing factors are used for different data sets to reduce the overfitting risk of the model; finally, GridSearchCV is used to construct a search parameter grid to achieve parameter optimization of the LGBM model to achieve a higher accuracy weekly load forecast;

[0010] Step 2: FOA optimization algorithm: First, determine the parameters to be optimized of the TFT model and clarify their search range, using the MAPE value as the optimization objective function; then initialize the population and start iterative optimization. When the number of iterations reaches the upper limit, stop and return the parameter combination with the best fitness, which is used as the input of the TFT model;

[0011] Step 3: TFT daily load forecasting: Use the parameters optimized by FOA to build a TFT rolling forecasting model, and conduct comparative experiments based on the results of the grey correlation analysis method; when rolling the data, introduce the prediction results of LGBM as the key influencing factor; finally, through the comparison of experimental results, verify the effectiveness of the model and explore the differences between urban and residential users.

[0012] Step 1 also includes the following steps:

[0013] Step 1.1: Screening of factors affecting gas load: Quantify the values ​​of weather conditions and holiday types, thereby establishing a sample database of gas load and quantified influencing factors;

[0014] Step 1.2: Build the LGBM model

[0015] At each step, LGBM updates the model by minimizing the gradient of the loss function, and the model's predictions are represented as a stack of decision trees:

[0016] F(x)=F m-1 (x)+η·h m (x)

[0017] Where F(x) is the prediction of the model, Fm-1(x) is the prediction of the first m-1 trees, η is the learning rate, and h m (x) is the prediction of the mth tree;

[0018] LGBM uses a histogram-based algorithm to discretize the eigenvalues ​​into multiple intervals when constructing each tree to speed up calculations and reduce memory consumption. The goal of each tree is to minimize the following loss:

[0019]

[0020] Among them, g j and h j are the gradient and Hessian matrix of the current node, λ is the regularization parameter, and γ is the parameter used to control the complexity of the tree;

[0021] To prevent overfitting, LGBM introduces regularization terms, usually including L1 and L2 regularization:

[0022]

[0023] Among them, w j is the weight of the tree, and λ and α are the hyperparameters controlling L1 and L2 regularization, respectively.

[0024] In step 1.2, for the weekly load forecasting by LGBM, the factors with greater influence on the weekly load forecasting are selected through LGBM feature importance analysis; for the daily load forecasting by LGBM-FOA-TFT model, the correlation between different factors and daily load is calculated by grey correlation method, and different combinations of influencing factors are used to test the accuracy of the model;

[0025] In model construction, LGBM is first used to perform feature importance analysis to select factors that have a significant impact on daily load forecasting. Then, the FOA optimization algorithm is used to adjust the hyperparameters of the TFT model. Finally, the results of LGBM and the FOA-optimized TFT model are combined to achieve a more accurate daily load forecast.

[0026] In the formula, a and b are the minimum and maximum differences between the two levels, respectively, and X 0 is the daily load value of the reference sequence, x i is the data value of the subsequence influencing factor, i = 1, 2, ..., 9, t is the number of data groups, t = 1, 2, ..., n, ζ i (t) is the correlation coefficient between the i-th influencing factor column and the daily load value, p∈【0,1】, r i is the grey correlation degree of the influencing factors on daily load,

[0027]

[0028] In step 2, the FOA algorithm is divided into two stages, the first stage is olfactory search, and the second stage is visual search;

[0029] In the first stage, individual fruit flies rely on their sense of smell to determine the approximate direction of food, and release odor information to other fruit flies to share their own judgment of the location of food. After receiving information from surrounding fruit flies, they compare and determine the most accurate location of food. This process continues until all fruit flies reach a consensus on the location information.

[0030]

[0031] In the formula, (X i ,Y i ) represents the position information of each individual in the fruit fly population, Xaxis and Yaxis represent the initial position of the fruit fly, FR represents the single flight range of the fruit fly, rand represents random flight, and the following formula is used to calculate the taste concentration value Smell_i of each fruit fly individual in the current population

[0032]

[0033] Where fitness represents the taste judgment function. When using FOA for optimization, fitness is the objective function. Because the source of the food smell is unknown, the inverse of the distance from the point to the origin is calculated as the taste concentration judgment value. After finding the best taste concentration value bestSmell and its corresponding fruit fly position, bestIndex information, the second stage begins. Other fruit flies in the group use vision to fly to this position.

[0034] SmellBest = bestSmell;

[0035]

[0036] These two stages are repeated until the number of iterations of the algorithm is reached, and the final result is used as the optimal parameters of TFT.

[0037] In step 3, TFT combines deep learning and self-attention mechanism:

[0038] In the daily gas load forecasting, the TFT model uses the self-attention mechanism. By introducing a variable selection network, TFT dynamically adjusts the feature weights according to the input of each time step to help the model decide which input features should be paid attention to in the current forecast. The TFT model is as follows:

[0039] Input layer: receives time series data, usually including target variables, historical time features and external variables;

[0040] Variable selection network: Determine which features should be retained for the next prediction of the model by calculating the importance of each feature;

[0041] Sequence modeling: Self-attention captures long-term and short-term dependencies, allowing the model to dynamically generate the current hidden state based on all past inputs;

[0042] Output layer: Generates prediction values ​​based on hidden states and outputs load prediction for the current time step;

[0043] The variable selection network selects input features by calculating the importance of the features. The importance is calculated through an attention mechanism, and the formula is as follows:

[0044] α=softmax(W·x)

[0045] Among them, α is the selection weight of the feature, W is the learnable parameter, and x is the input feature;

[0046] TFT uses the self-attention mechanism to capture dependencies in time series: given an input sequence X = [x1, x2, …, xT], the self-attention mechanism calculates the attention weight A for each time step:

[0047]

[0048] Among them, the score function score is usually a dot product or a vector representation after linear transformation;

[0049] The output layer in TFT is usually composed of multiple fully connected layers to map features to prediction results; assuming the input is Z, the output of MLP is:

[0050] Y=MLP(Z)

[0051] The training process of TFT optimizes the model parameters by minimizing the loss function, which is the mean square error (MSE):

[0052]

[0053] Among them, L is the total loss, y i is the actual value, y^ i is the predicted value of the model.

[0054] In the present invention using the above technical solution, LGBM as a gradient boosting tree model can effectively capture the overall trend of the data. The FOA algorithm optimizes the parameters of TFT by simulating the intelligent foraging behavior of fruit flies to improve the generalization ability of the model. The TFT network uses its powerful sequence modeling capabilities to extract time series data layer by layer through an embedded integrated structure, and deeply explores the spatiotemporal characteristics, thereby making the prediction results more accurate. The present invention combines the three, so that the combination of the three can improve the overall prediction performance and solve the shortcomings of traditional methods in natural gas demand prediction. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 It is the overall flow chart of the present invention;

[0056] Figure 2 This is the importance analysis diagram of factors affecting gas weekly load;

[0057] Figure 2 (a) Diagram of factors affecting weekly load of urban data;

[0058] Figure 2 (b) Diagram of factors affecting weekly load of resident data;

[0059] Figure 3 This is the weekly load forecast result;

[0060] Figure 3 (a) is the city weekly load forecast diagram;

[0061] Figure 3 (b) is the residents' weekly load forecast diagram;

[0062] Figure 4 It is the MAPE value for daily load prediction. DETAILED DESCRIPTION

[0063] At present, LGBM, as a gradient boosting algorithm based on a tree model, has attracted widespread attention for its outstanding performance in forecasting problems. Through continuous iteration, LGBM can gradually improve the performance of weak models and adapt to complex nonlinear relationships, which makes it perform well in weekly load forecasting. At the same time, the fruit fly optimization algorithm (FOA), as a heuristic optimization algorithm, is inspired by observing the behavior of fruit flies when looking for food. The algorithm uses information transmission and mutual cooperation between individual fruit flies to search the solution space of the problem. By simulating the process of fruit flies releasing pheromones when looking for the shortest path, FOA can find a better solution in the search space, thereby optimizing the hyperparameters of TFT.

[0064] The time fusion transformer (TFT) combines the advantages of sequence modeling and time series feature processing, which can effectively capture the dynamic patterns in time series and is particularly suitable for processing energy data forecasting tasks with temporal and dynamic characteristics. The structure of TFT can flexibly integrate various input features, making it have strong expressive power in complex forecasting problems. Combining LGBM, FOA and TFT can further improve the accuracy of daily forecasts while predicting weekly loads, thereby achieving more accurate energy demand forecasts.

[0065] In the present invention, a gas classification load forecasting method based on LGBM-FOA-TFT is established, a combined model based on LGBM-FOA-TFT is established, and LGBM, FOA (Fruit Fly Optimization Algorithm) and TFT network models are integrated into an overall forecasting framework, such as Figure 1 As shown in the figure, the LGBM model is used to process the overall prediction of gas weekly load data, the FOA algorithm optimizes the hyperparameters of the TFT model, and the TFT network focuses on mining the spatiotemporal characteristics in time series data for daily load forecasting.

[0066] The present invention comprises the following steps:

[0067] Step 1: LGBM weekly load forecasting: First, the data set is divided into urban data and resident data, and the LGBM model is used to perform feature importance analysis to determine the correlation between each influencing factor and the load result. According to the correlation results, different influencing factors are used for different data sets to reduce the risk of overfitting of the model. Finally, GridSearchCV is used to construct a search parameter grid to achieve parameter optimization of the LGBM model to achieve a higher accuracy weekly load forecast.

[0068] Step 2: FOA optimization algorithm: First, determine the parameters to be optimized of the TFT model and clarify its search range, using the MAPE value as the optimization objective function. Then initialize the population and start iterative optimization. When the number of iterations reaches the upper limit, stop and return the parameter combination with the best fitness, which is used as the input of the TFT model.

[0069] Step 3: TFT daily load forecasting: The TFT rolling forecasting model is constructed using the parameters optimized by FOA, and a comparative experiment is conducted based on the results of the grey correlation analysis method. When rolling the data, the forecast results of LGBM are introduced as the key influencing factors. Finally, the effectiveness of the model is verified and the differences between urban and residential users are explored through the comparison of experimental results.

[0070] Step 1 also includes the following steps:

[0071] Step 1.1: Screening of factors affecting gas load:

[0072] The prediction of urban and residential gas load involves multiple influencing factors. The reasonable selection of these factors is crucial to improving the accuracy of the prediction model. Since the input of machine learning requires numerical data, the weather conditions and holiday types are quantified (Table 1, Table 2). Thus, a sample database of gas load and quantified influencing factors is established.

[0073] Table 1 Quantification table of weather conditions

[0074] clear Negative cloud fog haze rain Snow other 1 2 3 4 5 6 7 8

[0075] Table 2 Holiday type quantification table

[0076] Working Day weekend Qingming Festival Labor Day Dragon Boat Festival Mid-Autumn Festival National Day New Year Spring Festival 0 1 2 3 4 5 6 7 8

[0077] The present invention adopts two different strategies in the selection of influencing factors, corresponding to the two types of data, city and resident, to more comprehensively evaluate the performance of the model at different prediction levels.

[0078] For the weekly load forecasting by LGBM, the factors with greater impact on the weekly load forecasting are selected through LGBM feature importance analysis to reduce the complexity of the model. This method can effectively quantify the linear and nonlinear relationships between factors and provide key reference information for the weekly load forecasting model. Analyzing the importance of influencing factors such as average weather conditions, maximum temperature, minimum temperature, average temperature, wind force level, air quality, number of holidays, and whether it is a heating week helps to deeply understand the impact of these factors on the weekly load forecasting and analyze the difference in impact between urban weekly load data and residential weekly load data.

[0079] Through Figure 2 (a) with Figure 2 Comparative analysis of (b) shows that urban weekly load data is more susceptible to the highest temperature, lowest temperature, average temperature and whether it is a heating week, while it is less affected by air quality, wind level, number of holidays and average weather conditions. Compared with urban data, residential data is more susceptible to air quality, and is also affected by average temperature, number of holidays and wind level.

[0080] Therefore, in order to improve the accuracy of the prediction and reduce the complexity of the model, in the construction of the model, for the urban weekly load data, the factors that are more closely related to the weekly load, such as the maximum temperature, minimum temperature, average temperature, and whether it is a heating week, are selected to be retained, and the factors that are less closely related to the weekly load, such as air quality, wind force level, average weather conditions, and number of holidays, are discarded. For the resident data, the factors that are more closely related to the gas load, such as the maximum temperature, minimum temperature, average temperature, air quality, and whether it is a heating week level, are selected to be retained, and the variables that are less closely related to the weekly load, such as average weather conditions and number of holidays, are discarded. Such variable selection is expected to improve the prediction performance of the model and better reflect the key factors affecting the weekly load of cities and residents.

[0081] For the daily load forecasting by the LGBM-FOA-TFT model, the grey correlation method is used to calculate the correlation between different factors and the daily load, and different combinations of influencing factors are used to test the accuracy of the model. There may be nonlinear and non-stationary relationships in time series data, and the grey correlation method is an effective method for analyzing the correlation of time series data. It considers the overall characteristics of the sequence and can still play a good role when the data is highly irregular.

[0082] In model construction, LGBM is first used to perform feature importance analysis to select factors that have a significant impact on daily load forecasting. Then, the FOA optimization algorithm is used to adjust the hyperparameters of the TFT model to improve the model's prediction ability. Finally, the results of LGBM and the FOA-optimized TFT model are combined to achieve more accurate daily load forecasting.

[0083] In the formula, a and b are the minimum and maximum differences between the two levels, respectively, and X 0 is the daily load value of the reference sequence, x i is the data value of the subsequence influencing factor, i = 1, 2, ..., 9, t is the number of data groups, t = 1, 2, ..., n, ζ i (t) is the correlation coefficient between the i-th influencing factor column and the daily load value, p∈【0,1】, r i is the grey correlation degree of influencing factors on daily load.

[0084]

[0085] Table 3 Grey correlation calculation results

[0086] data situation tempHigh tempLow tempAvg windLevel airData holidayLevel Heating weeklyUse City 0.69 0.54 0.54 0.53 0.73 0.75 0.65 0.62 0.67 Resident 0.68 0.60 0.60 0.60 0.71 0.70 0.68 0.59 0.63

[0087] The influencing factors include weather conditions (such as sunny, rainy, etc.), maximum temperature, minimum temperature, average temperature, wind factors, air quality, holiday level, whether it is a heating day and weekly load factors. The correlation results calculated by formula 1-4 are shown in Table 3. The top five factors with the highest correlation are selected, that is, weather conditions, wind, air quality, holiday level and weekly load data are selected for urban and resident daily load forecasts. The remaining factors are added to the model in sequence according to the correlation degree. The final selected influencing factors are determined according to the forecast results, so as to more accurately predict the daily gas load. This comprehensive influencing factor selection strategy is expected to provide useful inspiration for improving the overall performance of the model and exploring the differences between cities and residents in the selection of influencing factors.

[0088] Step 1.2: Build the LGBM model

[0089] Gas weekly load forecasting is one of the important tasks to achieve efficient energy management, which is affected by many factors. LGBM, as a gradient boosting machine (GBM) algorithm, can mine the complex relationship between factors in the data by integrating multiple decision trees, and then make choices for factors such as temperature and weather, which can improve the prediction accuracy and reduce the complexity of the model.

[0090] LightGBM (LGBM) is a machine learning algorithm based on gradient boosted decision tree (GBDT), designed for high efficiency and scalability. Its core idea is to improve the prediction ability of the model by gradually optimizing the loss function and building a series of weak learners (decision trees). The following are the basic formulas and concepts of LGBM:

[0091] The loss function used by LGBM is usually the squared error (for regression problems) or the logarithmic loss (for classification problems). The general form is:

[0092]

[0093] Among them, L is the total loss, n is the number of samples, and y i is the actual value, F(x i ) is the predicted value of the model.

[0094] At each step, LGBM updates the model by minimizing the gradient of the loss function. The prediction of the model can be represented as a stack of decision trees:

[0095] F(x)=F m-1 (x)+η·h m (x)

[0096] Where F(x) is the prediction of the model, Fm-1(x) is the prediction of the first m-1 trees, η is the learning rate, and h m (x) is the prediction of the mth tree.

[0097] LGBM uses a histogram-based algorithm to discretize the eigenvalues ​​into multiple intervals when constructing each tree to speed up calculations and reduce memory consumption. The goal of each tree is to minimize the following loss:

[0098]

[0099] Among them, g j and h j are the gradient and Hessian matrix of the current node, λ is the regularization parameter, and γ is the parameter used to control the complexity of the tree.

[0100] To prevent overfitting, LGBM introduces regularization terms, usually including L1 and L2 regularization:

[0101]

[0102] Among them, w j is the weight of the tree, and λ and α are the hyperparameters controlling L1 and L2 regularization, respectively.

[0103] LGBM provides a powerful and efficient modeling method for gas weekly load forecasting by integrating multiple decision trees, comprehensively considering multiple factors, and optimizing the target loss function, providing strong support for achieving sustainable and intelligent energy management.

[0104] In step 2, the FOA (FruitFlyOptimizationAlgorithm) algorithm is a new global optimization algorithm that simulates the foraging behavior of fruit flies. It finds the optimal solution to the problem by simulating the strategy of fruit flies when searching for food. The parameter optimization of TFT is a high-dimensional, non-convex, and complex search space problem. The global search characteristics of FOA help to find better parameter configurations. The process of fruit fly colonies searching for food is divided into two stages. The first stage is olfactory search, and the second stage is visual search.

[0105] In the first stage, individual fruit flies rely on their sense of smell to determine the general direction of the food, and release odor information to other fruit flies to share their judgment of the location of the food. After receiving the information transmitted by the surrounding fruit flies, they compare with each other to determine the most accurate location of the food. This process continues until all fruit flies reach a consensus on the location information.

[0106]

[0107] In the formula, (X i ,Y i ) represents the position information of each individual in the fruit fly population, Xaxis and Yaxis represent the initial position of the fruit fly, FR represents the single flight range of the fruit fly, rand represents random flight, and the following formula is used to calculate the taste concentration value Smell_i of each fruit fly individual in the current population

[0108]

[0109] Where fitness represents the taste judgment function. When using FOA for optimization, fitness is the objective function. Because the source of the food smell is unknown, the inverse of the distance from the point to the origin is calculated as the taste concentration judgment value Si. After finding the best taste concentration value bestSmell and its corresponding fruit fly position, bestIndex information, the second stage begins. Other fruit flies in the group use vision to fly to this position.

[0110] SmellBest = bestSmell;

[0111]

[0112] These two stages are repeated until the number of iterations of the algorithm is reached, and the final result is used as the optimal parameters of TFT.

[0113] The FOA algorithm simulates the foraging and reconnaissance strategies of fruit flies and realizes an efficient global optimization method. It is suitable for solving various complex problems and seeks better parameters for TFT to improve the accuracy of the model.

[0114] In step 3, Temporal Fusion Transformer (TFT) is a model for time series forecasting that combines deep learning and self-attention mechanism to process multiple features in time series data, especially the relationship between time series features and external features. Gas daily load forecasting is a typical time series problem. Using TFT to forecast gas daily load can effectively capture the time series relationship between daily load usage.

[0115] In the gas daily load forecasting, the TFT model uses the self-attention mechanism to dynamically select which historical information is important, thereby better retaining relevant time features. By introducing a variable selection network, TFT dynamically adjusts the feature weights according to the input of each time step, helping the model decide which input features should be focused on in the current forecast.

[0116] The input layer of TFT includes current input features and past time series data. By introducing a gating mechanism, the model can selectively retain or forget information. Specifically:

[0117] Input layer: receives time series data, usually including target variables, historical time features, and external variables.

[0118] Variable selection network: By calculating the importance of each feature, determine which features should be retained for the next prediction of the model.

[0119] Sequence Modeling: The self-attention mechanism captures long-term and short-term dependencies, allowing the model to dynamically generate the current hidden state based on all past inputs.

[0120] Output layer: Generates predicted values ​​based on hidden states and outputs the load forecast for the current time step.

[0121] The variable selection network selects input features by calculating the importance of the features. The importance is usually calculated through a simple attention mechanism, as follows:

[0122] α=softmax(W·x) where α is the feature selection weight, W is a learnable parameter, and x is the input feature.

[0123] TFT uses the self-attention mechanism to capture dependencies in time series. Given an input sequence X = [x1, x2, ..., xT], the self-attention mechanism calculates the attention weight A for each time step:

[0124]

[0125] Among them, the score function score is usually a dot product or a vector representation after linear transformation.

[0126] The output layer in TFT is usually composed of multiple fully connected layers to map features to prediction results. Assuming the input is Z, the output of MLP is:

[0127] Y=MLP(Z)

[0128] The training process of TFT optimizes the model parameters by minimizing the loss function. The commonly used loss function is the mean square error (MSE):

[0129]

[0130] Among them, L is the total loss, y i is the actual value, y^ i is the predicted value of the model.

[0131] The design of TFT allows the model to capture and utilize long-term dependencies in time series in a targeted manner, thereby improving the accuracy of forecasts. This flexibility makes TFT particularly suitable for forecasting urban and residential daily loads.

[0132] experiment

[0133] 3.1 Dataset

[0134] The present invention actually collects the overall gas load data of a city from January 2017 to October 2022 and the gas load data of residents in some areas of a city from January 2021 to September 2023. Daily temperature data, weather conditions, wind data and air quality data are collected from the weather data website.

[0135] The input of LGBM is weekly data (Table 4). The data is processed in such a way that the weather conditions, temperature and air quality data are taken as weekly averages, and the number of holidays and gas load values ​​are taken as weekly sums.

[0136] Table 4 Gas Weekly Load Sample Data

[0137]

[0138]

[0139] The input of TFT is daily data (Table 5), and the data is processed by daily temperature data, weather conditions, wind data, air quality and total data for the week in which the day falls.

[0140] Table 5 Gas daily load sample data

[0141]

[0142] 3.3 Selection of combination model parameters

[0143] 3.3.1LGBM parameter selection

[0144] When using LGBM for weekly load forecasting, optimizing the model parameters is a critical step, which directly affects the performance and generalization ability of the model. A set of parameter grids to be searched is defined using GridSearchCV, including different parameter combinations. GridSearchCV will try all possible parameter combinations and finally select the optimal parameter combination (Table 6).

[0145] Table 6 LGBM parameter selection

[0146] data objective num_leaves learning_rate max_depth n_estimators City data regression 50 0.1 7 30 Resident data regression 30 0.1 3 30

[0147] 3.3.2 FOA parameter selection

[0148] The performance of FOA depends largely on the selection of its internal parameters. FOA is used to optimize the parameters of TFT, taking the optimization of seq_len as an example. seq_len represents the length of the time series data accepted by the TFT model. Table 7 shows some parameter selections.

[0149] Table 7 FOA parameter selection

[0150] populations_size iteration range_low range_high 30 100 5 25

[0151] 3.3.3TFT parameter selection

[0152] The parameters for TFT daily prediction are based on the results of the FOA optimization algorithm (Table 8).

[0153] Table 8 Selection of some parameters of TFT model

[0154]

[0155]

[0156] 3.4 Model Performance Analysis

[0157] 3.4.1 Model evaluation indicators

[0158] In order to comprehensively evaluate the prediction accuracy of the LGBM-FOA-TFT gas daily load forecasting model, the following evaluation indicators are selected. f and Represent the actual value and model prediction value of the i-th sample, f=1,2,...,N, N is the total number of samples. MAE measures the error between the model prediction value and the actual value.

[0159] (1) Mean absolute error MAE (Equation 13).

[0160]

[0161] (2) Root mean square error RMSE (Equation 14).

[0162]

[0163] RMSE indicates the degree of dispersion between the model prediction value and the actual value, and it is highly sensitive to errors.

[0164] (3) Mean absolute percentage error MAPE (Formula 15).

[0165]

[0166] MAPE is an indicator to measure the overall error of the model. It expresses the size of the model prediction error relative to the actual value in percentage form. The smaller the value of these evaluation indicators, the higher the prediction accuracy of the model.

[0167] 3.4.2 Analysis of weekly prediction performance of LGBM model

[0168] For the two datasets of cities and residents, the results are as follows Figure 3 shown.

[0169] Table 9 Weekly load forecast performance

[0170] Dataset MAE RMSE MAPE City data 688000.46 1065000.26 4.21% Resident data 1780.57 2350.72 5.46%

[0171] In summary, comparison Figure 3 (a) Figure 3 The image in (b) and the performance comparison data in Table 9 show that, in the urban and residential weekly load forecasting, the weekly load forecasting model achieved good results in MAE, RMSE and MAPE through LBGM feature importance analysis, which provides a good foundation for the subsequent TFT daily forecasting.

[0172] 3.4.3 Analysis of daily forecasting performance of TFT model

[0173] TFT daily forecast selects 15 days rolling forecast for 7 days, for example, use [1-15] to predict

[16] , and then use [2-16] to predict 17, and so on. The five factors with the highest grey correlation are selected first, and the remaining factors are substituted into the forecast model from high to low. The order of urban data factors is heating, tempHigh, tempLow, tempAvg, and the order of resident data factors is tempHigh, tempLow, tempAvg, heating.

[0174] Table 10 Comparison of daily load forecast results

[0175]

[0176]

[0177] like Figure 4 As shown, after comparative analysis of the results, it is concluded that for urban data, in addition to the preferred factors, the heating factor is selected to make the model prediction value most accurate, and the mape value is 3.96%. For resident data, in addition to the preferred factors, the tempHigh factor is selected to make the model prediction value most accurate, and the mape value is 5.56%.

[0178] In the rolling forecast of both city and resident data, the value of WeeklyUse is generated by LGBM forecast. Under the optimal combination of city and resident factors, WeeklyUse is removed and the forecast results with and without WeeklyUse are compared to analyze the accuracy comparison between LBGM-FOA-TFT and other models.

[0179] Table 11 Comparison of daily load forecasting performance under different models

[0180]

[0181] In summary, for the urban and residential daily load data, comparing the performance data in Table 11, it is found that under the same parameters, LGBM-FOA-TFT performs better in all three indicators (MAE, RMSE, MAPE), which shows that the model is more accurate in urban load forecasting and has higher precision.

[0182] The model combining LBGM and FOA-TFT may take advantage of the advantages of TFT in characterizing data and the ability of FOA-TFT on time series data. This combination improves the overall performance of the model and makes it more powerful in gas load forecasting.

[0183] Based on LGBM, FOA and TFT, the LGBM-FOA-TFT gas daily load data model was established, and the accuracy and effectiveness were verified by the gas load data of a certain city. Based on the research results, the following conclusions were drawn.

[0184] (1) In terms of gas load forecasting, the performance of the LGBM-FOA-TFT model is significantly better than that of the single TFT model. This shows that the model that comprehensively considers LGBM, FOA, and TFT has significant advantages in improving forecasting accuracy.

[0185] (2) By adopting the LGBM feature importance analysis, the present invention clarifies that the urban weekly load data is greatly affected by temperature and heating conditions, and less affected by other factors, while the resident weekly load data is greatly affected by temperature, air quality and heating conditions.

[0186] (3) By adopting the grey correlation method for analysis, the present invention clarifies that both urban and residential daily load data are greatly affected by weather conditions, wind speed, air quality, holiday levels, and weekly load data. Subsequent experiments have shown that urban daily load is more susceptible to the impact of heating conditions, while residential daily load is more susceptible to the impact of maximum temperature.

[0187] (4) Although the model performs well on urban data, it is not very accurate in predicting resident data. To address this issue, further optimization should involve eliminating factors with less influence to improve the simplicity of the model, and it is recommended to consider other factors such as local economic factors and government policies for model optimization.

Claims

1. A gas classification load forecasting method based on LGBM-FOA-TFT, characterized by: The steps include: Step 1: LGBM weekly load forecasting: First, the data set is divided into urban data and resident data, and the LGBM model is used to perform feature importance analysis to determine the correlation between each influencing factor and the load result; according to the correlation results, different influencing factors are used for different data sets to reduce the overfitting risk of the model; finally, GridSearchCV is used to construct a search parameter grid to achieve parameter optimization of the LGBM model to achieve a higher accuracy weekly load forecast; Step 2: FOA optimization algorithm: First, determine the parameters to be optimized of the TFT model and clarify their search range, using the MAPE value as the optimization objective function; then initialize the population and start iterative optimization. When the number of iterations reaches the upper limit, stop and return the parameter combination with the best fitness, which is used as the input of the TFT model; Step 3: TFT daily load forecasting: Use the parameters optimized by FOA to build a TFT rolling forecasting model, and conduct comparative experiments based on the results of the grey correlation analysis method; when rolling the data, introduce the prediction results of LGBM as the key influencing factor; finally, through the comparison of experimental results, verify the effectiveness of the model and explore the differences between urban and residential users.

2. The gas classification load forecasting method based on LGBM-FOA-TFT according to claim 1 is characterized by: Step 1 also includes the following steps: Step 1.1: Screening of factors affecting gas load: Quantify the values ​​of weather conditions and holiday types, thereby establishing a sample database of gas load and quantified influencing factors; Step 1.2: Build the LGBM model At each step, LGBM updates the model by minimizing the gradient of the loss function, and the model's predictions are represented as a stack of decision trees: F(x)=F m-1 (x)+η·h m (x) Where F(x) is the prediction of the model, Fm-1(x) is the prediction of the first m-1 trees, η is the learning rate, and h m (x) is the prediction of the mth tree; LGBM uses a histogram-based algorithm to discretize the eigenvalues ​​into multiple intervals when constructing each tree to speed up calculations and reduce memory consumption. The goal of each tree is to minimize the following loss: Among them, g j and h j are the gradient and Hessian matrix of the current node respectively, λ is the regularization parameter, γ is a parameter used to control the complexity of the tree; To prevent overfitting, LGBM introduces regularization terms, usually including L1 and L2 regularization: Among them, w j is the weight of the tree, and λ and α are the hyperparameters controlling L1 and L2 regularization, respectively.

3. The gas classification load forecasting method based on LGBM-FOA-TFT according to claim 1 is characterized in that: In step 1.2, for the weekly load forecasting by LGBM, the factors with greater influence on the weekly load forecasting are selected through LGBM feature importance analysis; for the daily load forecasting by LGBM-FOA-TFT model, the correlation between different factors and daily load is calculated by grey correlation method, and different combinations of influencing factors are used to test the accuracy of the model; In model construction, LGBM is first used to perform feature importance analysis to select factors that have a significant impact on daily load forecasting. Then, the FOA optimization algorithm is used to adjust the hyperparameters of the TFT model. Finally, the results of LGBM and the FOA-optimized TFT model are combined to achieve a more accurate daily load forecast. In the formula, a and b are the minimum and maximum differences between the two levels, respectively, X0 is the daily load value of the reference sequence, and x i is the data value of the subsequence influencing factor, i = 1, 2, ..., 9, t is the number of data sets, t = 1, 2, ..., n, ζ i (t) is the correlation coefficient between the i-th influencing factor column and the daily load value, p∈【0,1】, r i is the grey correlation degree of the influencing factors on daily load, 4. The gas classification load forecasting method based on LGBM-FOA-TFT according to claim 1 is characterized by: In step 2, the FOA algorithm is divided into two stages, the first stage is olfactory search, and the second stage is visual search; In the first stage, individual fruit flies rely on their sense of smell to determine the approximate direction of food, and release odor information to other fruit flies to share their own judgment of the location of food. After receiving information from surrounding fruit flies, they compare and determine the most accurate location of food. This process continues until all fruit flies reach a consensus on the location information. In the formula, (X i ,Y i ) represents the position information of each individual in the fruit fly population, Xaxis and Yaxis represent the initial position of the fruit fly, FR represents the single flight range of the fruit fly, rand represents random flight, and the following formula is used to calculate the taste concentration value Smell_i of each fruit fly individual in the current population Where fitness represents the taste judgment function. When using FOA for optimization, fitness is the objective function. Because the source of the food smell is unknown, the inverse of the distance from the point to the origin is calculated as the taste concentration judgment value. After finding the best taste concentration value bestSmell and its corresponding fruit fly position, bestIndex information, the second stage begins. Other fruit flies in the group use vision to fly to this position. SmellBest = bestSmell; These two stages are repeated until the number of iterations of the algorithm is reached, and the final result is used as the optimal parameters of TFT.

5. The gas classification load forecasting method based on LGBM-FOA-TFT according to claim 1 is characterized by: In step 3, TFT combines deep learning and self-attention mechanism: In the daily gas load forecasting, the TFT model uses the self-attention mechanism. By introducing a variable selection network, TFT dynamically adjusts the feature weights according to the input of each time step to help the model decide which input features should be paid attention to in the current forecast. The TFT model is as follows: Input layer: receives time series data, usually including target variables, historical time features and external variables; Variable selection network: Determine which features should be retained for the next prediction of the model by calculating the importance of each feature; Sequence modeling: Self-attention captures long-term and short-term dependencies, allowing the model to dynamically generate the current hidden state based on all past inputs; Output layer: Generates prediction values ​​based on hidden states and outputs load prediction for the current time step; The variable selection network selects input features by calculating the importance of the features. The importance is calculated through an attention mechanism, and the formula is as follows: α=softmax(W·x) Among them, α is the selection weight of the feature, W is the learnable parameter, and x is the input feature; TFT uses the self-attention mechanism to capture dependencies in time series: given an input sequence X = [x1, x2, …, xT], the self-attention mechanism calculates the attention weight A for each time step: Among them, the score function score is usually a dot product or a vector representation after linear transformation; The output layer in TFT is usually composed of multiple fully connected layers to map features to prediction results; assuming the input is Z, the output of MLP is: Y=MLP(Z) The training process of TFT optimizes the model parameters by minimizing the loss function, which is the mean square error (MSE): Among them, L is the total loss, y i is the actual value, y^ i is the predicted value of the model.