XGBoost-based natural gas price prediction method, system, storage medium and device

By calculating the cross-correlation function and the autocorrelation function, an XGBoost-based prediction model was constructed, which solved the problems of nonlinear relationships and the influence of multiple factors in liquefied natural gas price prediction, improved the prediction accuracy and precision, and met the needs of supply and demand balance and marketing.

CN123160194APending Publication Date: 2026-11-24PETROCHINA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510654172.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-21
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Existing liquefied natural gas (LNG) price forecasting models cannot effectively handle complex nonlinear relationships, cannot accurately capture and predict price changes, and ignore the dynamic relationships of historical data and various influencing factors, resulting in low forecast accuracy and poor explanatory power.

Method used

By calculating the cross-correlation and autocorrelation functions of natural gas price data and multiple influencing factor data sequences, the target influencing factors and lag periods are determined. An XGBoost-based prediction model is then constructed, taking into account the lag effect of influencing factors on prices and the lag effect of prices themselves, thereby improving prediction accuracy.

Benefits of technology

It improves the accuracy and precision of liquefied natural gas price forecasts, enabling better understanding of price trends and achieving effective supply-demand balance and marketing to ensure supply.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123160194A_ABST
    Figure CN123160194A_ABST
Patent Text Reader

Abstract

This disclosure belongs to the field of natural gas technology and provides a method, system, storage medium, and device for natural gas price prediction based on XGBoost. The method includes: preprocessing natural gas price-related data to generate standard data and a standard data sequence; calculating the cross-correlation function between the standard data sequence and the influencing factor data sequence, calculating the autocorrelation function between the standard data sequence and the lagged standard data sequence, determining the target influencing factor data sequence and its corresponding target lag period, and the optimal lag period corresponding to the standard data sequence; constructing a sample dataset to train the XGBoost model and generate an initial prediction model; setting the candidate value range of hyperparameters, forming a parameter grid, and determining the optimal hyperparameter combination; generating a final prediction model based on the optimal hyperparameter combination and the sample dataset; and using the final prediction model to predict the price of natural gas. This improves the accuracy of the final prediction model in predicting natural gas prices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure pertains to the field of natural gas technology, and particularly relates to a natural gas price prediction method, system, storage medium, and device based on XGBoost. Background Technology

[0002] Liquefied natural gas (LNG) plays a vital role in the gas supply structure due to its advantages such as convenient, flexible, safe, and efficient transportation. Significant LNG price fluctuations can hinder companies from developing long-term investment plans, reduce gas users' willingness to consume LNG, particularly in the industrial and power generation sectors, and impede the large-scale development of the LNG market. Unstable LNG ex-factory prices can also lead to imbalances in natural gas supply and demand, thereby affecting national energy security strategies. Therefore, accurate forecasting of LNG ex-factory prices is crucial for understanding price trends and achieving a balance between supply and demand. Accurate price forecasting is also essential for improving marketing, supply assurance, and profitability.

[0003] Currently, the common approach to predicting liquefied natural gas (LNG) prices is to establish predictive models. These predictive models fall into three categories: statistical models, artificial intelligence models, and combined predictive models.

[0004] Statistical models are generally based on linear assumptions and primarily utilize price-related data for modeling. Due to their fast processing speed, they are widely used for price forecasting with continuous, trend-based, periodic, and seasonal patterns. However, because their parameters are fixed, statistical models cannot handle complex nonlinear relationships and generally can only predict univariate time series data. They cannot introduce other influencing variables into the model. Due to the high volatility of liquefied natural gas (LNG) prices, their accuracy in predicting LNG prices is relatively low, and they suffer from poor externalities, strong data dependence, and poor fitting performance when data is volatile or noisy. Artificial intelligence (AI) models have strong data fitting capabilities and can maintain high accuracy even with large data fluctuations. They have good predictive performance on the nonlinear parts of time series data, but they also suffer from high data requirements and poor model interpretability. When forecasting liquefied natural gas prices, combined forecasting models, including equal-weighted average combination methods and variable-weighted combination methods, obtain the forecast values ​​at different times by corresponding weighting. They only consider the fusion of forecast values ​​for the same period, emphasize the impact of the current period, and ignore the information contained in historical data. Therefore, they cannot effectively identify the dynamic relationship between variables and cannot more accurately capture and predict price changes.

[0005] Liquefied natural gas (LNG) price data exhibits both linear and nonlinear characteristics, possessing complex internal relationships and inherent instability. Using a single forecasting model makes it difficult to accurately grasp the patterns of data change, thus compromising forecast accuracy. Furthermore, market price formation and fluctuations are often influenced by multiple factors, including geographical environment, time, and climate, the effects of which take time to manifest in market prices. LNG price data is affected not only by contemporaneous data but also by historical data, exhibiting a certain lag effect. Relying solely on simple correlation tests to screen influencing factors can easily lead to omitted variables, inaccurate forecasts, and poor explanatory power. Summary of the Invention

[0006] To address the aforementioned issues, this disclosure provides a natural gas price prediction method, system, storage medium, and device based on XGBoost. Before model training, the cross-correlation function of the standard data sequence corresponding to natural gas price-related data and multiple influencing factor data sequences is calculated, as well as the autocorrelation function of the standard data sequence and its lagged counterpart. Based on the correlation between the autocorrelation function and multiple cross-correlation functions, the target influencing factor data sequence and its corresponding target lag period, and the optimal lag period corresponding to the standard data sequence are determined. Using the standard data sequence and its corresponding optimal lag period, and the target influencing factor data sequence and its corresponding target lag period as input variables, and the standard data as the output variable, a sample dataset is constructed. Based on the sample dataset, the final prediction model is trained and generated. The final prediction model considers the lag effect of the influence of influencing factors on natural gas prices, as well as the lag effect inherent in natural gas prices themselves, thus improving the accuracy of natural gas price prediction.

[0007] This invention is achieved through the following technical solution:

[0008] In a first aspect, embodiments of this disclosure provide a natural gas price prediction method based on XGBoost, the method comprising:

[0009] Natural gas price-related data and multiple influencing factor data sequences are obtained through data terminals. The natural gas price-related data is preprocessed to generate standard data and standard data sequences.

[0010] Calculate the cross-correlation function between the standard data sequence and multiple influencing factor data sequences, calculate the autocorrelation function between the standard data sequence and the lagged standard data sequence, determine the correlation between the autocorrelation function and multiple cross-correlation functions, and determine the target influencing factor data sequence and the corresponding target lag period, as well as the optimal lag period corresponding to the standard data sequence.

[0011] Using standard data sequences and their corresponding optimal lag periods, target influencing factor data sequences and their corresponding target lag periods as input variables, and standard data as output variables, a sample dataset is constructed. The XGBoost model is trained using the sample dataset to generate an initial prediction model.

[0012] Set the candidate value range of hyperparameters to form a parameter grid. Based on the parameter grid and the sample dataset, determine the optimal combination of hyperparameters for the initial prediction model.

[0013] Based on the optimal combination of hyperparameters, an initial prediction model is trained using a sample dataset to generate the final prediction model.

[0014] Acquire real-time data, use the final prediction model to predict the price of natural gas, and feed the final prediction results back to the data terminal.

[0015] Furthermore,

[0016] Obtain price-related data tables and influencing factor data sequences through data terminals;

[0017] Identify characters in a price-related data table, convert the characters to floating-point numbers, generate price-related data, handle missing values ​​in the price-related data, and generate a given dataset based on the price-related data after handling missing values.

[0018] Identify and locate outliers in a given dataset that are significantly different from other data points.

[0019] Process outliers in a given dataset and generate the original dataset based on the processed dataset.

[0020] The original data is converted into a standard normal distribution with a mean of 0 and a standard deviation of 1, generating standard data and standard data sequences.

[0021] Furthermore,

[0022] The cross-correlation function between the standard data series and the influencing factor data series is expressed as:

[0023]

[0024] Wherein, formula (1) is the continuous form of the cross-correlation function between the standard data sequence and the influencing factor data sequence, and formula (2) is the discrete form of the cross-correlation function between the standard data sequence and the influencing factor data sequence; f(t) represents the standard data sequence, g(t) represents the influencing factor data sequence, g(t+τ) represents the influencing factor data sequence with a time lag of τ, t represents the integral variable of time, and τ represents the time difference between the two sequences.

[0025] Furthermore,

[0026] The autocorrelation function of the standard data sequence and the lagged standard data sequence is expressed as:

[0027]

[0028] Wherein, formula (3) is the continuous form of the autocorrelation function of the standard data sequence and the lagged standard data sequence, and formula (4) is the discrete form of the autocorrelation function of the standard data sequence and the lagged standard data sequence; f(t+τ) represents the standard data sequence with a lagged time difference τ, t represents the integral variable of time, and τ represents the time difference between the two sequences.

[0029] Furthermore,

[0030] The correlation coefficients of multiple cross-correlation functions of the standard data sequence and the data sequences of different influencing factors are calculated. Based on the result of the first correlation coefficient calculation, the target influencing factor data sequence and the corresponding target lag period are determined.

[0031] The correlation coefficient is calculated for the autocorrelation function of the standard data sequence and the lagged standard data sequence. Based on the result of the second correlation coefficient calculation, the optimal lag period corresponding to the standard data sequence is determined.

[0032] Furthermore,

[0033] According to a preset ratio, the sample dataset is divided into a training set, a validation set, and a test set; each of the training set, validation set, and test set includes multiple sample data, and each sample data includes an input variable and an output variable that have a corresponding relationship.

[0034] The XGBoost model is trained using the training set to generate an initial prediction model.

[0035] Furthermore,

[0036] Set the candidate value range for hyperparameters to form a parameter grid, which includes multiple combinations of hyperparameters;

[0037] The sample dataset is divided into k subsets. One subset is selected from the k subsets as the sub-validation set, and the remaining k-1 subsets are selected as the sub-training set; where k is a natural number greater than 1.

[0038] Choose a combination of target hyperparameters, train the initial prediction model with a different sub-training set each time, and use a different sub-validation set to validate the performance of the trained initial prediction model, thus obtaining k performance metrics.

[0039] Calculate the average value of k performance indicators to determine the average performance indicator corresponding to the target hyperparameter combination;

[0040] Based on the average performance index corresponding to the combination of hyperparameters, the optimal combination of hyperparameters is determined from multiple combinations.

[0041] Furthermore,

[0042] Based on the optimal combination of hyperparameters, the initial prediction model is trained using the training set to generate the target prediction model;

[0043] The target prediction model is tested using a validation set and a test set. If the target prediction model passes the performance test, it is determined as the final prediction model and used to predict natural gas prices.

[0044] Secondly, based on the same inventive concept, the present disclosure also provides a natural gas price prediction system based on XGBoost, the system including a data processing module, a feature processing module, a first training module, a hyperparameter processing module, a second training module and a prediction module;

[0045] The data processing module is used to acquire natural gas price-related data and multiple influencing factor data sequences through the data terminal, preprocess the natural gas price-related data, and generate standard data and standard data sequences.

[0046] The feature processing module is used to calculate the cross-correlation function between the standard data sequence and multiple influencing factor data sequences, calculate the autocorrelation function between the standard data sequence and the lagged standard data sequence, determine the correlation between the autocorrelation function and multiple cross-correlation functions, and determine the target influencing factor data sequence and the corresponding target lag period, as well as the optimal lag period corresponding to the standard data sequence.

[0047] The first training module is used to construct a sample dataset with standard data sequences and their corresponding optimal lag periods, target influencing factor data sequences and their corresponding target lag periods as input variables, and standard data as output variables. The sample dataset is then used to train the XGBoost model and generate an initial prediction model.

[0048] The hyperparameter processing module is used to set the candidate value range of hyperparameters, form a parameter grid, and determine the optimal combination of hyperparameters for the initial prediction model based on the parameter grid and the sample dataset.

[0049] The second training module is used to train the initial prediction model using the sample dataset based on the optimal hyperparameter combination, and generate the final prediction model.

[0050] The forecasting module is used to acquire real-time data, use the final forecasting model to predict the price of natural gas, and feed the final forecast results back to the data terminal.

[0051] Furthermore,

[0052] The data processing module includes a data acquisition unit, a data identification unit, an anomaly identification unit, an anomaly processing unit, and a data conversion unit;

[0053] The data acquisition unit is used to acquire price-related data tables and influencing factor data sequences through a data terminal.

[0054] The data recognition unit is used to recognize characters in the price-related data table, convert the characters into floating-point numbers, generate price-related data, handle missing data values ​​in the price-related data, and generate a given dataset based on the price-related data after handling missing data values.

[0055] The outlier identification unit is used to identify and locate outliers in a given dataset, and to determine outliers that are significantly different from other data points in the given dataset.

[0056] The outlier processing unit is used to process outliers in a given dataset and generate the original data based on the given dataset after outlier processing.

[0057] The data transformation unit is used to convert the original data into a standard normal distribution with a mean of 0 and a standard deviation of 1, generating standard data and standard data sequences.

[0058] Furthermore,

[0059] The feature processing module includes a cross-correlation function generation unit, an autocorrelation function generation unit, and a correlation coefficient calculation unit;

[0060] The cross-correlation function generation unit is used to calculate the cross-correlation function between the standard data sequence and multiple influencing factor data sequences, respectively.

[0061] The autocorrelation function generation unit is used to calculate the autocorrelation function between the standard data sequence and the lagged standard data sequence;

[0062] The correlation coefficient calculation unit is used to calculate the correlation coefficient of multiple cross-correlation functions between the standard data sequence and data sequences of different influencing factors. Based on the first correlation coefficient calculation result, the target influencing factor data sequence and the corresponding target lag period are determined. The unit also calculates the correlation coefficient of the autocorrelation function between the standard data sequence and the lagged standard data sequence. Based on the second correlation coefficient calculation result, the optimal lag period corresponding to the standard data sequence is determined.

[0063] Furthermore,

[0064] The hyperparameter processing module includes a parameter grid generation unit, a subset generation unit, a performance index verification unit, an average performance index calculation unit, and a hyperparameter selection unit.

[0065] The parameter mesh generation unit is used to set the candidate value range of hyperparameters to form a parameter mesh, which includes multiple hyperparameter combinations.

[0066] The subset generation unit is used to divide the sample dataset into k subsets, select one subset from the k subsets as the sub-validation set, and use the remaining k-1 subsets as the sub-training set; where k is a natural number greater than 1.

[0067] The performance metric verification unit is used to select the target hyperparameter combination. Each time, a different sub-training set is used to train the initial prediction model, and a different sub-validation set is used to verify the performance metrics of the trained initial prediction model, resulting in k performance metrics.

[0068] The average performance index calculation unit is used to calculate the average value of k performance indices and determine the average performance index corresponding to the target hyperparameter combination.

[0069] The hyperparameter selection unit is used to determine the optimal hyperparameter combination from multiple hyperparameter combinations based on the average performance index corresponding to the hyperparameter combination.

[0070] Thirdly, based on the same inventive concept, the present disclosure also provides a computer-readable storage medium storing one or more programs, which, when executed, can implement the aforementioned XGBoost-based natural gas price prediction method.

[0071] Fourthly, based on the same inventive concept, embodiments of this disclosure also provide an electronic device, including a processor, a communication interface, the aforementioned computer-readable storage medium, and a communication bus. The processor, communication interface, and computer-readable storage medium communicate with each other via the communication bus. The processor is used to execute a program stored in the aforementioned computer-readable storage medium.

[0072] Compared with the prior art, this disclosure has the following advantages:

[0073] When constructing the final prediction model for natural gas prices, the lag effect of influencing factors on natural gas prices and the lag effect of natural gas prices themselves were considered, which improved the accuracy of the final prediction model in predicting natural gas prices.

[0074] Other features and advantages of this disclosure will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the disclosure. The objects and other advantages of this disclosure may be realized and obtained by means of the structures pointed out in the description, claims and drawings. Attached Figure Description

[0075] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0076] Figure 1 A flowchart of a natural gas price prediction method based on XGBoost is provided for embodiments of this disclosure;

[0077] Figure 2 A bar chart showing the correlation coefficients of an autocorrelation function with different lag periods, provided in an embodiment of this disclosure;

[0078] Figure 3 A coordinate graph comparing the predicted and actual values ​​of the first reference model provided in this embodiment of the disclosure;

[0079] Figure 4 A coordinate graph comparing the predicted and actual values ​​of the second reference model provided in this embodiment of the disclosure;

[0080] Figure 5 A coordinate graph comparing the predicted and actual values ​​of the third reference model provided in this embodiment of the disclosure;

[0081] Figure 6 A coordinate graph comparing the predicted and actual values ​​of the final prediction model provided in this embodiment of the disclosure;

[0082] Figure 7 A block diagram of a natural gas price prediction system based on XGBoost is provided for embodiments of this disclosure;

[0083] Figure 8 This is a schematic diagram of an electronic device structure provided in an embodiment of the present disclosure. Detailed Implementation

[0084] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0085] Firstly, Figure 1 A flowchart of a natural gas price prediction method based on XGBoost, as provided in this disclosure embodiment, is shown below. Figure 1As shown, this disclosure provides a natural gas price prediction method based on XGBoost, including:

[0086] S1: Obtain natural gas price-related data and multiple influencing factor data sequences through the data terminal, preprocess the natural gas price-related data, and generate standard data and standard data sequences.

[0087] Specifically, price-related data includes the JKM index, which is an important indicator for assessing liquefied natural gas spot prices. Influencing factors include geographical environment, time, and climate. Preprocessing of natural gas price-related data includes basic data processing and feature transformation.

[0088] S2: Calculate the cross-correlation function between the standard data sequence and the multiple influencing factor data sequences, calculate the autocorrelation function between the standard data sequence and the lagged standard data sequence, determine the correlation between the autocorrelation function and the multiple cross-correlation functions, and determine the target influencing factor data sequence and the corresponding target lag period, as well as the optimal lag period corresponding to the standard data sequence.

[0089] Specifically, the cross-correlation function between the standard data sequence and the influencing factor data sequence, and the autocorrelation function between the standard data sequence and the lagged standard data sequence are calculated. The correlation coefficients of the cross-correlation function and the autocorrelation function are calculated. Based on the correlation coefficient calculation results, the target influencing factor data sequence and the corresponding target lag period, as well as the optimal lag period corresponding to the standard data sequence, are determined. This enables feature selection of a large amount of price-related data and multi-type influencing factor data.

[0090] S3: Using the standard data sequence and its corresponding optimal lag period, the target influencing factor data sequence and its corresponding target lag period as input variables, and the standard data as the output variable, construct a sample dataset, use the sample dataset to train the XGBoost model, and generate an initial prediction model.

[0091] S4: Set the candidate value range of hyperparameters to form a parameter grid. Based on the parameter grid and the sample dataset, determine the optimal combination of hyperparameters for the initial prediction model.

[0092] Specifically, since this disclosure uses the XGBoost algorithm to generate an initial prediction model, and the XGBoost model contains a large number of hyperparameters, such as the number of trees, learning factor, and regularization parameter, it is necessary to find the optimal hyperparameter combination that can improve the model's generalization ability through optimization. First, the candidate value range of the hyperparameters is determined to form a parameter grid. Based on the parameter grid and the sample dataset, the optimal hyperparameter combination of the initial prediction model is determined. Second, considering that the amount of sample data processed by the initial prediction model is relatively small, dividing the training set, validation set, and test set in a single training session may lead to unstable evaluation results. Therefore, the K-fold cross-validation method is used to improve the robustness of model performance evaluation and reduce the risk of overfitting.

[0093] S5: Based on the optimal combination of hyperparameters, train the initial prediction model using the sample dataset to generate the final prediction model.

[0094] S6: Acquire real-time data, use the final prediction model to predict the price of natural gas, and feed the final prediction results back to the data terminal.

[0095] In this embodiment, the varying degrees of influence of different types of influencing factors on natural gas prices are considered, along with the lag effect of these factors on natural gas prices and the inherent lag effect of natural gas prices themselves. Before model training, the cross-correlation function between the standard data sequence and multiple influencing factor data sequences is calculated, as well as the autocorrelation function between the standard data sequence and the lagged standard data sequence. Based on the correlation between the autocorrelation function and the multiple cross-correlation functions, the target influencing factor data sequence and its corresponding target lag period, and the optimal lag period corresponding to the standard data sequence are determined. A sample dataset is constructed using the standard data sequence and its corresponding optimal lag period, and the target influencing factor data sequence and its corresponding target lag period as input variables, and the standard data as the output variable. Based on this sample dataset, the final prediction model is trained and generated. The final prediction model considers the lag effect of the influencing factors on natural gas prices and the inherent lag effect of natural gas prices themselves, thus improving the accuracy of natural gas price prediction.

[0096] In some examples, natural gas price-related data and multiple influencing factor data sequences are acquired via a data terminal. The natural gas price-related data is then preprocessed to generate standard data and standard data sequences, including:

[0097] S11: Obtain price-related data tables and influencing factor data sequences through a data terminal.

[0098] S12: Identify characters in the price-related data table, convert the characters into floating-point numbers, generate price-related data, handle missing data values ​​in the price-related data, and generate the given dataset based on the price-related data after handling missing data values.

[0099] S13: Identify and locate data in a given dataset, and determine outliers that are significantly different from other data points in the given dataset.

[0100] Specifically, outliers are abnormal observations that deviate significantly from the characteristics, distribution, or behavior of other data points. The 3sigma detection method can be used to identify and locate data within a given dataset. This method divides the data distribution range into six standard deviations (sigma) intervals centered on the mean. The ±3sigma range contains 99.73% of the data. By monitoring whether the data exceeds these three standard deviations, it can be determined whether the process is under control or whether an anomaly exists.

[0101] S14: Process outliers in the given dataset and generate the original data based on the processed dataset.

[0102] S15: Convert the original data into a standard normal distribution with a mean of 0 and a standard deviation of 1, generating standard data and a standard data sequence.

[0103] Specifically, after generating the raw data, feature transformations are performed to simplify the data size, extract useful information, reduce redundancy and noise, improve data distribution and separability, facilitate subsequent correlation analysis, and ensure the accuracy and comparability of the analysis results. The standard deviation standardization method is used to transform the raw data into a standard normal distribution with a mean of 0 and a standard deviation of 1, generating standard data and standard data sequences. The standard deviation standardization method is a standardization technique applied to data processing and analysis.

[0104] In some examples, the cross-correlation function between the standard data series and the influencing factor data series is expressed as:

[0105]

[0106] Wherein, formula (1) is the continuous form of the cross-correlation function between the standard data sequence and the influencing factor data sequence, and formula (2) is the discrete form of the cross-correlation function between the standard data sequence and the influencing factor data sequence; f(t) represents the standard data sequence, g(t) represents the influencing factor data sequence, g(t+τ) represents the influencing factor data sequence with a time lag of τ, t represents the integral variable of time, and τ represents the time difference between the two sequences.

[0107] In some examples, the autocorrelation function of the standard data sequence and the lagged standard data sequence is expressed as:

[0108]

[0109] Wherein, formula (3) is the continuous form of the autocorrelation function of the standard data sequence and the lagged standard data sequence, and formula (4) is the discrete form of the autocorrelation function of the standard data sequence and the lagged standard data sequence; f(t+τ) represents the standard data sequence with a lagged time difference τ, t represents the integral variable of time, and τ represents the time difference between the two sequences.

[0110] In some examples, the correlation between the autocorrelation function and multiple cross-correlation functions is determined to identify the target influencing factor data sequence and its corresponding target lag period, as well as the optimal lag period corresponding to the standard data sequence. Specifically, this includes:

[0111] S21: Calculate the correlation coefficients of multiple cross-correlation functions between the standard data sequence and the data sequences of different influencing factors. Based on the result of the first correlation coefficient calculation, determine the target influencing factor data sequence and the corresponding target lag period.

[0112] Specifically, the data sequences of influencing factors with the highest correlation coefficients from the first correlation coefficient calculation results are selected as the target influencing factor data sequences; alternatively, a correlation coefficient threshold is set, and data sequences with correlation coefficients exceeding the threshold are considered to have high correlation and are thus identified as target influencing factor data sequences. The target lag period corresponding to the target influencing factor data sequence can be determined using the PEARSON correlation coefficient method based on the cross-correlation function between the standard data sequence and the influencing factor data sequences; alternatively, the target lag period corresponding to the target influencing factor data sequence can be determined based on the calculation results of the cross-correlation function between the standard data sequence and the target influencing factor data sequences.

[0113] S22: Calculate the correlation coefficient of the autocorrelation function of the standard data sequence and the lagged standard data sequence, and determine the optimal lag period corresponding to the standard data sequence based on the result of the second correlation coefficient calculation.

[0114] Specifically, the correlation coefficient can be calculated using the PEARSON correlation coefficient method based on the autocorrelation function of the standard data sequence and the lagged standard data sequence. The optimal lag period corresponding to the standard data sequence can be determined based on the result of the second correlation coefficient calculation. Alternatively, the optimal lag period corresponding to the standard data sequence can be determined based on the calculation result of the autocorrelation function of the standard data sequence and the lagged standard data sequence.

[0115] In some examples, the XGBoost model is trained using a sample dataset to generate an initial prediction model, including:

[0116] S31: Divide the sample dataset into a training set, a validation set, and a test set according to a preset ratio;

[0117] Specifically, the training set, validation set, and test set each include multiple sample data. Each sample data includes an input variable and an output variable that have a corresponding relationship.

[0118] S32: Train the XGBoost model using the training set to generate an initial prediction model.

[0119] In some examples, a candidate range of hyperparameter values ​​is set to form a parameter grid. Based on the parameter grid and the sample dataset, the optimal combination of hyperparameters for the initial prediction model is determined, specifically including:

[0120] S41: Set the candidate value range of hyperparameters to form a parameter grid, which includes multiple hyperparameter combinations.

[0121] S42: Divide the sample dataset into k subsets, select one subset from the k subsets as the sub-validation set, and use the remaining k-1 subsets as the sub-training set; where k is a natural number greater than 1.

[0122] S43: Select the target hyperparameter combination, train the initial prediction model using a different sub-training set each time, and verify the performance of the trained initial prediction model using different sub-validation sets to obtain k performance metrics.

[0123] S44: Calculate the average value of k performance indicators to determine the average performance indicator corresponding to the target hyperparameter combination.

[0124] S45: Based on the average performance index corresponding to the combination of hyperparameters, determine the optimal combination of hyperparameters from multiple combinations of hyperparameters.

[0125] Specifically, from all hyperparameter combinations, the combination with the best average performance index or the highest average performance index data is selected as the optimal hyperparameter combination.

[0126] It should be noted that the sub-training set and sub-validation set are not the same as the training set and validation set. The sub-training set and sub-validation set are determined from the sample dataset by dividing it into equal and random subsets, while the training set and validation set are determined from the sample dataset according to a preset ratio.

[0127] In some examples, an initial prediction model is trained using a sample dataset based on the optimal combination of hyperparameters to generate the final prediction model, specifically including:

[0128] S51: Based on the optimal combination of hyperparameters, the initial prediction model is trained using the training set to generate the target prediction model;

[0129] S52: Use the validation set and test set to test the performance of the target prediction model. If the target prediction model passes the performance test, it is determined as the final prediction model and used to predict natural gas prices.

[0130] Specifically, the performance test includes the target prediction model obtaining prediction data based on sample data from the validation set and the test set, comparing the prediction data with the actual data, and calculating the mean squared error, mean absolute error, and mean absolute percentage error between the prediction data and the actual data. If the mean squared error, mean absolute error, and mean absolute percentage error are less than the preset threshold, the target prediction model passes the performance test.

[0131] Example 1:

[0132] Natural gas price-related data and multiple influencing factor data sequences are obtained through data terminals. Price-related data may include the JKM index, while influencing factors include geographical, temporal, and climatic factors. Different types of influencing factors have varying degrees of impact on natural gas prices. Some influencing factors have a lag effect on natural gas prices; when an influencing factor exists, it does not immediately affect natural gas prices but rather after a certain period. Furthermore, different influencing factors have different lag periods. Therefore, when forecasting natural gas prices, it is necessary to consider different influencing factors and their corresponding lag periods to improve forecast accuracy.

[0133] Acquire price-related data tables and influencing factor data sequences through a data terminal. Identify characters in the price-related data tables, convert them to floating-point numbers, generate price-related data, handle missing values ​​in the price-related data, and generate a given dataset based on the price-related data after missing value handling.

[0134] The 3sigma detection method is used to identify and locate outliers in a given dataset, distinguishing them significantly from other data points. These outliers are then processed, and the original dataset is generated based on the processed dataset. Outliers are abnormal observations that deviate significantly from the characteristics, distribution, or behavior of other data points. The 3sigma detection method divides the data distribution range into six standard deviations (sigma) intervals centered on the mean. The ±3 sigma range encompasses 99.73% of the data. By monitoring whether the data exceeds these three standard deviations, it is determined whether the process is under control or whether an anomaly exists.

[0135] The original data undergoes feature transformation, using standard deviation standardization to convert it into a standard normal distribution with a mean of 0 and a standard deviation of 1, generating a standard data sequence. After generating the original data, feature transformation is applied to simplify the data size, extract useful information, reduce redundancy and noise, improve data distribution and separability, facilitate subsequent correlation analysis, and ensure the accuracy and comparability of the analysis results.

[0136] It is important to understand that the data sequence of influencing factors obtained through the data terminal can be a pre-processed data sequence or an unprocessed data sequence. If the obtained data sequence of influencing factors is an unprocessed data sequence, it is necessary to perform preprocessing such as correcting missing values, removing outliers, and feature transformation on the data sequence of influencing factors.

[0137] After obtaining the standard data and standard data sequences, as well as the influencing factor data sequences, feature selection is required. Feature selection refers to choosing the most representative and relevant feature data or dataset sequences from the data or data sequences to reduce data dimensionality, reduce redundant information and noise, and improve the model's generalization ability. The goal is to retain the most relevant data or data sequences while eliminating irrelevant or redundant features. The cross-correlation function between the standard data sequences and the influencing factor data sequences, and the autocorrelation function between the standard data sequences and lagged standard data sequences are calculated. The correlation coefficients of the cross-correlation and autocorrelation functions are then calculated. Based on the correlation coefficient calculation results, the target influencing factor data sequences and their corresponding target lag periods, as well as the optimal lag periods corresponding to the standard data sequences, are determined. This enables feature selection for a large amount of price-related data and multiple types of influencing factor data.

[0138] Calculate the cross-correlation function between the standard data series and the influencing factor data series. The cross-correlation function is a measure of the similarity between two series. It is usually used to find characteristics in the unknown series by comparing it with a known series. It is a function of time, reflecting the degree of matching between the two series at corresponding positions after time shift. The cross-correlation function between the standard data series and the influencing factor data series is expressed as:

[0139]

[0140] Wherein, formula (1) is the continuous form of the cross-correlation function between the standard data sequence and the influencing factor data sequence, and formula (2) is the discrete form of the cross-correlation function between the standard data sequence and the influencing factor data sequence; f(t) represents the standard data sequence, g(t) represents the influencing factor data sequence, g(t+τ) represents the influencing factor data sequence with a time lag of τ, t represents the integral variable of time, and τ represents the time difference between the two sequences.

[0141] Because the data includes multiple influencing factor data sequences, it is necessary to calculate the cross-correlation functions between multiple standard data sequences and the influencing factor data sequences separately. Furthermore, by calculating the cross-correlation functions, the target lag period corresponding to each influencing factor data sequence is determined. The target lag period corresponding to the influencing factor data sequence represents the lag period in which the influencing factor has the greatest impact on natural gas prices and the highest correlation. Influencing factors include geographical environmental factors, temporal factors, and climatic factors. Geographical environmental factors include factors such as the extraction volume, production volume, supply and demand relationship, and monthly average reserves of natural gas in different regions. Temporal factors include factors such as extraction cycles and production cycles. Climatic factors include factors such as season, temperature, and weather.

[0142] The autocorrelation function of the standard data sequence and its lagged counterpart is calculated. When the two input sequences of the cross-correlation function are identical, it becomes the autocorrelation function. The autocorrelation function of the standard data sequence and its lagged counterpart is expressed as:

[0143]

[0144] Wherein, formula (3) is the continuous form of the autocorrelation function of the standard data sequence and the lagged standard data sequence, and formula (4) is the discrete form of the autocorrelation function of the standard data sequence and the lagged standard data sequence; f(t+τ) represents the standard data sequence with a lagged time difference τ, t represents the integral variable of time, and τ represents the time difference between the two sequences.

[0145] The cross-correlation function and the autocorrelation function are essentially two functions performing an inner product operation, that is, a continuous form of the inner product of vectors. From the perspective of linear space, their significance is: the projection of one vector onto another vector. The larger the inner product result, the larger the projection, the smaller the angle between the two vectors, the more consistent their directions, and the higher the similarity.

[0146] After calculating multiple cross-correlation functions and autocorrelation functions, it is necessary to calculate the correlation coefficients of these functions to complete feature selection.

[0147] Based on multiple cross-correlation functions of standard data sequences and data sequences of different influencing factors, the PEARSON correlation coefficient method is used to calculate the correlation coefficient. Based on the result of the first correlation coefficient calculation, the target influencing factor data sequence is determined. A correlation coefficient threshold can be set. If the correlation coefficient exceeds the correlation coefficient threshold, it is confirmed as having a high correlation and is determined as the target influencing factor data sequence.

[0148] Based on the cross-correlation function between the standard data sequence and the influencing factor data sequence, the target lag period corresponding to the target influencing factor data sequence is determined using the PEARSON correlation coefficient method; or, the target lag period corresponding to the target influencing factor data sequence is determined based on the calculation result of the cross-correlation function between the standard data sequence and the target influencing factor data sequence; a correlation coefficient threshold can be set, and if the correlation coefficient exceeds the correlation coefficient threshold, it is confirmed as a high correlation and determined as the target lag period.

[0149] Figure 2 A bar chart showing the correlation coefficients corresponding to different lag periods of an autocorrelation function provided in this embodiment of the disclosure, such as... Figure 2 As shown, based on the autocorrelation function of the standard data sequence and the lagged standard data sequence, the PEARSON correlation coefficient method is used to calculate the correlation coefficient. The optimal lag period corresponding to the standard data sequence is determined based on the second correlation coefficient calculation result; or, the optimal lag period corresponding to the standard data sequence is determined based on the calculation result of the autocorrelation function of the standard data sequence and the lagged standard data sequence. A correlation coefficient threshold can be set; if the correlation coefficient exceeds the threshold, it is considered to have a high correlation and is identified as the target influencing factor data sequence.

[0150] In this embodiment, the PEARSON correlation coefficient method is used to calculate the correlation coefficients of the cross-correlation function and the autocorrelation function. Based on the values ​​of the PEARSON correlation coefficient, the cross-correlation function and the autocorrelation function with high correlation are determined, thereby determining the corresponding influencing factor data sequence and lag period. The PEARSON correlation coefficient measures the degree of linear correlation between two variables, and its value ranges from -1 to 1. A value close to 1 indicates a positive correlation, a value close to -1 indicates a negative correlation, and values ​​close to -1 or 1 indicate a relatively high correlation.

[0151] After determining the target influencing factor data sequence and its corresponding target lag period, and the optimal lag period corresponding to the standard data sequence, the XGBoost model is trained using the standard data sequence and its corresponding optimal lag period, the target influencing factor data sequence and its corresponding target lag period, and the standard data.

[0152] In the actual training process, the sample dataset needs to be divided into training set, validation set and test set according to a preset ratio.

[0153] In this embodiment, the preset ratio of the training set, validation set, and test set is 8:1:1. The training set, validation set, and test set include multiple sample data sets formed based on standard data sequences and their corresponding optimal lag periods, target influencing factor data sequences and their corresponding target lag periods, and standard data. The standard data sequences and their corresponding optimal lag periods, and the target influencing factor data sequences and their corresponding target lag periods are used as input variables, and the standard data is used as the output variable. There is a corresponding relationship between the input and output variables in a single sample data set. The XGBoost model is trained using the training set to generate an initial prediction model.

[0154] In this embodiment, the XGBoost model is selected as the basis for predicting natural gas prices. The XGBoost model is an improvement on the boosting tree algorithm based on the classification regression tree algorithm. Before training the XGBoost model, it needs to be initialized. The original XGBoost model is represented as follows:

[0155]

[0156] in, f represents the predicted value of the i-th sample data, k represents the number of trees, and f k Let x represent a function related to the structure of the tree and the weights of its leaves, where Z is the function space. i Let x be the i-th input sample data. i Determined by inputting variables;

[0157] Using multiple trees for collaborative decision-making, and through continuous iteration, new regression trees are built by reducing the objective function value. This optimizes model performance, avoids overfitting, and helps find the optimal prediction solution. The objective function value is expressed as:

[0158]

[0159] Among them, D (t) This represents the objective function value in the t-th iteration. Here, y is the loss function, and η is the learning factor used to mitigate the effect of newly added trees; i This represents the true label of the i-th sample, which is the true natural gas price confirmed by the standard data corresponding to the output variable; f represents the predicted value of the i-th sample after the (t-1)-th iteration; t (x i ) represents the prediction value of the t-th tree for the i-th sample; γ is the regularization factor to prevent overfitting; γ and λ are regularization parameters, T represents the number of leaves, and w j This represents the weight of the j-th leaf node.

[0160] The objective loss function is simplified by performing a second-order Taylor expansion and removing constant terms.

[0161] After performing a second-order Taylor expansion on the target loss function, we obtain formula (7):

[0162]

[0163] Among them, f t Let g represent the t-th tree. i h i These are the first and second derivatives of the loss function, respectively.

[0164] Removing the constant term from the objective loss function simplifies the objective function, resulting in formula (8):

[0165]

[0166] Among them, f j Let j be the j-th tree.

[0167] The optimal leaf node weight is calculated using the following formula:

[0168]

[0169] Among them, I j This represents the set of indices of all samples that are assigned to the j-th leaf node.

[0170] The optimal objective function is determined according to formula (9), and is expressed as:

[0171]

[0172] Adjusting the hyperparameters in the XGBoost model can improve its prediction accuracy and prevent overfitting by optimizing the model and its objective function. Hyperparameters in the XGBoost model include the number of trees (k), the learning factor (η), and the regularization parameter.

[0173] Using standard data sequences and their corresponding optimal lag periods, target influencing factor data sequences and their corresponding target lag periods as input variables, and standard data as output variables, a sample dataset is constructed. The XGBoost model is then trained using the sample dataset to generate an initial prediction model.

[0174] Define the candidate value range for hyperparameters to form a parameter grid, which includes multiple hyperparameter combinations. Divide the sample dataset into five subsets, selecting one subset as the sub-validation set and the remaining four subsets as the sub-training sets. Select the target hyperparameter combination, and train the initial prediction model using a different sub-training set each time. Validate the trained initial prediction model using different sub-validation sets, obtaining five performance metrics. Calculate the average of the five performance metrics to determine the average performance metric corresponding to the target hyperparameter combination. Based on the average performance metrics of all hyperparameter combinations, select the hyperparameter combination with the best average performance metric or the highest average performance metric value; this is determined as the optimal hyperparameter combination.

[0175] In this embodiment, K-fold cross-validation is used to determine the optimal combination of hyperparameters, thereby improving the robustness of model performance evaluation and reducing the risk of overfitting. Preferably, 5-fold cross-validation is used, i.e., k is set to 5. K-fold cross-validation can be automated by calling the GridSearchCV search method through an external interface; the GridSearchCV search method is a utility tool used to perform a detailed parameter search on a specified parameter grid.

[0176] It should be noted that the sub-training set and sub-validation set are not the same as the training set and validation set. The sub-training set and sub-validation set are determined from the sample dataset by dividing it into equal and random subsets, while the training set and validation set are determined from the sample dataset according to a preset ratio.

[0177] Based on the optimal hyperparameter combination, the initial prediction model is trained using the training set to generate the target prediction model. The target prediction model is then tested using a validation set and a test set. If the target prediction model passes the performance test, it is determined as the final prediction model and used to predict natural gas prices. The performance test includes the target prediction model acquiring prediction data based on sample data from the validation and test sets, comparing the predicted data with actual data, and calculating the mean squared error, mean absolute error, and mean absolute percentage error between the predicted and actual data. If these errors are less than preset thresholds, the target prediction model passes the performance test.

[0178] When using the final prediction model to forecast natural gas prices, real-time data is acquired, the final prediction model is used to predict natural gas prices, and the final prediction result is fed back to the data terminal. The prediction result output by the final prediction model is standardized data; therefore, the prediction result needs to be de-standardized to generate a final prediction result that includes specific price-related data, and this final prediction result is then fed back to the data terminal.

[0179] Example 2:

[0180] Based on the standard data sequence and corresponding optimal lag period, target influencing factor data sequence and corresponding target lag period, and standard data determined in Example 1, the prediction errors of the final prediction model and the reference model are compared; thus, the prediction accuracy of the final prediction model is verified by comparison. The standard data sequence and standard data are the data and data sequence determined in Example 1 by preprocessing the natural gas price-related data, and are associated with the natural gas price.

[0181] The reference models include a first reference model, a second reference model, and a third reference model. During training, the first reference model uses only the standard data sequence as input variables and the standard data as output variables; therefore, it does not consider the lag effect of natural gas prices themselves or the lag effect of influencing factors. The second reference model uses the standard data sequence and the corresponding optimal lag period as input variables and the standard data as output variables; therefore, it only considers the lag effect of natural gas prices themselves. The third reference model uses the standard data sequence, the influencing factor data sequence, and the corresponding target lag period as input variables and the standard data as output variables; therefore, it only considers the lag effect of influencing factors. During the training of the first, second, and third reference models, the proportions of the training, validation, and test sets in the sample dataset remain unchanged; only the input vector in the training set is changed. Furthermore, throughout the entire training process of the first, second, and third reference models, only the input vector in the training set differs; all other training processes remain consistent with the final prediction model.

[0182] After training the first reference model, the second reference model, and the third reference model, the prediction errors of the first reference model, the second reference model, the third reference model, and the final prediction model are compared using the validation set and the test set.

[0183] Figure 3 A coordinate graph comparing the predicted and actual values ​​of the first reference model provided in this embodiment of the disclosure, such as... Figure 3 As shown, Figure 3The horizontal axis represents the sample index, with each index corresponding to a sample data point in the test or validation set. The vertical axis, JKM, represents the JKM index, a crucial indicator for assessing liquefied natural gas (LNG) spot prices. Here, it serves as price-related data for natural gas. The yellow dashed line represents the predicted JKM index value determined by the first reference model after inverse standardization of the prediction results, while the blue solid line represents the actual JKM index value. The validation set is typically used during the training phase to verify the model's training effectiveness and optimize hyperparameters. The test set is used to test the prediction performance. Therefore, the sample data in the test set is primarily used to determine the mean squared error, mean absolute error, and mean absolute percentage error (MAE) of the predicted and actual values ​​corresponding to the first reference model. The first reference model has a mean squared error of 33.5056, a mean absolute error of 3.3588, and a MAE of 25.65%.

[0184] Figure 4 A coordinate graph comparing the predicted and actual values ​​of the second reference model provided in this embodiment of the disclosure, such as... Figure 4 As shown, Figure 4 The horizontal axis represents the sample index, with each sample index corresponding to a sample data point in the test or validation set. The vertical axis, JKM, represents the JKM index. The yellow dashed line represents the predicted value of the JKM index determined by the second reference model after inverse standardization of the prediction results, and the blue solid line represents the actual value of the JKM index. The mean squared error, mean absolute error, and mean absolute percentage error of the predicted and actual values ​​corresponding to the second reference model are mainly determined using sample data from the test set. The mean squared error of the second reference model is 31.4252, the mean absolute error is 2.7707, and the mean absolute percentage error is 23.48%.

[0185] Figure 5 A coordinate graph comparing the predicted and actual values ​​of the third reference model provided in this embodiment of the disclosure, such as... Figure 5 As shown, Figure 5 The horizontal axis represents the sample index, with each sample index corresponding to a sample data point in the test or validation set. The vertical axis, JKM, represents the JKM index. The yellow dashed line represents the predicted value of the JKM index determined by the third reference model after inverse standardization of the prediction results, and the blue solid line represents the actual value of the JKM index. The mean squared error, mean absolute error, and mean absolute percentage error of the predicted and actual values ​​corresponding to the third reference model are mainly determined using sample data from the test set. The mean squared error of the third reference model is 15.2720, the mean absolute error is 1.8229, and the mean absolute percentage error is 19.07%.

[0186] Figure 6 A coordinate graph comparing the predicted and actual values ​​of the final prediction model provided in this embodiment of the disclosure, such as... Figure 6 As shown, Figure 6The horizontal axis represents the sample index, with each sample index corresponding to a sample data point in the test or validation set. The vertical axis, JKM, represents the JKM index. The yellow dashed line represents the predicted value of the JKM index determined after the final prediction model performs inverse standardization on the prediction results, and the blue solid line represents the actual value of the JKM index. The mean squared error, mean absolute error, and mean absolute percentage error (MAE) of the predicted and actual values ​​corresponding to the final prediction model are mainly determined using the sample data in the test set. The final prediction model has a mean squared error of 14.2757, a mean absolute error of 1.6275, and a MAE of 15.42%.

[0187] Table 1 shows a comparison of prediction errors. As shown in Table 1, during the testing of the test set, the final prediction model exhibited significantly lower mean square error, mean absolute error, and mean absolute percentage error compared to the other three reference errors. Therefore, considering the lag effect of natural gas prices themselves and the lag effect of influencing factors, the final prediction model trained can improve the accuracy of natural gas price predictions.

[0188] Mean square error Mean Absolute Error Mean absolute percentage error First Reference Model 33.5056 3.3588 25.65% Second Reference Model 31.4252 2.7707 23.48% Third Reference Model 15.2720 1.8229 19.07% Final prediction model 14.2757 1.6275 15.42%

[0189] Table 1

[0190] Secondly, based on the same inventive concept... Figure 7 A block diagram of a natural gas price prediction system based on XGBoost is provided for embodiments of this disclosure, as follows: Figure 7 As shown, this disclosure also provides a natural gas price prediction system based on XGBoost, the system including a data processing module, a feature processing module, a first training module, a hyperparameter processing module, a second training module, and a prediction module;

[0191] The data processing module is used to acquire natural gas price-related data and multiple influencing factor data sequences through the data terminal, preprocess the natural gas price-related data, and generate standard data and standard data sequences.

[0192] The feature processing module is used to calculate the cross-correlation function between the standard data sequence and multiple influencing factor data sequences, calculate the autocorrelation function between the standard data sequence and the lagged standard data sequence, determine the correlation between the autocorrelation function and multiple cross-correlation functions, and determine the target influencing factor data sequence and the corresponding target lag period, as well as the optimal lag period corresponding to the standard data sequence.

[0193] The first training module is used to construct a sample dataset with standard data sequences and their corresponding optimal lag periods, target influencing factor data sequences and their corresponding target lag periods as input variables, and standard data as output variables. The sample dataset is then used to train the XGBoost model and generate an initial prediction model.

[0194] The hyperparameter processing module is used to set the candidate value range of hyperparameters, form a parameter grid, and determine the optimal combination of hyperparameters for the initial prediction model based on the parameter grid and the sample dataset.

[0195] The second training module is used to train the initial prediction model using the sample dataset based on the optimal hyperparameter combination, and generate the final prediction model.

[0196] The forecasting module is used to acquire real-time data, use the final forecasting model to predict the price of natural gas, and feed the final forecast results back to the data terminal.

[0197] In some examples, the data processing module includes a data acquisition unit, a data identification unit, an anomaly identification unit, an anomaly handling unit, and a data transformation unit;

[0198] The data acquisition unit is used to acquire price-related data tables and influencing factor data sequences through the data terminal;

[0199] The data recognition unit is used to recognize characters in the price-related data table, convert the characters into floating-point numbers, generate price-related data, handle missing data values ​​in the price-related data, and generate a given dataset based on the price-related data after handling missing data values.

[0200] The outlier identification unit is used to identify and locate outliers in a given dataset, and to determine outliers that are significantly different from other data points in the given dataset.

[0201] The outlier processing unit is used to process outliers in a given dataset and generate the original data based on the given dataset after outlier processing.

[0202] The data transformation unit is used to convert the original data into a standard normal distribution with a mean of 0 and a standard deviation of 1, generating standard data and standard data sequences.

[0203] In some examples, the feature processing module includes a cross-correlation function generation unit, an autocorrelation function generation unit, and a correlation coefficient calculation unit;

[0204] The cross-correlation function generation unit is used to calculate the cross-correlation function between the standard data sequence and multiple influencing factor data sequences, respectively;

[0205] The autocorrelation function generation unit is used to calculate the autocorrelation function between the standard data sequence and the lagged standard data sequence;

[0206] The correlation coefficient calculation unit is used to calculate the correlation coefficient of multiple cross-correlation functions between the standard data sequence and the data sequences of different influencing factors. Based on the first correlation coefficient calculation result, the target influencing factor data sequence and the corresponding target lag period are determined. The unit also calculates the correlation coefficient of the autocorrelation function between the standard data sequence and the lagged standard data sequence. Based on the second correlation coefficient calculation result, the optimal lag period corresponding to the standard data sequence is determined.

[0207] In some examples, the hyperparameter processing module includes a parameter grid generation unit, a subset generation unit, a performance metric verification unit, an average performance metric calculation unit, and a hyperparameter selection unit;

[0208] The parameter mesh generation unit is used to set the candidate value range of hyperparameters to form a parameter mesh, which includes multiple hyperparameter combinations;

[0209] The subset generation unit is used to divide the sample dataset into k subsets, select one subset from the k subsets as the sub-validation set, and use the remaining k-1 subsets as the sub-training set; where k is a natural number greater than 1.

[0210] The performance metric verification unit is used to select the target hyperparameter combination. Each time, a different sub-training set is used to train the initial prediction model, and a different sub-validation set is used to verify the performance metrics of the trained initial prediction model, resulting in k performance metrics.

[0211] The average performance index calculation unit is used to calculate the average value of k performance indices and determine the average performance index corresponding to the target hyperparameter combination.

[0212] The hyperparameter selection unit is used to determine the optimal hyperparameter combination from multiple hyperparameter combinations based on the average performance index corresponding to the hyperparameter combination.

[0213] Thirdly, based on the same inventive concept, the present disclosure also provides a computer-readable storage medium storing one or more programs, which, when executed, can implement the aforementioned XGBoost-based natural gas price prediction method.

[0214] Fourthly, based on the same inventive concept, Figure 8 This is a schematic diagram of an electronic device structure provided in an embodiment of the present disclosure, such as... Figure 8 As shown in the illustration, this disclosure also provides an electronic device, including a processor, a communication interface, the aforementioned computer-readable storage medium, and a communication bus. The processor, communication interface, and computer-readable storage medium communicate with each other via the communication bus. The processor is used to execute a program stored in the aforementioned computer-readable storage medium.

[0215] It should be noted that the electrical connection between the above-mentioned units does not necessarily mean the connection between lines. The indirect connection method can be applied to the embodiments of this disclosure as long as it achieves the purpose of this disclosure.

[0216] Although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure.

Claims

1. A natural gas price forecasting method based on XGBoost, characterized in that, The method includes: Natural gas price-related data and multiple influencing factor data sequences are obtained through data terminals. The natural gas price-related data is preprocessed to generate standard data and standard data sequences. Calculate the cross-correlation function between the standard data sequence and multiple influencing factor data sequences, calculate the autocorrelation function between the standard data sequence and the lagged standard data sequence, determine the correlation between the autocorrelation function and multiple cross-correlation functions, and determine the target influencing factor data sequence and the corresponding target lag period, and the optimal lag period corresponding to the standard data sequence. Using the standard data sequence and its corresponding optimal lag period, the target influencing factor data sequence and its corresponding target lag period as input variables, and the standard data as output variables, a sample dataset is constructed. The XGBoost model is then trained using the sample dataset to generate an initial prediction model. Set the candidate value range of hyperparameters to form a parameter grid, and determine the optimal hyperparameter combination of the initial prediction model based on the parameter grid and the sample dataset; Based on the optimal hyperparameter combination, the initial prediction model is trained using the sample dataset to generate the final prediction model; The system acquires real-time data, uses the final prediction model to predict the price of natural gas, and feeds the final prediction results back to the data terminal.

2. The method according to claim 1, characterized in that, The process involves acquiring natural gas price-related data and multiple influencing factor data sequences via a data terminal, preprocessing the natural gas price-related data to generate standard data and standard data sequences, including: The data terminal is used to obtain price-related data tables and influencing factor data sequences. Identify characters in the price-related data table, convert the characters into floating-point numbers, generate price-related data, process the missing data in the price-related data, and generate a given dataset based on the price-related data after processing the missing data. Identify and locate data in the given dataset, and determine outliers that are significantly different from other data points in the given dataset; Process outliers in the given dataset, and generate the original data based on the given dataset after processing the outliers; The original data is converted into a standard normal distribution with a mean of 0 and a standard deviation of 1, generating the standard data and the standard data sequence.

3. The method according to claim 1, characterized in that, The cross-correlation function between the standard data sequence and the influencing factor data sequence is expressed as: Wherein, formula (1) is the continuous form of the cross-correlation function between the standard data sequence and the influencing factor data sequence, and formula (2) is the discrete form of the cross-correlation function between the standard data sequence and the influencing factor data sequence; f(t) represents the standard data sequence, g(t) represents the influencing factor data sequence, g(t+τ) represents the influencing factor data sequence with a time lag of τ, t represents the integral variable of time, and τ represents the time difference between the two sequences.

4. The method according to claim 1, characterized in that, The autocorrelation function of the standard data sequence and the lagged standard data sequence is expressed as: Wherein, formula (3) is the continuous form of the autocorrelation function of the standard data sequence and the lagged standard data sequence, and formula (4) is the discrete form of the autocorrelation function of the standard data sequence and the lagged standard data sequence; f(t+τ) represents the standard data sequence with a lagged time difference τ, t represents the integral variable of time, and τ represents the time difference between the two sequences.

5. The method according to claim 1, characterized in that, The process of determining the correlation between the autocorrelation function and multiple cross-correlation functions, and identifying the target influencing factor data sequence and its corresponding target lag period, as well as the optimal lag period corresponding to the standard data sequence, includes: The correlation coefficients are calculated for multiple cross-correlation functions of the standard data sequence and different influencing factor data sequences. Based on the first correlation coefficient calculation result, the target influencing factor data sequence and the corresponding target lag period are determined. The autocorrelation coefficient of the standard data sequence and the lagged standard data sequence is calculated, and the optimal lag period corresponding to the standard data sequence is determined based on the second correlation coefficient calculation result.

6. The method according to claim 1, characterized in that, The step of training the XGBoost model using a sample dataset to generate an initial prediction model includes: According to a preset ratio, the sample dataset is divided into a training set, a validation set, and a test set; wherein, each of the training set, validation set, and test set includes multiple sample data, and each sample data includes an input variable and an output variable that have a corresponding relationship; The XGBoost model is trained using the training set to generate the initial prediction model.

7. The method according to claim 1, characterized in that, The process of setting candidate value ranges for hyperparameters to form a parameter grid, and determining the optimal combination of hyperparameters for the initial prediction model based on the parameter grid and the sample dataset, includes: Set the candidate value range of the hyperparameters to form the parameter grid, which includes multiple hyperparameter combinations; The sample dataset is divided into k subsets. One subset is selected from the k subsets as a sub-validation set, and the remaining k-1 subsets are selected as a sub-training set; where k is a natural number greater than 1. Select a target hyperparameter combination, train the initial prediction model using a different sub-training set each time, and verify the performance of the trained initial prediction model using different sub-validation sets to obtain k performance metrics; Calculate the average value of the k performance indicators to determine the average performance indicator corresponding to the target hyperparameter combination; Based on the average performance index corresponding to the hyperparameter combination, the optimal hyperparameter combination is determined from multiple hyperparameter combinations.

8. The method according to claim 1, characterized in that, The step of training an initial prediction model using a sample dataset based on the optimal hyperparameter combination to generate a final prediction model includes: Based on the optimal hyperparameter combination, the initial prediction model is trained using the training set to generate the target prediction model; The target prediction model is tested using a validation set and a test set. If the target prediction model passes the performance test, it is determined as the final prediction model for predicting natural gas prices.

9. A natural gas price forecasting system based on XGBoost, characterized in that, The system includes a data processing module, a feature processing module, a first training module, a hyperparameter processing module, a second training module, and a prediction module; The data processing module is used to acquire natural gas price-related data and multiple influencing factor data sequences through a data terminal, preprocess the natural gas price-related data, and generate standard data and standard data sequences. The feature processing module is used to calculate the cross-correlation function between the standard data sequence and multiple influencing factor data sequences, calculate the autocorrelation function between the standard data sequence and the lagged standard data sequence, determine the correlation between the autocorrelation function and multiple cross-correlation functions, and determine the target influencing factor data sequence and the corresponding target lag period, and the optimal lag period corresponding to the standard data sequence. The first training module is used to construct a sample dataset by using the standard data sequence and the corresponding optimal lag period, the target influencing factor data sequence and the corresponding target lag period as input variables, and the standard data as output variables, and to train the XGBoost model using the sample dataset to generate an initial prediction model. The hyperparameter processing module is used to set the candidate value range of hyperparameters, form a parameter grid, and determine the optimal hyperparameter combination of the initial prediction model based on the parameter grid and the sample dataset. The second training module is used to train the initial prediction model using the sample dataset based on the optimal hyperparameter combination, and generate the final prediction model. The prediction module is used to acquire real-time data, use the final prediction model to predict the price of natural gas, and feed the final prediction result back to the data terminal.

10. The system according to claim 9, characterized in that, The data processing module includes a data acquisition unit, a data identification unit, an anomaly identification unit, an anomaly processing unit, and a data conversion unit; The data acquisition unit is used to acquire price-related data tables and influencing factor data sequences through a data terminal. The data recognition unit is used to recognize characters in the price-related data table, convert the characters into floating-point numbers, generate price-related data, process missing data values ​​in the price-related data, and generate a given dataset based on the price-related data after processing missing data values. The outlier identification unit is used to identify and locate data in a given dataset, and to determine outliers that are significantly different from other data points in the given dataset. The outlier processing unit is used to process outliers in a given dataset and generate original data based on the given dataset after processing the outliers. The data conversion unit is used to convert the original data into a standard normal distribution with a mean of 0 and a standard deviation of 1, generating standard data and standard data sequences.

11. The system according to claim 9, characterized in that, The feature processing module includes a cross-correlation function generation unit, an autocorrelation function generation unit, and a correlation coefficient calculation unit; The cross-correlation function generation unit is used to calculate the cross-correlation function between the standard data sequence and the multiple influencing factor data sequences, respectively. The autocorrelation function generation unit is used to calculate the autocorrelation function between the standard data sequence and the lagged standard data sequence; The correlation coefficient calculation unit is used to calculate the correlation coefficient of multiple cross-correlation functions between the standard data sequence and different influencing factor data sequences, and to determine the target influencing factor data sequence and the corresponding target lag period based on the first correlation coefficient calculation result; The autocorrelation coefficient of the standard data sequence and the lagged standard data sequence is calculated, and the optimal lag period corresponding to the standard data sequence is determined based on the second correlation coefficient calculation result.

12. The system according to claim 9, characterized in that, The hyperparameter processing module includes a parameter grid generation unit, a subset generation unit, a performance index verification unit, an average performance index calculation unit, and a hyperparameter selection unit. The parameter grid generation unit is used to set the candidate value range of hyperparameters to form the parameter grid, which includes multiple hyperparameter combinations. The subset generation unit is used to divide the sample dataset into k subsets, determine one subset from the k subsets as a sub-validation set, and the remaining k-1 subsets as a sub-training set; where k is a natural number greater than 1. The performance index verification unit is used to select target hyperparameter combinations, train the initial prediction model using different sub-training sets each time, and verify the performance index of the trained initial prediction model using different sub-verification sets to obtain k performance indices. The average performance index calculation unit is used to calculate the average value of k performance indices and determine the average performance index corresponding to the target hyperparameter combination. The hyperparameter selection unit is used to determine the optimal hyperparameter combination from multiple hyperparameter combinations based on the average performance index corresponding to the hyperparameter combination.

13. A computer-readable storage medium storing one or more programs, characterized in that, When one or more of these programs are executed, the natural gas price prediction method based on XGBoost as described in any one of claims 1-8 can be implemented.

14. An electronic device comprising a processor, a communication interface, a computer-readable storage medium as described in claim 13, and a communication bus; wherein, The processor, communication interface, and computer-readable storage medium communicate with each other via a communication bus; Its features are, The processor is used to execute programs stored in a computer-readable storage medium.