A carbon emission calculation method based on gradient boosting tree and swarm intelligence algorithm
Patent Information
- Application Number
- CN202510612628.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-13
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2045-05-13
AI Technical Summary
[0003]然而,当前主流的碳排放量化方法在数据精度、动态响应能力和技术可靠性方面存在显著短板
[0031] The beneficial effects of this invention are as follows: The solution of this application constructs an electricity-carbon coupling feature set from multiple dimensions such as energy structure, unit operating status, meteorological influence, and time-series dynamics. It covers key features such as the proportion of renewable energy, the proportion of fossil energy power generation, load factor, coal power load, temperature, wind speed, peak-valley load ratio, and short-term historical carbon emission values. This feature set can comprehensively capture the key driving factors of carbon emissions from the power system. The feature set includes both the carbon intensity baseline of the energy structure at the macro level and the operating efficiency of meso-level units, the real-time impact of external meteorological factors, and the time-series dynamics, enabling the feature set to accurately characterize the complex relationship of the electricity-carbon coupling system. By using the particle swarm optimization algorithm to globally optimize the hyperparameters of the GBDT model, and by encoding the particle position vector and iteratively updating it, the optimal parameter combination such as the number of trees, maximum depth, and minimum number of sample splits can be efficiently searched within the feasible region. This avoids the local optima problem and computational resource waste of traditional grid search, and significantly improves the model's ability to fit high-dimensional nonlinear data. The GBDT model is based on the residual learning mechanism. By iteratively training new decision trees to fit the prediction residuals of the previous model, it can gradually correct the prediction error and achieve progressive and accurate prediction of carbon emission factors. It effectively handles the complex mapping relationship in power system data, enhances the model's adaptability to dynamic changing scenarios, avoids overfitting or underfitting problems, and greatly improves prediction accuracy and generalization performance.
Smart Images

Figure CN120542718B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of carbon emission technology, and in particular to a carbon emission calculation method based on gradient boosting tree and swarm intelligence algorithm. Background Technology
[0002] Faced with the severe challenges of global warming, the power industry, as a core sector of carbon emissions, urgently needs to accurately quantify carbon emissions to support a low-carbon transition. The power system is undergoing a structural transformation from traditional fossil fuel-dominated to deeply integrated renewable energy sources. Trends such as diversified energy structures, more complex load demands, and dynamic weather conditions place higher demands on the real-time performance, accuracy, and adaptability of carbon emission measurement. Effective carbon emission measurement is not only a key basis for evaluating the effectiveness of emission reduction measures but also the foundation for achieving refined carbon management and optimizing energy dispatch strategies.
[0003] However, current mainstream carbon emission quantification methods have significant shortcomings in terms of data accuracy, dynamic response capability, and technical reliability. Traditional methods mostly rely on static emission factors or simple statistical models, making it difficult to capture the dynamic coupling relationships of multiple dimensions of factors in the power system, such as changes in energy structure, unit operating status, and meteorological conditions. They also struggle to construct a comprehensive feature system covering energy structure, operating status, environmental impact, and time-series dynamics. Furthermore, the hyperparameter optimization of traditional machine learning algorithms relies on empirical parameter tuning or grid search, which easily leads to local optima and low computational efficiency. This makes them ill-suited to high-dimensional nonlinear data characteristics, resulting in insufficient prediction accuracy or weak generalization ability. Existing technologies, unable to respond in real-time to the interactive effects of multiple variables, exhibit significantly increased measurement errors when facing extreme weather conditions, sudden changes in energy structure, and other unsteady-state operating conditions, failing to meet the practical needs of real-time carbon accounting, emission monitoring, and optimized scheduling in the power system. Therefore, there is an urgent need for a carbon emission measurement method that can integrate multi-dimensional dynamic features, optimize model parameter configuration, and adapt to complex scenarios to improve the accuracy and reliability of carbon emission measurement in the power system. Summary of the Invention
[0004] In view of the above-mentioned prior art, the present invention provides a carbon emission calculation method based on gradient boosting tree and swarm intelligence algorithm, which mainly solves the technical problems existing in the background art.
[0005] To achieve the above objectives, the technical solution of this invention is implemented as follows:
[0006] A carbon emission calculation method based on gradient boosting tree and swarm intelligence algorithm, the calculation method comprising the following steps:
[0007] Acquire basic data and preprocess the basic data. The preprocessing includes removing outliers using sliding filtering and handling missing values using historical averages. The basic data includes power generation data, meteorological conditions data, and load data from the power generation side.
[0008] Feature extraction is performed on the preprocessed basic data to form an electricity-carbon coupling feature set, which includes basic energy structure features, unit operating status features, meteorological impact features, time-series dynamic features, and time-meteorological conditions energy consumption features.
[0009] A tree-based machine learning algorithm is used to construct a prediction model, and a swarm intelligence algorithm is used to search and optimize the hyperparameters of the prediction model. The established prediction model is then used for training.
[0010] By inputting the electricity-carbon coupling feature set into the trained prediction model, the dynamic carbon emission factor prediction result of the power system is obtained. Based on the dynamic carbon emission factor prediction result, the carbon emission prediction result of the power system is obtained.
[0011] Optionally, the power generation data includes fossil fuel consumption data, fossil fuel power generation data, wind power generation data, and photovoltaic power generation data; the meteorological condition data includes temperature and wind speed; and the load data includes actual load, rated load, peak and off-peak load, and reserve capacity.
[0012] Optionally, the specific process of using historical averages to handle missing values includes: taking the power generation data, meteorological condition data, and load data from the power generation side, and forming data sequences for power generation data, meteorological conditions data, and load data respectively according to the detection time points; calculating the historical average for each data sequence; and using the corresponding historical average to fill the missing values in the corresponding data sequence.
[0013] Optionally, the specific process of removing outliers using sliding filtering includes: for any selected data sequence, for any time point in the data sequence, take four adjacent data points before and after it, and together with the data at that time point, form a sliding window containing nine data points; calculate the average value of the data within the sliding window; if the difference between the data at that time point and the average value of the window exceeds a preset threshold, then replace the data at that time point with the average value of the window.
[0014] Optionally, the basic characteristics of the energy structure consist of the proportion of renewable energy and the proportion of fossil energy power generation; the characteristics of unit operation status consist of load rate and coal-fired power load; the meteorological influence characteristics include temperature and wind speed; and the time-series dynamic characteristics consist of peak-valley load ratio and short-term historical carbon emission values.
[0015] Optionally, the tree-based machine learning algorithm includes the gradient boosting decision tree algorithm, and the swarm intelligence algorithm includes a first particle swarm optimization algorithm and a second particle swarm optimization algorithm.
[0016] Optionally, the GBDT model is optimized using the first particle swarm optimization algorithm, specifically including:
[0017] Initialize the particle swarm size and maximum number of iterations. Encode the hyperparameters of the GBDT model, including the number of trees, maximum depth, and minimum number of sample splits, into particle position vectors, and randomly initialize the particle positions and velocities.
[0018] The particle velocity and position are updated according to the particle swarm optimization formula. When the maximum number of iterations or the fitness value converges, the hyperparameters corresponding to the global optimal position are used as the optimal parameter combination of the GBDT model.
[0019] Optionally, training the prediction model specifically includes: collecting historical basic data, constructing a historical electricity-carbon coupling feature set based on the historical basic data, and dividing the historical electricity-carbon coupling feature set into a training set and a test set;
[0020] The GBDT model is initialized using the optimal parameter combination. For the first decision tree in the initialized GBDT model, the residual between the actual value and the initial predicted value of the dynamic carbon emission factor in the training set is fitted.
[0021] The subsequent decision trees are generated round by round. Each tree is trained using the prediction residuals of the previous model as the training target, and the maximum depth of the tree is limited to the optimized parameters.
[0022] After each round of decision tree training, the root mean square error is calculated on the test set. If the error does not decrease for 10 consecutive rounds, training is terminated and the prediction model is output.
[0023] The model is evaluated using a test set. If the mean absolute error, root mean square error, or coefficient of determination does not reach the preset threshold, the hyperparameter optimization and training process is restarted. After determining the optimal parameter combination of the GBDT model, the training set is input into the constructed GBDT model for training to obtain the initial GBDT model.
[0024] Optionally, for the trained GBDT model, the prediction accuracy can be evaluated using one of the mean absolute error, root mean square error, or coefficient of determination. If the evaluation result is lower than the expected value, the current GBDT model can be used as the initial GBDT model, and the model can be retrained using data with low prediction accuracy.
[0025] Optionally, the prediction results of the prediction model are corrected using the actual residual term, specifically including:
[0026] Collect basic data at the current time t, and construct an electricity-carbon coupling feature set at time t based on the basic data at the current time t. Input the electricity-carbon coupling feature set at time t into the prediction model to obtain the initial dynamic carbon emission factor prediction value.
[0027] Collect basic data and actual carbon emission factors at time t-1, construct an electricity-carbon coupling feature set at time t-1 based on the basic data at time t-1, input the electricity-carbon coupling feature set at time t-1 into the prediction model, and obtain the predicted value of dynamic carbon emission factors at time t-1.
[0028] The actual residual term is obtained based on the predicted value of the dynamic carbon emission factor at time t-1 and the actual carbon emission factor at time t-1.
[0029] An adaptive learning rate is obtained based on the second particle swarm optimization algorithm, and a real-time residual correction term is obtained based on the adaptive learning rate and the residual term.
[0030] The initial dynamic carbon emission factor prediction at time t is superimposed with the real-time residual correction term to obtain the corrected dynamic carbon emission factor.
[0031] The beneficial effects of this invention are as follows: The solution of this application constructs an electricity-carbon coupling feature set from multiple dimensions such as energy structure, unit operating status, meteorological influence, and time-series dynamics. It covers key features such as the proportion of renewable energy, the proportion of fossil energy power generation, load factor, coal power load, temperature, wind speed, peak-valley load ratio, and short-term historical carbon emission values. This feature set can comprehensively capture the key driving factors of carbon emissions from the power system. The feature set includes both the carbon intensity baseline of the energy structure at the macro level and the operating efficiency of meso-level units, the real-time impact of external meteorological factors, and the time-series dynamics, enabling the feature set to accurately characterize the complex relationship of the electricity-carbon coupling system. By using the particle swarm optimization algorithm to globally optimize the hyperparameters of the GBDT model, and by encoding the particle position vector and iteratively updating it, the optimal parameter combination such as the number of trees, maximum depth, and minimum number of sample splits can be efficiently searched within the feasible region. This avoids the local optima problem and computational resource waste of traditional grid search, and significantly improves the model's ability to fit high-dimensional nonlinear data. The GBDT model is based on the residual learning mechanism. By iteratively training new decision trees to fit the prediction residuals of the previous model, it can gradually correct the prediction error and achieve progressive and accurate prediction of carbon emission factors. It effectively handles the complex mapping relationship in power system data, enhances the model's adaptability to dynamic changing scenarios, avoids overfitting or underfitting problems, and greatly improves prediction accuracy and generalization performance.
[0032] By analyzing and inferring from real-time input feature data, carbon emission prediction results that conform to the actual operation of the power system are output. In this process, the impact of factors such as changes in energy structure, load fluctuations, and meteorological conditions on carbon emissions can be dynamically responded to, providing a scientific and accurate quantitative basis for monitoring, assessing, and optimizing carbon emissions in the power system. Attached Figure Description
[0033] Figure 1 This is a flowchart illustrating a carbon emission calculation method based on gradient boosting tree and swarm intelligence algorithm in an embodiment of this application. Detailed Implementation
[0034] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. In the following description, the expression "some embodiments" refers to a subset of all possible embodiments; however, it should be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with each other without conflict.
[0035] In the following description, numerous specific details are set forth in order to provide a more thorough understanding of the invention. However, it will be apparent to those skilled in the art that the invention can be practiced without one or more of these details. In other instances, certain technical features well-known in the art have not been described in order to avoid obscuring the invention.
[0036] It should be understood that the present invention can be embodied in various forms and should not be construed as being limited to the embodiments set forth herein. Rather, providing these embodiments will make the disclosure thorough and complete, and will fully convey the scope of the invention to those skilled in the art. Furthermore, the terminology used herein is intended only to describe particular embodiments and is not intended to limit the invention. When used herein, the singular forms “a,” “an,” and “the” are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the terms “compose” and / or “comprising,” when used in this specification, identify the presence of the stated features, integers, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups. When used herein, the term “and / or” includes any and all combinations of the associated listed items.
[0037] It should also be noted that when an element is referred to as being "fixed to" another element, it can be directly attached to the other element or there may be an intervening element. When an element is referred to as being "connected to" another element, it can be directly connected to the other element or there may be an intervening element. The terms "vertical," "horizontal," "inner," "outer," "left," "right," and similar expressions used herein are for illustrative purposes only and do not represent the only possible implementation.
[0038] To fully understand this invention, a detailed structure will be presented in the following description to illustrate the technical solution proposed by this invention. Optional embodiments of the invention are described in detail below; however, in addition to these detailed descriptions, the invention may have other embodiments.
[0039] See Figure 1 The present application discloses a carbon emission calculation method based on gradient boosting tree and swarm intelligence algorithm, the calculation method comprising the following steps:
[0040] S1. Obtain basic data and preprocess the basic data. The preprocessing includes removing outliers using sliding filtering and processing missing values using historical averages. The basic data includes power generation data, meteorological conditions data, and load data from the power generation side.
[0041] S2. Extract features from the preprocessed basic data to form an electricity-carbon coupling feature set, which includes basic energy structure features, unit operating status features, meteorological impact features, time-series dynamic features, and time-meteorological conditions energy consumption features.
[0042] S3. A prediction model is constructed using a tree-based machine learning algorithm, and the hyperparameters of the prediction model are searched and optimized using a swarm intelligence algorithm. The established prediction model is then used for training.
[0043] S4. Input the electricity-carbon coupling feature set into the trained prediction model to obtain the prediction results of the dynamic carbon emission factor of the power system. Based on the prediction results of the dynamic carbon emission factor, obtain the prediction results of the carbon emissions of the power system.
[0044] Specifically, by collecting basic data in advance, including power generation data, meteorological conditions, and load information, and by preprocessing to eliminate data noise and supplement missing information, a feature set reflecting the system's operating status and environmental impact is formed. In the feature construction stage, the raw data is transformed into comprehensive features covering energy structure, unit efficiency, external environmental effects, and temporal dynamic characteristics, revealing the inherent laws of carbon emissions through multi-dimensional correlation. Subsequently, a tree-based machine learning algorithm is used to construct a prediction model, and a swarm intelligence algorithm is used to search and optimize the hyperparameters of the prediction model. Combined with an iterative training mechanism, errors are gradually corrected, ultimately generating a high-precision dynamic carbon emission factor prediction result. This high-precision dynamic carbon emission factor prediction result is multiplied by fossil fuel power generation to obtain the power system's carbon emission prediction result. Through dynamic fusion of multi-dimensional features and optimized model structure, this method can accurately capture the real-time changes and complex correlations of power system carbon emissions. Furthermore, the collaborative analysis of environmental factors and system operating status enhances the model's adaptability to changes in external conditions, ultimately significantly improving the stability and reliability of the input data. The overall method exhibits strong robustness in complex scenarios, providing efficient and accurate technical support for low-carbon regulation and decision-making in power systems.
[0045] In an optional implementation, the power generation data includes fossil fuel consumption data, fossil fuel power generation data, wind power generation data, and photovoltaic power generation data; the meteorological condition data includes temperature and wind speed; and the load data includes actual load, rated load, peak and off-peak load, and reserve capacity.
[0046] Specifically, the power generation data includes data on fossil fuel consumption, fossil fuel power generation, wind power generation, and photovoltaic power generation. Fossil fuel consumption includes coal and natural gas consumption. This data reflects the proportion of different energy types in the power system. Fossil fuel consumption and power generation are directly related to the calculation of carbon emissions and are the core basis for carbon emission measurement. Wind and photovoltaic power generation data reflect the contribution of renewable energy to the power supply. The proportion of renewable energy directly affects the carbon intensity baseline of the entire power system. Through this data, the basic characteristics of the energy structure can be accurately constructed, providing key information on energy composition for carbon emission measurement, enabling the measurement to assess carbon emission levels based on the actual energy generation composition.
[0047] Meteorological data, including temperature and wind speed, have a direct and real-time impact on the operation of power systems. Wind speed is a key factor determining wind power generation; changes in wind speed lead to fluctuations in wind power output, which in turn affect the ratio of renewable energy to fossil fuel generation in the power system, thus indirectly affecting carbon emissions. Temperature, on the other hand, can influence the carbon emissions of the power system by affecting electricity consumption and the efficiency of power generation equipment.
[0048] Load data includes actual load, rated load, peak-valley load, and reserve capacity. These data characterize the load characteristics and operating status of the power system from different dimensions. For example, comparing actual load with rated load yields the load factor, reflecting the operating efficiency of generating units. A low load factor may indicate that the units are operating inefficiently, leading to increased carbon emissions per unit of electricity. Peak-valley load data reflects the distribution of electricity demand at different times. Higher peak loads may require more high-carbon fossil fuel units to operate, while lower peak loads may utilize more low-carbon or renewable energy sources. This time-of-day difference has a significant impact on carbon emissions. Reserve capacity reflects the generation capacity reserved by the system to ensure power supply reliability; the operating status of reserve units also affects carbon emissions. Through this load data, we can comprehensively characterize the operating status of generating units and power dispatch patterns, capture the inertial characteristics and dynamic changes in system operation, and ensure that carbon emission calculations fully consider the actual situation at the load end.
[0049] In an optional implementation, after obtaining the above-mentioned basic data, it is usually necessary to preprocess the basic data. The preprocessing includes removing outliers and handling missing values. The specific process of handling missing values includes: taking the power generation data, meteorological condition data, and load data from the power generation side, and forming data sequences for power generation data, meteorological conditions data, and load data according to the detection time points, respectively; calculating the historical average value for each data sequence; and using the corresponding historical average value to fill the missing values in the corresponding data sequence.
[0050] Furthermore, the specific process for removing outliers includes: for any selected data sequence, for any time point in the data sequence, taking four adjacent data points before and after it, and forming a sliding window containing nine data points together with the data at that time point; calculating the average value of the data within the sliding window; if the difference between the data at that time point and the average value of the window exceeds a preset threshold, then replacing the data at that time point with the average value of the window.
[0051] Taking the processing of fossil fuel consumption data as an example, historical fossil fuel consumption data from the past 5 years is collected daily and arranged in chronological order to form a data sequence k of fossil fuel consumption data. T ={K t,1 ,K t+1,2, K t+2,3 ,...,K t+N,n}, K t+N,n This represents the fossil fuel consumption data n at time point t+N, for this data sequence k. T Calculate its historical average value, and fill the data sequence k with the corresponding historical average value. T Missing values in.
[0052] Similarly, for the data sequence k of fossil energy consumption data... T Let i be the time point to be detected. Take the four adjacent data points before and after i, and together with the data at that time point, form a sliding window T = {K} containing nine data points. i-4,n ,K i-3,n ,K i-2,n ,...,K i,n ,K i+1,n ,...K i+4,n} Calculate the average value of the data within the sliding window. If the difference between the data at that time point and the average value of the window exceeds a preset threshold, it indicates that the data at that time point is an outlier. In this case, the data at that time point is replaced with the average value of the window.
[0053] Furthermore, the other data sequences are preprocessed using the methods described above.
[0054] In an optional implementation, the electricity-carbon coupling feature set includes basic energy structure features, unit operating status features, meteorological impact features, time-series dynamic features, and time-meteorological condition energy consumption features. The basic energy structure features consist of the proportion of renewable energy and the proportion of fossil fuel power generation. The unit operating status features consist of the load factor and the proportion of coal-fired power load. The meteorological impact features include temperature and wind speed. The time-series dynamic features consist of the peak-valley load ratio and short-term historical carbon emission values.
[0055] Specifically, the basic characteristics of the energy structure consist of the proportion of renewable energy and the proportion of fossil fuel power generation. The proportion of renewable energy is quantified by the ratio of wind power and photovoltaic power generation to total power generation, which reflects the contribution of low-carbon energy to the power supply. The proportion of fossil fuel power generation reflects the dominance of high-carbon energy by the proportion of power generation from fossil fuels such as coal and natural gas. Together, they constitute the carbon intensity baseline of the energy structure, providing macro-level basic parameters for measuring the overall carbon emissions of the system, enabling the model to distinguish the direct impact of different energy types on carbon emissions.
[0056] The characteristics of unit operation status include load factor and coal-fired power load ratio. The load factor, which is the ratio of actual load to rated load, describes the operating efficiency of the generator unit. Low load factor is usually accompanied by insufficient energy utilization and increased unit energy consumption, which indirectly leads to an increase in carbon emission intensity. The coal-fired power load ratio, which is the ratio of the power generation of coal-fired units to the total power generation, directly reflects the contribution of high-carbon power generation in the system. Both of these characteristics capture the impact of unit operating efficiency and high-carbon energy dependence on carbon emissions at the meso-level, providing the model with key parameters that reflect the equipment operating status.
[0057] Meteorological impact characteristics include temperature and wind speed. Temperature, as an environmental variable, affects the thermodynamic cycle efficiency of generator units, and thus indirectly affects fossil energy consumption and carbon emission levels. Wind speed, as the core driving factor of wind power generation, directly determines wind power generation and the real-time proportion of renewable energy through real-time data within the effective wind speed range. As external input variables, these two factors enable the calculation method to respond in real time to the dynamic effects of meteorological conditions on energy conversion efficiency and renewable energy output, avoiding calculation deviations caused by ignoring environmental factors.
[0058] The time-series dynamic characteristics consist of the peak-valley load ratio and short-term historical carbon emission values. The peak-valley load ratio, which is the ratio of the average load during peak hours to that during valley hours, reflects the temporal distribution pattern of electricity demand. High load during peak hours may prompt fossil fuel units to increase their output, while low load during valley hours is accompanied by changes in renewable energy consumption, thus affecting the temporal distribution characteristics of carbon emissions. The short-term historical carbon emission values extract the total carbon emissions of the hour preceding the current moment, capturing the inertial characteristics of system operation and reflecting the continuous impact of historical carbon emissions on the current state. The combination of these two values enables the model to learn the dynamic patterns of the power system in the time dimension, improving its ability to predict load fluctuations and carbon emission trends.
[0059] In one optional implementation, the tree-based machine learning algorithm includes a gradient boosting decision tree algorithm, which constructs a GBDT model for prediction. The swarm intelligence algorithm includes a first particle swarm optimization algorithm and a second particle swarm optimization algorithm.
[0060] Furthermore, the GBDT model is optimized using the first particle swarm optimization algorithm, specifically including:
[0061] Initialize the particle swarm size and maximum number of iterations. Encode the hyperparameters of the GBDT model, including the number of trees, maximum depth, and minimum number of sample splits, into particle position vectors, and randomly initialize the particle positions and velocities.
[0062] The particle velocity and position are updated according to the particle swarm optimization formula. When the maximum number of iterations or the fitness value converges, the hyperparameters corresponding to the global optimal position are used as the optimal parameter combination of the GBDT model.
[0063] Specifically, in the optimization process, the basic configuration of the particle swarm is first defined, the particle swarm size is set to determine the number of individuals participating in the search, the maximum number of iterations is set to control the computational complexity of the search process, and the core hyperparameters of the GBDT model, including the number of trees, the maximum depth of the decision tree, and the minimum number of sample splits, are encoded as particle position vectors, so that each particle corresponds to a specific set of hyperparameters. Within the parameter feasible region, the initial position and velocity of the particles are randomly initialized to form a diverse initial search population, ensuring comprehensive coverage of the search space.
[0064] During the iterative optimization phase, particles adjust their search direction by fusing their individual historical best experience with the swarm's global best experience. Each particle updates its state in each iteration based on its current velocity, its previous best position, and the best position found by the entire swarm, moving towards potentially better regions in the parameter space. After each position update, the hyperparameter combination carried by the particle is applied to the GBDT model. The model is trained using an electro-carbon coupling feature set, and the fitness of the current hyperparameter combination is evaluated using the prediction error on the validation set. A smaller error indicates higher fitness, meaning the combination better fits the complex mapping relationships in the data. Particles continuously compare their current fitness with their historical best fitness and the global best fitness, dynamically updating their individual and global best positions. The search process terminates when the preset maximum number of iterations is reached, or when the global best fitness no longer significantly improves in multiple consecutive iterations. At this point, the hyperparameter combination corresponding to the global best position—that is, the optimal values of the number of trees, maximum depth, and minimum number of sample splits determined by particle swarm optimization—is extracted as the optimal parameter combination for the GBDT model. This process leverages the global search capability of the particle swarm optimization algorithm to effectively avoid the subjectivity of traditional manual parameter tuning and the computational inefficiency of grid search. It can automatically optimize the parameter configuration that maximizes the generalization performance of the model for the high-dimensional and nonlinear data characteristics in the carbon emission measurement scenario of the power system, laying a key parameter foundation for the subsequent GBDT model to achieve accurate prediction based on the residual training mechanism.
[0065] Furthermore, training the prediction model specifically includes: collecting historical basic data, constructing a historical electricity-carbon coupling feature set based on the historical basic data, and dividing the historical electricity-carbon coupling feature set into a training set and a test set;
[0066] The GBDT model is initialized using the optimal parameter combination. For the first decision tree in the initialized GBDT model, the residual between the actual value and the initial predicted value of the dynamic carbon emission factor in the training set is fitted.
[0067] The subsequent decision trees are generated round by round. Each tree is trained using the prediction residuals of the previous model as the training target, and the maximum depth of the tree is limited to the optimized parameters.
[0068] After each round of decision tree training, the root mean square error is calculated on the test set. If the error does not decrease for 10 consecutive rounds, training is terminated and the prediction model is output.
[0069] Specifically, after determining the optimal hyperparameters, a gradient boosting decision tree model is initialized based on these parameters, and iterative training begins. In the initial stage, the model uses the label mean or log odds as the baseline prediction value and calculates the initial residual, i.e., the difference between the actual and predicted values. The first decision tree uses these residuals as the training objective, generating a tree structure through feature splitting. The output value of each leaf node is the mean of the sample residuals within that node, thus minimizing the loss function. After training the first tree, the model superimposes the current prediction result with the initial baseline value to update the overall prediction value. In each subsequent iteration, the residuals of the preceding model on all training samples are first calculated as the training objective for the new tree. During the generation of the new tree, split points are selected based on the importance of features, and the tree depth and minimum number of samples per leaf node are limited to control model complexity and prevent overfitting. After each tree is trained, it is weighted according to the learning rate and superimposed onto the preceding model to gradually correct the prediction error. During training, the model's prediction accuracy is evaluated on an independent validation set after each iteration. If the validation error does not decrease for several consecutive iterations, training is terminated early to avoid invalid computation, thus outputting the final prediction model.
[0070] Furthermore, for the trained GBDT model, the prediction accuracy is evaluated using one of the following: mean absolute error, root mean square error, or coefficient of determination. If the evaluation result is lower than the expected value, the current GBDT model is used as the initial GBDT model, and the model is retrained using data with low prediction accuracy.
[0071] Before a gradient boosting decision tree model is deployed in practical applications after training, its predictive performance needs to be systematically tested using pre-defined evaluation metrics. The evaluation process primarily employs three types of metrics: mean absolute error (MAO), root mean square error (RMSE), and coefficient of determination (CMD), quantifying prediction accuracy from three dimensions: absolute error, squared error sensitivity, and model explanatory power. MAO, calculated as the average absolute deviation between predicted and actual values, directly reflects the average magnitude of the model's prediction error. RMSE amplifies the impact of larger errors through squaring, more sensitively capturing model stability issues in extreme scenarios. CMD measures the model's ability to capture the inherent patterns in the data by comparing the model's prediction variance to the overall data variance. Thresholds for these three metrics need to be set based on business requirements; for example, in carbon emission calculation scenarios, the CMD must be no less than 0.9, and the RMSE must not exceed 5% of the actual value range.
[0072] If the evaluation results show that the indicators do not meet the preset standards, the iterative optimization process of the model needs to be initiated. At this time, the current model should be used as the initial model, rather than being completely re-initialized, to preserve the learned data patterns. The core of the optimization process lies in targeted learning for samples with large prediction errors. In practice, it is first necessary to screen samples with significant prediction deviations from the test set or new data, such as residuals exceeding twice the standard deviation, and analyze the differences between their feature distribution and the original training data. For example, in electricity carbon emission prediction, it may be found that samples with high prediction errors during periods of sudden load increases or under extreme wind speed conditions often contain dynamic coupling relationships that traditional features cannot fully describe. By extracting supplementary features such as high-frequency unit operating parameters and fuel characteristic changes during relevant periods, an enhanced training set is constructed, and the training and validation sets are re-divided.
[0073] During retraining, the model continues to generate new trees based on the initial model's tree structure, but the training strategy needs to be adjusted to strengthen the learning of high-error samples. A weighted loss function is adopted, assigning larger weight coefficients to high residual samples, forcing the newly generated decision trees to prioritize fitting the residuals of these samples. Simultaneously, a dynamic learning rate mechanism is introduced, using a higher learning rate in the early stages of training to quickly approach the global optimum, and gradually reducing the learning rate in later stages to refine local adjustments. For example, in the deep peak-shaving scenario of coal-fired power units, by increasing the weights of relevant samples, the model can more accurately capture the impact of nonlinear changes in fuel combustion efficiency on carbon emissions under low-load conditions.
[0074] The prediction results of the prediction model are corrected using the actual residual term, specifically including:
[0075] Collect basic data at the current time t, and construct an electricity-carbon coupling feature set at time t based on the basic data at the current time t. Input the electricity-carbon coupling feature set at time t into the prediction model to obtain the initial dynamic carbon emission factor prediction value.
[0076] Collect basic data and actual carbon emission factors at time t-1, construct an electricity-carbon coupling feature set at time t-1 based on the basic data at time t-1, input the electricity-carbon coupling feature set at time t-1 into the prediction model, and obtain the predicted value of dynamic carbon emission factors at time t-1.
[0077] The actual residual term is obtained based on the predicted value of the dynamic carbon emission factor at time t-1 and the actual carbon emission factor at time t-1.
[0078] An adaptive learning rate is obtained based on the second particle swarm optimization algorithm, and a real-time residual correction term is obtained based on the adaptive learning rate and the residual term.
[0079] The initial dynamic carbon emission factor prediction at time t is superimposed with the real-time residual correction term to obtain the corrected dynamic carbon emission factor.
[0080] Specifically, in the real-time prediction and correction phase, for the current time t, an electricity-carbon coupling feature set containing the energy structure, load status, and meteorological parameters at that time is first constructed based on the real-time collected basic data. This feature set is then input into the initial model to obtain the initial dynamic carbon emission factor prediction value, which reflects the model's immediate response to the current operating state. Simultaneously, basic data and the actual carbon emission factor at the previous time t-1 are collected. The actual carbon emission factor at the previous time t-1 is calculated by dividing the actual fossil energy consumption by the actual power generation. The basic data from the previous time t-1 is used to construct the electricity-carbon coupling feature set at time t-1, which is then input into the model to obtain the predicted value for that time. The residual, i.e., the model prediction bias, is calculated by comparing this predicted value with the actual value.
[0081] The existence of prediction bias indicates that the model may lag under short-term dynamic changes. Therefore, a second particle swarm optimization (PSO) algorithm is introduced to dynamically solve for the adaptive learning rate. Its solution process is similar to that of the first PSO algorithm optimizing the GBDT model. PSO simulates the search behavior of a particle swarm and iteratively optimizes the learning rate within a preset parameter space, aiming to minimize the root mean square error of historical residuals. This allows the learning rate to be dynamically adjusted according to the system's operating state, such as load fluctuations during peak and off-peak periods and the stability of renewable energy output. For example, the learning rate is increased when the load changes drastically to strengthen residual correction, and decreased when the system is operating smoothly to avoid over-adjustment.
[0082] In summary, after each prediction result is obtained, a real-time residual correction term is calculated based on the prediction result and actual value of the previous moment. This term is then superimposed on the initial prediction value of the current moment to obtain the final dynamic factor used for carbon emission calculation. This approach retains the GBDT model's ability to fit long-term data patterns, such as the impact of seasonal energy structure changes on carbon emissions, while also enabling rapid response to short-term sudden changes through real-time residual correction, such as the instantaneous fluctuations in emission factors caused by deep peak shaving of coal-fired power units and the impact of extreme wind speeds on wind power output.
[0083] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. The scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A carbon emission calculation method based on gradient boosting tree and swarm intelligence algorithm, characterized in that, The calculation method includes the following steps: Acquire basic data and preprocess the basic data. The preprocessing includes removing outliers using sliding filtering and handling missing values using historical averages. The basic data includes power generation data, meteorological conditions data, and load data from the power generation side. Feature extraction is performed on the preprocessed basic data to form an electricity-carbon coupling feature set, which includes basic energy structure features, unit operating status features, meteorological impact features, time-series dynamic features, and time-meteorological conditions energy consumption features. A tree-based machine learning algorithm is used to construct a prediction model, and a swarm intelligence algorithm is used to search and optimize the hyperparameters of the prediction model. The established prediction model is then used for training. The electricity-carbon coupling feature set is input into the trained prediction model to obtain the prediction results of the dynamic carbon emission factor of the power system. Based on the prediction results of the dynamic carbon emission factor, the prediction results of the carbon emission of the power system are obtained. Tree-based machine learning algorithms include gradient boosting decision tree algorithms, and swarm intelligence algorithms include first particle swarm optimization algorithms and second particle swarm optimization algorithms. The GBDT model is optimized using the first particle swarm optimization algorithm, specifically including: Initialize the particle swarm size and maximum number of iterations. Encode the hyperparameters of the GBDT model, including the number of trees, maximum depth, and minimum number of sample splits, into particle position vectors, and randomly initialize the particle positions and velocities. The particle velocity and position are updated according to the particle swarm optimization formula. When the maximum number of iterations or the fitness value converges, the hyperparameters corresponding to the global optimal position are used as the optimal parameter combination of the GBDT model. Training the prediction model specifically includes: collecting historical basic data, constructing a historical electricity-carbon coupling feature set based on the historical basic data, and dividing the historical electricity-carbon coupling feature set into a training set and a test set; The GBDT model is initialized using the optimal parameter combination. For the first decision tree in the initialized GBDT model, the residual between the actual value and the initial predicted value of the dynamic carbon emission factor in the training set is fitted. The subsequent decision trees are generated round by round. Each tree is trained using the prediction residuals of the previous model as the training target, and the maximum depth of the tree is limited to the optimized parameters. After each round of decision tree training, the root mean square error is calculated on the test set. If the error does not decrease for 10 consecutive rounds, the training is terminated and the prediction model is output. The prediction results of the prediction model are corrected using the actual residual term, specifically including: Collect basic data at the current time t, and construct an electricity-carbon coupling feature set at time t based on the basic data at the current time t. Input the electricity-carbon coupling feature set at time t into the prediction model to obtain the initial dynamic carbon emission factor prediction value. Collect basic data and actual carbon emission factors at time t-1, construct an electricity-carbon coupling feature set at time t-1 based on the basic data at time t-1, input the electricity-carbon coupling feature set at time t-1 into the prediction model, and obtain the predicted value of dynamic carbon emission factors at time t-1. The actual residual term is obtained based on the predicted value of the dynamic carbon emission factor at time t-1 and the actual carbon emission factor at time t-1. An adaptive learning rate is obtained based on the second particle swarm optimization algorithm, and a real-time residual correction term is obtained based on the adaptive learning rate and the residual term. The initial dynamic carbon emission factor prediction at time t is superimposed with the real-time residual correction term to obtain the corrected dynamic carbon emission factor.
2. The carbon emission calculation method based on gradient boosting tree and swarm intelligence algorithm according to claim 1, characterized in that, The power generation data includes fossil fuel consumption data, fossil fuel power generation data, wind power generation data, and photovoltaic power generation data. The meteorological condition data includes temperature and wind speed. The load data includes actual load, rated load, peak and off-peak load, and reserve capacity.
3. The carbon emission calculation method based on gradient boosting tree and swarm intelligence algorithm according to claim 2, characterized in that, The specific process of using historical averages to handle missing values includes: generating data, meteorological data, and load data from the power generation side, respectively forming data sequences for generating data, meteorological data, and load according to the detection time points; calculating the historical average for each data sequence; and using the corresponding historical average to fill the missing values in the corresponding data sequence.
4. The carbon emission calculation method based on gradient boosting tree and swarm intelligence algorithm according to claim 3, characterized in that, The specific process of removing outliers using sliding filtering includes: for any selected data sequence, for any time point in the data sequence, take four adjacent data points before and after it, and together with the data at that time point, form a sliding window containing nine data points. Calculate the average value of the data within the sliding window. If the difference between the data at that time point and the average value of the window exceeds a preset threshold, then replace the data at that time point with the average value of the window.
5. The carbon emission calculation method based on gradient boosting tree and swarm intelligence algorithm according to claim 4, characterized in that, The basic characteristics of the energy structure consist of the proportion of renewable energy and the proportion of fossil fuel power generation; the characteristics of unit operation status consist of load rate and coal-fired power load; the meteorological influence characteristics include temperature and wind speed; and the time-series dynamic characteristics consist of peak-valley load ratio and short-term historical carbon emission values.
6. The carbon emission calculation method based on gradient boosting tree and swarm intelligence algorithm according to claim 1, characterized in that, For the trained GBDT model, the prediction accuracy is evaluated using one of the following: mean absolute error, root mean square error, or coefficient of determination. If the evaluation result is lower than the expected value, the current GBDT model is used as the initial GBDT model, and the model is retrained using data with low prediction accuracy.