Carbon emission prediction method and device based on energy data, equipment and storage medium
Through the improved squid group algorithm, the hyperparameters of the LightGBM algorithm are adjusted, which solves the problem of difficulty in tuning hyperparameters in carbon emission prediction by machine learning models, and achieves higher prediction accuracy and efficiency.
Patent Information
- Application Number
- CN202411724062.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing machine learning models have difficulty in tuning hyperparameters in carbon emission prediction, which affects the accuracy of model output results.
The improved cassia group algorithm is used to adjust the hyperparameters of the LightGBM algorithm, and the hyperparameter combination is optimized through LEVY flight strategy and Gaussian mutant operator to improve the prediction accuracy of the model.
It achieves smaller root mean square error and shorter training time, improves the prediction accuracy and efficiency of the LightGBM model, and enhances the convergence performance of the model and the ability to find optimal solutions.
Smart Images

Figure CN119647679A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of energy consumption technology, and in particular to a carbon emission prediction method, device, equipment and storage medium based on energy data. Background Art
[0002] Energy data is a record of information on energy production, consumption, reserves, prices, emissions, and related policies and technologies. These data not only reflect the operating status of the energy industry, but also provide an important basis for energy policy formulation, market forecasting, and optimal resource allocation. Among them, energy consumption is one of the indicators for measuring economic growth. Energy consumption refers to the energy consumed in production and life, while carbon emissions refer to the emissions of greenhouse gases such as carbon dioxide generated during the energy consumption process. Therefore, carbon emissions are regarded as a specific manifestation of energy consumption.
[0003] With the development of artificial intelligence technology and the increasing requirements for the accuracy of carbon emission prediction, machine learning methods have been used in carbon emission prediction because of their strong ability to handle nonlinear and complex problems. Although scholars have used various machine learning models to predict carbon emissions, there is still room for improvement in the prediction effect. The parameters of machine learning models are mainly divided into two categories: model parameters and hyperparameters. The parameters that can be optimized through training are called model parameters, and the parameters that cannot be directly optimized through training are called hyperparameters. Since machine learning algorithms contain a large number of hyperparameters, the selection of hyperparameters will be directly related to the output results of the model. Therefore, how to find the optimal hyperparameter combination becomes a key step that affects the performance of machine learning. Summary of the invention
[0004] In view of the above problems, the present invention proposes a carbon emission prediction method, device, equipment and storage medium based on energy data, in an effort to solve or alleviate one or more of the above technical problems.
[0005] According to one aspect of the present invention, a carbon emission prediction method based on energy data is proposed, the method comprising the following steps:
[0006] Determine the influencing factors of carbon emissions, and obtain historical data of the influencing factors and the corresponding historical carbon emissions; the influencing factors include economic factors, demographic factors, scientific and technological investment, energy structure, energy consumption intensity, and industrial structure;
[0007] The historical data of the influencing factors are used as input values, and the historical carbon emissions are used as output values to construct and train a prediction model based on the LightGBM algorithm; wherein the hyperparameters of the LightGBM algorithm are adjusted using the improved Salp Swarm algorithm to obtain the optimal parameter combination;
[0008] Carbon emissions are predicted using the trained prediction model with the optimal parameter combination.
[0009] Furthermore, the hyperparameters of the LightGBM algorithm include learning rate, maximum depth of the tree, number of iterations, number of leaf nodes on each tree, minimum amount of data on each leaf node, minimum leaf node sample weight and, sample sampling ratio of each tree, data ratio used in each iteration, L1 regularization parameter, and L2 regularization parameter.
[0010] Furthermore, the use of the improved salp swarm algorithm to adjust the hyperparameters of the LightGBM algorithm to obtain the optimal parameter combination includes:
[0011] Set the value range of the hyperparameters of the LightGBM algorithm; randomly initialize the position of the salps to generate a fixed-size population of solution individuals;
[0012] Calculate the fitness of each salp individual: substitute the individual parameters into the LightGBM model for training on the training set, calculate the root mean square error on the test set, and use the inverse of the root mean square error as the fitness function, so as to calculate the fitness value of each salp individual in the initial population according to the fitness function;
[0013] Determine the location of the food source: set the location of the salp with the best fitness as the location of the food source of the current iteration;
[0014] Determine the leader and followers: remove the top salp individual, sort the remaining salps in the group according to the initial population fitness, set the first half of the individuals as leaders, and the second half of the individuals as followers;
[0015] Position update: Update the positions of the leader and follower respectively;
[0016] Calculate the updated group fitness: compare it with the fitness value of the food source and set the new food source position, that is, the position of the salp individual with better fitness value;
[0017] Repeat the process of determining the leader and follower, updating the position, and calculating the updated group fitness; when the number of iterations reaches the maximum number of iterations, output the current food position as the global optimal solution.
[0018] Furthermore, the LEVY flight strategy is introduced in the position update to update the position of the leader. The leader position formula after adding the LEVY flight disturbance is:
[0019]
[0020] In the formula, is the position of the current salp leader i in the j-dimensional space; q is the adaptive weight; P j is the position of the current food source in the j-dimensional space; c1 and c2 are random numbers uniformly distributed between (0,1); ab j ,tb j is the range of the search space in the jth dimension; t is the current iteration number, and s is the LEVY flight step.
[0021] Furthermore, the calculation formula of the adaptive weight q in the leader position formula after adding the LEVY flight disturbance is:
[0022] q=q a -(q a -q m )×(t / T) 2
[0023] In the formula, q a ,q m They represent the preset maximum and minimum weights respectively, and T is the total number of iterations.
[0024] Furthermore, the Gaussian mutation operator is introduced in the position update to update the position of the follower. The follower position formula after the introduction of the Gaussian mutation operator is:
[0025]
[0026] In the formula, Indicates the position of the current salp follower ii in the j-dimensional space; To change the asynchronous length, l is a random number uniformly generated in the interval [0,1], n is a system parameter, N is the total number of individuals in the salp colony, and σ is the standard deviation of the Gaussian distribution.
[0027] Furthermore, when calculating the fitness of each individual salp, after calculating the root mean square error on the test set, the fitness function is further calculated according to the following formula:
[0028] F'=e -aF
[0029] In the formula, F' is the fitness function after exponential transformation; F is the original fitness function, that is, the root mean square error; a s is the preset starting value of a, k is the adjustment factor, F avg is the average value of the population fitness function, and ε is a number infinitely close to 0.
[0030] According to another aspect of the present invention, a carbon emission prediction device based on energy data is provided, the system comprising:
[0031] A historical data acquisition module, which is configured to determine the influencing factors of carbon emissions and acquire the historical data of the influencing factors and the corresponding historical carbon emissions; the influencing factors include economic factors, demographic factors, scientific and technological investment, energy structure, energy consumption intensity, and industrial structure;
[0032] A prediction model training module, which is configured to use the historical data of the influencing factors as input values and the historical carbon emissions as output values, to construct and train a prediction model based on the LightGBM algorithm; wherein the hyperparameters of the LightGBM algorithm are adjusted using an improved Salp Swarm algorithm to obtain an optimal parameter combination;
[0033] The carbon emission prediction module is configured to predict the carbon emission using a trained prediction model with an optimal parameter combination.
[0034] According to another aspect of the present invention, an electronic device is proposed, comprising: a memory; a processor; and a computer program; wherein the computer program is stored in the memory and is configured to be executed by the processor to implement the carbon emission prediction method based on energy data as described above.
[0035] According to another aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored; the computer program is executed by a processor to implement the carbon emission prediction method based on energy data as described above.
[0036] The beneficial technical effects of the present invention are:
[0037] The present invention proposes a carbon emission prediction method, device, equipment and storage medium based on energy data. First, the influencing factors of carbon emissions are determined, and the historical data of the influencing factors and the corresponding historical carbon emissions are obtained; the influencing factors include economic factors, population factors, scientific and technological investment, energy structure, energy consumption intensity, and industrial structure; then the historical data of the influencing factors are used as input values, and the historical carbon emissions are used as output values to construct and train a prediction model based on the LightGBM algorithm; wherein the hyperparameters of the LightGBM algorithm are adjusted using the improved salp swarm algorithm to obtain the optimal parameter combination; finally, the trained prediction model with the optimal parameter combination is used to predict carbon emissions. The LightGBM algorithm model optimized by the improved salp swarm algorithm in the present invention has a smaller root mean square error and a shorter average time consumption, and the improved salp swarm algorithm has obvious improvements in convergence performance and the ability to find the optimal solution. Applying the present invention to carbon emission forecasting is conducive to tracking and monitoring carbon emissions, improving the accuracy of carbon emission calculation results and forecasts; it can reduce costs and risks, help enterprises to promptly discover emission anomalies or high-energy-consuming equipment, take timely countermeasures, and reduce energy consumption and carbon emissions. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, in which:
[0039] Figure 1 The figure is a flow chart of a carbon emission prediction method based on energy data according to an embodiment of the present invention.
[0040] Figure 2 This is a diagram of the shape of an individual salp.
[0041] Figure 3 This is a diagram of the shape of the salp group.
[0042] Figure 4 The present invention is a flowchart of adjusting the hyperparameters of the LightGBM algorithm using the improved salp swarm algorithm according to an embodiment of the present invention.
[0043] Figure 5 It is a performance test comparison chart of a traditional salp swarm algorithm and an improved salp swarm algorithm according to an embodiment of the present invention.
[0044] Figure 6 The figure is a schematic diagram of the structure of a carbon emission prediction device based on energy data according to an embodiment of the present invention.
[0045] Figure 7FIG. 1 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0046] The principles and spirit of the present invention will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present invention, and are not intended to limit the scope of the present invention in any way. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.
[0047] Those skilled in the art know that the embodiments of the present invention can be implemented as a system, device, equipment, method or computer program product. Therefore, the present disclosure can be specifically implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software. In this article, it is to be understood that any number of elements in the drawings is for illustration and not limitation, and any naming is only for distinction and does not have any limiting meaning.
[0048] The embodiment of the present invention proposes a carbon emission prediction method based on energy data, such as Figure 1 As shown, the method comprises the following steps:
[0049] S1. Determine the influencing factors of carbon emissions and obtain historical data of the influencing factors and the corresponding historical carbon emissions; the influencing factors include economic factors, demographic factors, scientific and technological investment, energy structure, energy consumption intensity, and industrial structure;
[0050] S2. Using the historical data of the influencing factors as input values and the historical carbon emissions as output values, a prediction model based on the LightGBM algorithm is constructed and trained; wherein the hyperparameters of the LightGBM algorithm are adjusted using the improved Salp Swarm algorithm to obtain the optimal parameter combination;
[0051] S3. Use the trained prediction model with the optimal parameter combination to predict carbon emissions.
[0052] The method starts at S1. In S1, factors affecting carbon emissions are determined, and historical data of the factors affecting carbon emissions and corresponding historical carbon emissions are obtained.
[0053] According to an embodiment of the present invention, first, factors affecting carbon emissions are determined as follows.
[0054] 1) Economic factors: GDP, as an important economic factor, is the main indicator for measuring regional economic operations and can reflect the level of regional economic development. Economic growth is important, but rapid economic growth also generates a large amount of energy consumption, causing a significant increase in carbon emissions. Social fixed asset investment is also an important driving factor for economic growth.
[0055] 2) Population factors: The growth in the number of employed people will inevitably lead to an increase in energy demand, and the demand for energy for daily life and transportation will further increase. The consumption of these energy activities will increase carbon emissions.
[0056] 3) Investment in science and technology: Technological progress in energy use plays an important role in reducing greenhouse gas emissions.
[0057] 4) Energy structure: The development and utilization of new energy sources are the focus of carbon emission reduction. Different energy structures will cause differences in carbon emissions. The energy structure is characterized by the ratio of total carbon emissions to energy consumption, that is, energy structure = total carbon emissions / energy consumption. According to the carbon content, the greater the proportion of fossil fuel consumption such as coal and oil, the greater the carbon emissions and the greater the energy carbon emission factor value. The higher the proportion of renewable energy consumption, the smaller the carbon emissions and the smaller the corresponding energy carbon emission factor value.
[0058] 5) Energy intensity: Energy intensity is represented by the ratio of total energy consumption to total output value of the park, that is, energy intensity = total energy consumption / regional total output value. Energy intensity is often used to measure the comprehensive energy utilization rate of a region.
[0059] 6) Industrial structure: that is, the proportion of the output value of the tertiary industry in the total output value. The calculation formula is as follows: Tertiary industry = output value of the tertiary industry / regional GDP*100%.
[0060] Combined with the research and analysis of factors affecting carbon emissions, the factors affecting carbon emissions are determined as shown in Table 1.
[0061] Table 1
[0062]
[0063]
[0064] As an example, the relevant data of a city or an industrial park can be selected as historical data. For example, the carbon emissions of the industrial park in a few years are selected as the research period. The historical data of various influencing factors are mainly obtained from the statistical yearbook of the industrial park, the comprehensive report on economic and social development of the park management committee, and planning content. After selection and sorting, the activity data of various influencing factors are obtained, and the interpolation method is used to fill in some missing values.
[0065] Then execute S2. In S2, the historical data of the influencing factors are used as input values, and the historical carbon emissions are used as output values to build and train a prediction model based on the LightGBM algorithm; wherein, the improved Salp Swarm algorithm is used to adjust the hyperparameters of the LightGBM algorithm to obtain the optimal parameter combination.
[0066] According to an embodiment of the present invention, compared with many existing machine learning models, the LightGBM algorithm performs better in processing large-scale data, but one of the important features of the model is that it has many parameters. The LightGBM algorithm has seven major types of parameters including core parameters, learning control parameters, etc. The main hyperparameters of the model include learning rate, maximum depth of the tree, number of iterations, number of leaf nodes on each tree, minimum amount of data on each leaf node, minimum leaf node sample weight and, sample sampling ratio of each tree, data ratio used in each iteration, L1 regularization parameter, and L2 regularization parameter. Among them, the parameters affecting the accuracy rate include the maximum depth of the tree and the learning rate. The larger the number of decision trees, the higher the accuracy rate; the higher the learning rate, the faster the model is trained. The parameters affecting the degree of fitting include L1 regularization parameter, L2 regularization parameter, sample sampling ratio, etc. When the training set is small, L1 regularization can effectively reduce the complexity of the model and avoid overfitting problems; but when the training set is large, L1 regularization may cause the performance of the model to decline. L2 regularization is implemented by adding the square of the model's coefficients to the loss function, which prevents the model from overfitting.
[0067] Unlike general parameters that can be directly derived through automatic learning during the training data process, hyperparameters cannot usually be set manually. Their selection is crucial to model performance and generalization ability. Therefore, hyperparameter tuning is a key step in training machine learning models. At present, hyperparameter tuning methods can be mainly divided into two types: manual tuning and automatic tuning. Manual tuning methods are easy to implement, but more dependent on the operator's own experience; automatic tuning specifically includes a variety of methods. As the size of the data set increases and the complexity of the model increases, the automatic tuning method shows an efficiency advantage.
[0068] Therefore, the present invention introduces the salp swarm algorithm for automatic parameter adjustment, which can make full use of the parameter space for search and find the optimal parameter combination. The salp swarm algorithm (SSA) is a new optimization algorithm proposed in 2017. Salps are marine planktonic tunicates of the subphylum Salmonidae, which are highly similar to jellyfish and can float freely. The individual shapes of salps are as follows: Figure 2 As shown in Figure 2, salps forage and move in a chain-like group, with each group connected end to end. Figure 3As shown in Figure 2, the salp group is divided into two parts: leaders and followers. The leader is located at the front of the salp group, and the other individuals are followers. The followers follow the leader, and the leader moves according to the location of the food source.
[0069] The optimization process of the salp swarm algorithm is imitated from the foraging process of the salp swarm, and the process of the salp swarm searching for the best food source location is analogous to finding the optimal parameters. Unlike other bionic optimization algorithms, the leader does not determine the movement direction of the entire group, and the followers will update their positions under the influence of the previous individuals. The leader's leadership role for the followers behind is getting weaker and weaker, so the followers will not change their positions due to the leader's position, ensuring the diversity of the population. The salp swarm algorithm records the optimal solution and assigns the recorded value to the food source. The food source will not change due to the deterioration of the population; the salp swarm algorithm only updates the leader's position for the food source, so the leader is always exploring and developing the surrounding space; the follower's following movement improves the local search performance and the efficiency of finding the optimal solution.
[0070] During the actual iteration process of the algorithm, the location of the target food is random. Therefore, during the iteration process, it is necessary to calculate and compare the fitness values of all salps, and set the location of the best salp as the food source based on the sorting. Finally, the location of the food source is updated based on the location of the global optimal salp.
[0071] The specific steps of the salp swarm algorithm are as follows:
[0072] The first step is to set parameters and initialize the population. The positions of salps are randomly initialized to generate a random population of size N×D.
[0073] Step 2: Calculate the fitness value of each salp individual. According to the objective function calculation formula, calculate the fitness values of N salps in the initial population.
[0074] Step 3: Determine the location of the food source. In the actual problem of finding the optimal solution, the optimal solution is unknown. Set the location of the salp with the best fitness as the location of the current iteration food source.
[0075] Step 4: Determine the leader and followers. Remove the top salp individual, and the remaining N-1 salps in the group are sorted according to the initial population fitness. Set the first half of the individuals as leaders and the second half as followers.
[0076] Step 5: Update the position. Update the positions of the leader and follower respectively.
[0077] Step 6: Calculate the fitness of the updated group. Compare it with the fitness value of the food source and set a new food source location, that is, the location of the salp individual with a better fitness value.
[0078] Step 7. Repeat steps 4 to 6. When the calculation reaches the maximum number of iterations, output the current food position as the global optimal solution.
[0079] However, the above traditional salp group algorithm has the following disadvantages: in the leader position update stage, the leader only changes its position according to the food source. When the food source falls into the local optimum, the group will stop searching. In addition, since the individual moves near the food source and the range is not restricted, the individual cannot effectively search at the extreme point in the late convergence period and may jump out of the extreme point. In the follower position update stage, the update of the individual position of the salp only depends on the previous individual and lacks the ability to interact with other individuals, which makes the algorithm easily fall into the local optimal solution and then stagnate. The follower after the updated position will replace the original individual regardless of whether it is good or bad, making it difficult for the algorithm to find the optimal solution.
[0080] Therefore, in order to improve the convergence speed and optimization ability of the salp swarm algorithm, the present invention improves the traditional salp swarm algorithm, and the improvement strategies include: introducing the LEVY flight strategy to update the position of the leader, avoiding the salp swarm algorithm from expanding the search range, and improving the convergence performance of the algorithm; introducing the Gaussian mutation operator to update the position of the follower, avoiding the salp swarm algorithm from falling into the local optimal solution, and improving the optimization ability of the algorithm.
[0081] 1) Improvements to leader position updates
[0082] The LEVY process is a continuous-time random process. The theory was first proposed by French scientists. Through the study of the LEVY process, researchers found that the activity patterns of many animals in nature are consistent with the characteristics of the LEVY process. Conversely, the researchers proposed the LEVY flight strategy theory by studying the foraging activities of various animals based on the LEVY process. The LEVY flight strategy is a non-Gaussian random transformation process characterized by long-term random walks with small steps and occasional sudden changes in direction with larger steps. The researchers proposed the following formula to simulate the flight trajectory of LEVY:
[0083]
[0084] 0<β<2
[0085] Where s is the LEVY flight step length; μ and v are two random variables in the LEVY flight strategy. μ and v conform to the following formula:
[0086]
[0087] in It is calculated by the following formula:
[0088]
[0089] Where Γ is the gama distribution function and β is a specific value set.
[0090] In order to optimize the problem of unrestricted movement of individuals near food sources, the present invention adds an adaptive weight factor to avoid falling into the local optimal solution in the early stage of convergence. The influence of the food source on the leader decreases with the increase of the number of iterations, making the result closer and closer to the optimal value. In the early stage of iteration, a larger adaptive weight can make the algorithm have better exploration ability, and in the later stage of iteration, a smaller adaptive weight can make the algorithm have better development ability. The calculation formula of the adaptive weight q is:
[0091] q=q a -(q a -q m )×(t / T) 2
[0092] In the formula, q a ,q m They represent the preset maximum and minimum weights respectively, and T is the total number of iterations.
[0093] In order to optimize the problem that the salp group operator is prone to fall into the local optimal problem, LEVY flight perturbation is added so that the algorithm can maximize the diversification of the search area, thereby optimizing the local optimal problem. The leader position formula after adding LEVY flight perturbation is:
[0094]
[0095] In the formula, is the position of the current salp leader i in the j-dimensional space; q is the adaptive weight; P j is the position of the current food source in the j-dimensional space; c1 and c2 are random numbers uniformly distributed between (0,1); ab j ,tb j is the range of the search space in the jth dimension; t is the current iteration number, and s is the LEVY flight step.
[0096] 2) Improvements to follower position updates
[0097] Gaussian mutation (GM) is an optimization strategy that uses random numbers that follow a normal distribution to act on the original position vector to generate a new position. Gaussian distribution is a probability density function with a narrow tail. Based on the step size generated by the Gaussian mutation operator, the parent individual searches for the generation of offspring individuals in its vicinity, which enhances the diversity of the population, helps to better search for potential areas, and accelerates the convergence trend of the optimization algorithm. The Gaussian probability density formula is as follows:
[0098]
[0099] Among them, μ represents the expected value or mean value of the distribution, and σ represents the standard deviation. In order to combine the characteristics of the current population, two positions in the population are randomly selected, and the difference between the two is used to interact with the Gaussian distribution operator to form a Gaussian mutation operator. The expression of Gaussian mutation is as follows:
[0100]
[0101] in, is the Gaussian distribution formed by the probability density of f(x), They represent two randomly selected position information in the population, O represents the proposed Gaussian mutation operator, and D represents the included dimension.
[0102] In the follower position update stage, the update of the individual position of the salp will only depend on the previous individual, and lack the ability to interact with other individuals, which makes the algorithm easily fall into the local optimal solution, leading to stagnation. The follower after the updated position will replace the original individual regardless of whether it is good or bad, making it difficult for the algorithm to find the optimal solution. To address this type of problem, the present invention introduces the Gaussian mutation operator. When the follower position is updated, since it only depends on the previous individual and lacks sufficient vitality, in order to enable the follower to fully absorb the information of the food source and reduce the computational complexity, the Gaussian mutation operator is added to the original follower position update formula:
[0103]
[0104] In the formula, Indicates the position of the current salp follower ii in the j-dimensional space; To change the asynchronous length, l is a random number uniformly generated in the interval [0,1], n is a system parameter, N represents Gaussian distribution, and σ is the standard deviation of Gaussian distribution.
[0105] In summary, the historical data of influencing factors and historical carbon emissions are divided into two subsets: training set and test set, such as Figure 4 As shown in the figure, the hyperparameters of the LightGBM algorithm are adjusted using the improved salp swarm algorithm. The specific steps to obtain the optimal parameter combination include:
[0106] S21. Set the value range of the hyperparameters of the LightGBM algorithm; randomly initialize the position of the salps and randomly generate a fixed-size population of solution individuals;
[0107] S22. Calculate the fitness of each individual salp: substitute the individual parameters into the LightGBM model for training on the training set, calculate the root mean square error on the test set, and use the inverse of the root mean square error as the fitness function, so as to calculate the fitness value of each individual salp in the initial population according to the fitness function;
[0108] S23, determining the location of the food source: setting the location of the salp individual with the best fitness to the location of the current iteration food source;
[0109] S24, determine the leader and followers: remove the first salp individual, and sort the remaining salps in the group according to the initial population fitness, setting the first half of the individuals as leaders and the second half of the individuals as followers;
[0110] S25, position update: the leader position is updated using the leader position update formula that introduces the LEVY flight strategy, and the follower position is updated using the follower position update formula that introduces the Gaussian mutation operator;
[0111] S26, calculating the updated group fitness: comparing with the fitness value of the food source, setting a new food source position, that is, the position of the salp individual with a better fitness value;
[0112] S27, repeatedly execute S24 to S26; when the number of iterations reaches the maximum number of iterations, output the current food position as the global optimal solution.
[0113] In this embodiment, optionally, when calculating the fitness of each individual salp, after calculating the root mean square error on the test set, the fitness function is further calculated according to the following formula:
[0114] F'=e -aF
[0115] In the formula, F' is the fitness function after exponential transformation; F is the original fitness function, that is, the root mean square error; a s is the preset starting value of a, k is the adjustment factor, a s The values of F and k can be set according to the specific problem; avg is the average value of the population fitness function. Since a is a positive number, F avgIt must be a non-negative number. When the objective function value of an individual in the population is negative, F can be added to a suitable number to ensure that the values of all individuals in the population are non-negative; ε is a number infinitely close to 0 to prevent F avg When the denominator is 0, a program error occurs.
[0116] In the early stage of algorithm iteration, since the fitness function values between individuals are generally dispersed, the value of a is smaller at this time, so that the gap between the fitness function values between individuals can be reduced, and the probability of the best individual being selected is reduced to prevent the best individual from controlling the evolutionary direction of the entire population, so as to maintain the diversity between populations. In the later stage of algorithm iteration, since the fitness function values between populations are generally uniform, the value of a is larger at this time, so that the gap between the fitness function values between individuals in the population can be increased, and the probability of each individual being selected is the same, resulting in low competitiveness between populations. Through adaptive adjustment of the value of a, the algorithm can gradually increase the weight of local search during the iteration process, thereby better balancing global search and local search and accelerating the convergence of the algorithm.
[0117] Furthermore, in order to reduce accidental errors, the parameter adjustment steps are repeated multiple times, and the set of hyperparameters with the smallest average root mean square error is taken as the final solution. After obtaining the final global optimal solution, that is, the optimal parameter combination, the historical data of the influencing factors are used as input values, and the historical carbon emissions are used as output values to train the LightGBM model with the optimal parameter combination to obtain the trained prediction model.
[0118] Finally, S3 is executed, in which the carbon emissions are predicted using the trained prediction model with the optimal parameter combination.
[0119] The technical effect of the present invention is further verified through experiments.
[0120] In order to verify that the improved salp swarm algorithm can better perform parameter search and improve the prediction accuracy of the LightGBM model, the present invention compares the traditional manual parameter adjustment, the traditional salp swarm algorithm and the improved salp swarm algorithm.
[0121] Firstly, the traditional salp swarm algorithm (denoted as SSA) and the improved salp swarm algorithm (denoted as ISSA) are compared to verify the effectiveness of the improved salp swarm algorithm. The convergence performance is shown in Figure 5 shown.
[0122] Then, the maximum population size is set to 80, the maximum number of iterations is set to 800, the crossover factor is set to 0.7, the mutation factor is set to 0.15, and the value range of each hyperparameter of the LightGBM algorithm is set. The hyperparameters obtained by the traditional salp swarm algorithm and the improved salp swarm algorithm are substituted into the model respectively, the learning rate of the model is reduced to 0.01, the data set is divided 50 times and trained and predicted, and the average value of the root mean square error is taken as shown in Table 2 below.
[0123] Table 2
[0124] Prediction Model RMS Error Average Average algorithm time LightGBM traditional manual parameter adjustment 690.55 — LightGBM traditional salp group algorithm parameter adjustment 646.38 8322 LightGBM improved salp group algorithm parameter adjustment 622.56 8063
[0125] It can be seen from Table 2 that the improved salp swarm algorithm can better perform parameter search and improve the prediction accuracy of the LightGBM model.
[0126] Another embodiment of the present invention provides a carbon emission prediction device based on energy data, such as Figure 6 As shown, the system includes:
[0127] A historical data acquisition module 610 is configured to determine the influencing factors of carbon emissions and acquire the historical data of the influencing factors and the corresponding historical carbon emissions; the influencing factors include economic factors, demographic factors, scientific and technological investment, energy structure, energy consumption intensity, and industrial structure;
[0128] A prediction model training module 620 is configured to use the historical data of the influencing factors as input values and the historical carbon emissions as output values to construct and train a prediction model based on the LightGBM algorithm; wherein the hyperparameters of the LightGBM algorithm are adjusted using an improved Salp Swarm algorithm to obtain an optimal parameter combination;
[0129] The carbon emission prediction module 630 is configured to predict the carbon emission using the trained prediction model with the optimal parameter combination.
[0130] For the undetailed parts of the carbon emission prediction device based on energy data according to an embodiment of the present invention, please refer to the above detailed description of the method embodiment.
[0131] The method of the present invention can be executed in an electronic device. The electronic device can be any device with storage and computing capabilities, which can be implemented as a server, a workstation, etc., or as a personal computer such as a desktop computer or a notebook computer, or as a terminal device such as a mobile phone, a tablet computer, a smart wearable device, an Internet of Things device, but is not limited thereto.
[0132] Figure 7 Schematic diagram of an electronic device according to an embodiment of the present invention is shown. Figure 7 As shown, the electronic device may include: a processor 710, a memory 720, an input / output interface 730, a communication interface 740 and a bus 750. The processor 710, the memory 720, the input / output interface 730 and the communication interface 740 are connected to each other through the bus 750. The processor 710 can be implemented in a general CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc., for executing related programs to implement the technical solutions provided in the embodiments of this specification. The memory 720 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, etc. The memory 720 can store operating systems and other applications. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 720 and are called and executed by the processor 710. The input / output interface 730 is used to connect the input / output module to implement information input and output. The input / output / module can be configured as a component in an electronic device (not shown in the figure), or it can be externally connected to an electronic device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc. The communication interface 740 is used to connect a communication module (not shown in the figure) to realize communication interaction between this electronic device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or through a wireless mode (such as mobile network, WIFI, Bluetooth, etc.). The bus 750 includes a channel to transmit information between various components of the electronic device (such as a processor 710, a memory 720, an input / output interface 730, and a communication interface 740).
[0133] The embodiment of the present invention also provides a non-transitory readable storage medium, which stores instructions, and the instructions are used to make the electronic device perform a method according to an embodiment of the present invention. The readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be a computer-readable instruction, a data structure, a module of a program, or other data. Examples of readable storage media include, but are not limited to: phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape disk storage, etc.
[0134] It should be noted that, although several units, modules or submodules are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more modules described above can be embodied in one module. Conversely, the features and functions of one module described above can be further divided into being embodied by multiple modules.
[0135] In addition, although the operations of the method of the present invention are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0136] Although the spirit and principle of the present invention have been described with reference to several specific embodiments, it should be understood that the present invention is not limited to the disclosed specific embodiments, and the division of various aspects does not mean that the features in these aspects cannot be combined to benefit, and such division is only for the convenience of expression. The present invention is intended to cover various modifications and equivalent arrangements included in the spirit and scope of the attached claims.
Claims
1. A carbon emission prediction method based on energy data, characterized in that: The following steps are involved: Determine the influencing factors of carbon emissions, and obtain historical data of the influencing factors and the corresponding historical carbon emissions; the influencing factors include economic factors, demographic factors, scientific and technological investment, energy structure, energy consumption intensity, and industrial structure; The historical data of the influencing factors are used as input values, and the historical carbon emissions are used as output values to construct and train a prediction model based on the LightGBM algorithm; wherein the hyperparameters of the LightGBM algorithm are adjusted using the improved Salp Swarm algorithm to obtain the optimal parameter combination; Carbon emissions are predicted using the trained prediction model with the optimal parameter combination.
2. A carbon emission prediction method based on energy data according to claim 1, characterized in that: The hyperparameters of the LightGBM algorithm include learning rate, maximum depth of the tree, number of iterations, number of leaf nodes on each tree, minimum amount of data on each leaf node, minimum leaf node sample weight and, sample sampling ratio of each tree, data ratio used in each iteration, L1 regularization parameter, and L2 regularization parameter.
3. The carbon emission prediction method based on energy data according to claim 2 is characterized in that: The improved salp swarm algorithm is used to adjust the hyperparameters of the LightGBM algorithm to obtain the optimal parameter combination, including: Set the value range of the hyperparameters of the LightGBM algorithm; randomly initialize the position of the salps to generate a fixed-size population of solution individuals; Calculate the fitness of each salp individual: substitute the individual parameters into the LightGBM model for training on the training set, calculate the root mean square error on the test set, and use the inverse of the root mean square error as the fitness function, so as to calculate the fitness value of each salp individual in the initial population according to the fitness function; Determine the location of the food source: set the location of the salp with the best fitness as the location of the food source of the current iteration; Determine the leader and followers: remove the top salp individual, sort the remaining salps in the group according to the initial population fitness, set the first half of the individuals as leaders, and the second half of the individuals as followers; Position update: Update the positions of the leader and follower respectively; Calculate the updated group fitness: compare it with the fitness value of the food source and set the new food source position, that is, the position of the salp individual with better fitness value; Repeat the process of determining the leader and follower, updating the position, and calculating the updated group fitness; when the number of iterations reaches the maximum number of iterations, output the current food position as the global optimal solution.
4. The carbon emission prediction method based on energy data according to claim 3 is characterized in that: The LEVY flight strategy is introduced in the position update to update the position of the leader. The leader position formula after adding the LEVY flight disturbance is: In the formula, is the position of the current salp leader i in the j-dimensional space; q is the adaptive weight; P j is the position of the current food source in the j-dimensional space; c1 and c2 are random numbers uniformly distributed between (0, 1); ab j ,tb j is the range of the search space in the jth dimension; t is the current iteration number, and s is the LEVY flight step.
5. The carbon emission prediction method based on energy data according to claim 4 is characterized in that: The calculation formula of the adaptive weight q in the leader position formula after adding the LEVY flight disturbance is: q=q a -(q a -q m )×(t / T) 2 In the formula, q a ,q m They represent the preset maximum and minimum weights respectively, and T is the total number of iterations.
6. A carbon emission prediction method based on energy data according to claim 5, characterized in that: The Gaussian mutation operator is introduced in the position update to update the position of the follower. The follower position formula after the introduction of the Gaussian mutation operator is: In the formula, Indicates the position of the current salp follower ii in the,-dimensional space; To change the step length, Δ(t, b) = b(1-l(1-t / T) n ), l is a random number uniformly generated in the interval [0, 1], n is a system parameter, N represents Gaussian distribution, and σ is the standard deviation of Gaussian distribution.
7. The carbon emission prediction method based on energy data according to claim 3 is characterized in that: When calculating the fitness of each individual salp, after calculating the root mean square error on the test set, the fitness function is further calculated according to the following formula: F′=e -aF In the formula, F′ is the fitness function after exponential transformation; F is the original fitness function, that is, the root mean square error; a s is the preset starting value of a, k is the adjustment factor, F avg is the average value of the population fitness function, and ε is a number infinitely close to 0.
8. A carbon emission prediction device based on energy data, characterized in that: include: A historical data acquisition module, which is configured to determine the influencing factors of carbon emissions and acquire the historical data of the influencing factors and the corresponding historical carbon emissions; the influencing factors include economic factors, demographic factors, scientific and technological investment, energy structure, energy consumption intensity, and industrial structure; A prediction model training module, which is configured to use the historical data of the influencing factors as input values and the historical carbon emissions as output values, to construct and train a prediction model based on the LightGBM algorithm; wherein the hyperparameters of the LightGBM algorithm are adjusted using an improved Salp Swarm algorithm to obtain an optimal parameter combination; The carbon emission prediction module is configured to predict the carbon emission using a trained prediction model with an optimal parameter combination.
9. An electronic device, characterized in that: include: A memory, a processor, and a computer program; wherein the computer program is stored in the memory and configured to be executed by the processor to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The storage medium stores a computer program; the computer program is executed by a processor to implement the method according to any one of claims 1 to 7.
Citation Information
Cited By
Carbon emission tracking system based on Internet of Things technology
CN120069337A